I’m trying to create some kind of lint
tool for the C/AL programming language. So basically I need to perform syntax and lexical analysis against the source code. I’ve planned to write parser from the scratch, but then discovered that there are a lots of tools helping generate these parsers automatically.
I need performance, since checking 20 megabytes of code in one piece is the normal scenario, and I need that tool to be extendable by custom rules. So I decided to go with JavaScript.
As far I have found two generators I can use Jison and PEG.js.
Which of them give me more parsing performance? Maybe not comparing libraries, but algorithms?
Which one is better for my needs (parsing general purpose programming language)?
UPDATE: I have found similar Q&As:
Advertisement
Answer
In general you’d get very good parsing performance from a shift-reduce parser such as the one that Jison implements. It’s a bit old-school perhaps, but it can work in very tight memory requirements and in linear time.
PEG produces a different kind of parser that is perhaps more capable, but would require more memory to produce the same result. I.e. PEG will require an amount of memory proportional to the input, while a LALR parser will do it in much less space (some tables and a small stack).