I've downloaded syntax-cli and ran the following command and get errors, could someone help?
npm install -g syntax-cli
I created a file call letter.bnf with the following content:
%lex
%%
\s+ /* do nothing */
\d+ return 'NUMBER'
/lex
%%
E
: E '+' t
| t
;
T
: T '*' F
| F
;
F
: NUMBER
;
I then ran the command as follows:
syntax-cli --grammar letter.bnf --mode LALR1 --parse '2'
I keep getting the following error, what am I doing wrong?
Parsing mode: LALR1_BY_SLR(1).
Parsing:
2
SyntaxError:
2
^
Unexpected token: "2" at 1:0.
at Tokenizer.throwUnexpectedToken (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/dist/tokenizer.js:312:13)
at LRParser._unexpectedToken (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/dist/lr/lr-parser.js:224:23)
at LRParser.parse (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/dist/lr/lr-parser.js:163:16)
at lrParse (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/dist/bin/syntax.js:513:6)
at parse (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/dist/bin/syntax.js:488:45)
at Object._genericLR (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/dist/bin/syntax.js:372:7)
at Object.LALR1_BY_SLR1 (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/dist/bin/syntax.js:343:17)
at Object.LALR1 (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/dist/bin/syntax.js:340:17)
at main (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/dist/bin/syntax.js:753:32)
at Object.<anonymous> (/home/dancomp71/.nvm/versions/node/v16.16.0/lib/node_modules/syntax-cli/bin/syntax:5:30)
I've tried the command in a docker container, i've uploaded the code to my github, but I can't find the problem. I ran the command in wsl (windows/ubuntu) and in a ubuntu container with node, npm and syntax-cli installed.