Generating a Parser
To generate a parser from your grammar, use the
$ pegjs arithmetics.pegjs
This writes parser source code into a file with the same name as the grammar file but with “.js” extension. You can also specify the output file explicitly:
$ pegjs -o arithmetics-parser.js arithmetics.pegjs
If you omit both input and output files, the standard input and output are used (REPL mode).
By default, the generated parser is in the Node.js module format. You can override this using the
You can tweak the generated parser with several options.
To generate a parser using the module, take a look at the section about the method