DmitrySoshnikov / syntax

Syntactic analysis toolkit, language-agnostic parser generator.
MIT License
615 stars 88 forks source link

syntaxerror unexpected token #120

Open dancomp71 opened 2 years ago

dancomp71 commented 2 years ago

C:\dev\@compiler\grammar>type letter.bnf %lex

%%

\d+ return 'NUMBER'

/lex

%%

E : E '+' t | t ;

T : T '*' F | F ; F : NUMBER ;

C:\dev\@compiler\grammar>syntax-cli --grammar letter.bnf --mode LALR1 --parse '2'

Parsing mode: LALR1_BY_SLR(1).

Parsing:

'2'

SyntaxError:

'2' ^ Unexpected token: "'" at 1:0. at Tokenizer.throwUnexpectedToken (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\dist\tokenizer.js:312:13) at Tokenizer.getNextToken (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\dist\tokenizer.js:292:12) at LRParser.parse (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\dist\lr\lr-parser.js:150:35) at lrParse (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\dist\bin\syntax.js:513:6) at parse (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\dist\bin\syntax.js:488:45) at Object._genericLR (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\dist\bin\syntax.js:372:7) at Object.LALR1_BY_SLR1 (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\dist\bin\syntax.js:343:17) at Object.LALR1 (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\dist\bin\syntax.js:340:17) at main (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\dist\bin\syntax.js:753:32) at Object. (C:\Users\Daniel Serrano\AppData\Roaming\npm\node_modules\syntax-cli\bin\syntax:5:30)

DmitrySoshnikov commented 2 years ago

Please address documentation for the Windows command line interface. Likely you'll need to pass strings in double-quotes, either '"2"' or "2".