Skip to content

Commit

Permalink
Fix issue with ids beginning with True/False
Browse files Browse the repository at this point in the history
  • Loading branch information
nikmolnar committed Jan 5, 2022
1 parent 88e453b commit 60d9c1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion jison/mpilot.jison
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const { parseEntities } = _entities
":" return "COLON";
"," return "COMMA";
"=" return "EQUAL";
[a-zA-Z_][a-zA-Z_0-9]* return "ID";
"False" return "FALSE";
[\-\+]?((\d+\.\d*)|(\.\d+))([eE][\+\-]?\d+)? return "FLOAT";
[a-zA-Z_][a-zA-Z_0-9]* return "ID";
[\-\+]?\d+ return "INT";
"[" return "LBRACK";
"(" return "LPAREN";
Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,8 @@ describe('parser', () => {
},
])
})

test('FalseThreshold does not tokenize as FALSE', () => {
expect(parse('A = Command(FalseThreshold = 1.0)').commands[0].arguments[0].name).toEqual('FalseThreshold')
})
})
18 changes: 9 additions & 9 deletions src/parser/mpilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4014,16 +4014,16 @@ EOF: 1,
4: 4,

/*! Conditions:: INITIAL */
/*! Rule:: False */
5: 16,
/*! Rule:: [a-zA-Z_][a-zA-Z_0-9]* */
5: 3,

/*! Conditions:: INITIAL */
/*! Rule:: [\-\+]?((\d+\.\d*)|(\.\d+))([eE][\+\-]?\d+)? */
6: 11,
/*! Rule:: False */
6: 16,

/*! Conditions:: INITIAL */
/*! Rule:: [a-zA-Z_][a-zA-Z_0-9]* */
7: 3,
/*! Rule:: [\-\+]?((\d+\.\d*)|(\.\d+))([eE][\+\-]?\d+)? */
7: 11,

/*! Conditions:: INITIAL */
/*! Rule:: [\-\+]?\d+ */
Expand Down Expand Up @@ -4068,9 +4068,9 @@ EOF: 1,
/* 2: */ /^(?::)/,
/* 3: */ /^(?:,)/,
/* 4: */ /^(?:=)/,
/* 5: */ /^(?:False)/,
/* 6: */ /^(?:[+\-]?((\d+\.\d*)|(\.\d+))([Ee][+\-]?\d+)?)/,
/* 7: */ /^(?:[^\W\d]\w*)/,
/* 5: */ /^(?:[^\W\d]\w*)/,
/* 6: */ /^(?:False)/,
/* 7: */ /^(?:[+\-]?((\d+\.\d*)|(\.\d+))([Ee][+\-]?\d+)?)/,
/* 8: */ /^(?:[+\-]?\d+)/,
/* 9: */ /^(?:\[)/,
/* 10: */ /^(?:\()/,
Expand Down

0 comments on commit 60d9c1b

Please sign in to comment.