mirror of
https://github.com/IvarK/AntimatterDimensionsSourceCode.git
synced 2024-09-20 11:01:45 +00:00
Fix ! parsing in automator scripts
This commit is contained in:
parent
a56ebc7762
commit
8a69c2bc32
|
@ -98,9 +98,10 @@ CodeMirror.defineSimpleMode("automato", {
|
|||
{ regex: /(antimatter|infinity|time)(?=[\s,|]|$)/ui, token: "number" },
|
||||
{ regex: /(active|passive|idle)(?=[\s,|]|$)/ui, token: "number" },
|
||||
{ regex: /(light|dark)(?=[\s,|]|$)/ui, token: "number" },
|
||||
{ regex: /([1-9][0-9]+)(?=[\s,|-]|$)/ui, token: "number" },
|
||||
{ regex: /([1-9][0-9]+)(?=[\s,!|-]|$)/ui, token: "number" },
|
||||
{ regex: /[a-zA-Z_][a-zA-Z_0-9]*/u, token: "variable", next: "commandDone" },
|
||||
{ regex: /([1-9]|1[0-2])$/ui, token: "number" },
|
||||
{ regex: /!$/ui, token: "variable-2" },
|
||||
{ regex: /([1-9]|1[0-2])(?=!|$)/ui, token: "number" },
|
||||
],
|
||||
studiesLoad: [
|
||||
commentRule,
|
||||
|
|
|
@ -322,7 +322,8 @@ class Validator extends BaseVisitor {
|
|||
ctx.$cached = {
|
||||
normal: studiesOut,
|
||||
image: this.rawText.substr(positionRange.startOffset, positionRange.endOffset - positionRange.startOffset + 1),
|
||||
ec: 0
|
||||
ec: 0,
|
||||
startEC: false,
|
||||
};
|
||||
if (ctx.ECNumber) {
|
||||
if (ctx.ECNumber.isInsertedInRecovery) {
|
||||
|
@ -336,6 +337,7 @@ class Validator extends BaseVisitor {
|
|||
}
|
||||
ctx.$cached.ec = ecNumber;
|
||||
}
|
||||
if (ctx.Exclamation) ctx.$cached.startEC = true;
|
||||
return ctx.$cached;
|
||||
}
|
||||
|
||||
|
|
|
@ -354,12 +354,13 @@ const RCurly = createToken({ name: "RCurly", pattern: /[ \t]*}/ });
|
|||
const Comma = createToken({ name: "Comma", pattern: /,/ });
|
||||
const Pipe = createToken({ name: "Pipe", pattern: /\|/, label: "|" });
|
||||
const Dash = createToken({ name: "Dash", pattern: /-/, label: "-" });
|
||||
const Exclamation = createToken({ name: "Exclamation", pattern: /!/, label: "!" });
|
||||
|
||||
// The order here is the order the lexer looks for tokens in.
|
||||
export const automatorTokens = [
|
||||
HSpace, StringLiteral, StringLiteralSingleQuote, Comment, EOL,
|
||||
ComparisonOperator, ...tokenLists.ComparisonOperator,
|
||||
LCurly, RCurly, Comma, EqualSign, Pipe, Dash,
|
||||
LCurly, RCurly, Comma, EqualSign, Pipe, Dash, Exclamation,
|
||||
BlackHoleStr, NumberLiteral,
|
||||
AutomatorCurrency, ...tokenLists.AutomatorCurrency,
|
||||
ECLiteral,
|
||||
|
|
|
@ -89,10 +89,11 @@ class AutomatorParser extends Parser {
|
|||
|
||||
$.RULE("studyList", () => {
|
||||
$.AT_LEAST_ONE(() => $.SUBRULE($.studyListEntry));
|
||||
// Support the |3 export format for EC number
|
||||
// Support the |3 export format for EC number and optionally the ending exclamation point
|
||||
$.OPTION(() => {
|
||||
$.CONSUME(T.Pipe);
|
||||
$.CONSUME1(T.NumberLiteral, { LABEL: "ECNumber" });
|
||||
$.OPTION1(() => $.CONSUME(T.Exclamation));
|
||||
});
|
||||
}, { resyncEnabled: false });
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user