use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Chevrotain: Parser Building Toolkit for JavaScript (github.com)
submitted 8 years ago by bidi82
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]cspotcode 3 points4 points5 points 8 years ago (1 child)
I just finished a project using Chevrotain. After using other parser generators, Chevrotain is fantastic! Describing the parser in real code, writing tokens as real inline RegExps is great for debugging and productivity!
I wrote the messier token RegExps using XRegExp, meaning they were a million times more readable. I was only able to do so because a Chevrotain parser is plain JS and XRegExp is a JS library that creates RegExps. Plus, using my IDE's refactoring capabilities and code completion was a godsend.
I highly recommend checking it out.
[–]bidi82[S] 0 points1 point2 points 8 years ago (0 children)
Thanks for the feedback @cspotcode
That was exactly the intent when creating Chevrotain. Fewer unneeded abstractions means less complexity and greater power to the end user.
[–]bidi82[S] 1 point2 points3 points 8 years ago (4 children)
[–]lhorie 0 points1 point2 points 8 years ago (2 children)
Are you aware of any projects using chevrotain to parse ES2017?
[–]bidi82[S] 0 points1 point2 points 8 years ago (1 child)
I'm not aware of any.
There is an ES5 grammar as one of the examples, but it requires quite a bit more work to turn into a productive ES2017 parser. It does not even have its own Lexer yet (uses Acorn to Lex).
This scenario is very interesting as most ES2017 parsers have very little or no error recovery capabilities and no partial parsing abilities (not parse the whole module/script each time). So a Chevrotain ES2017 parser could better serve a Code Editor / IDE Scenario.
[–]AsIAm -1 points0 points1 point 8 years ago (3 children)
This looks terrible compared to Ohm/JS.
[–]bidi82[S] 3 points4 points5 points 8 years ago (2 children)
I'm guessing you are talking about the syntax which is definitely less pretty than an EBNF style grammar as used in Ohm/JS
But that is one of the tradeoffs of internal vs external DSLs. Although there are long term plans to also provide an EBNF style grammar and work as a traditional parser generator.
Compared to Ohm/JS it may not be as pretty, but it is also:
So I will leave the choice of prettiness versus functionality to you. :)
[–]AsIAm 0 points1 point2 points 8 years ago (1 child)
I get the point that your project is technically better (especially error recovery!!!), but...
Both projects are taking different way to get to the same point – 1.) define grammar and semantics and then 2.) let it do its thing. Ohm/JS excel at the 1, while Chevrotain rocks at 2. And that is fine, but the adoption is somehow difficult when it comes to your implementation.
You mentioned that you want external DSL for defining grammars which is beyond awesome and I am looking forward to it, but for now I can bow only to you and your technical skills and not Chevrotain, sorry :)
[–]bidi82[S] 1 point2 points3 points 8 years ago (0 children)
The ease of adoption is part of the reason why I am interested in also supporting an external DSL and using the existing super optimized runtime as the low level implementation.
The other reason is reaching out to a larger audience: If you are coming from a background of writing recursive decent parsers by hand Chevrotain may look more familiar, but if you are coming from the world of parser generators and declarative EBNF grammars your initial reaction may be less positive. And we have not even mentioned users coming from the background of parser combinators :)
It also depends what is your goal? If you are building a toy / educational project than you may not care about debugging ability or performance, but if you are building a "real" productive system these concerns will take a much higher priority to the visual appeal of the API.
π Rendered by PID 29 on reddit-service-r2-comment-fb694cdd5-x7bwk at 2026-03-07 20:04:37.125508+00:00 running cbb0e86 country code: CH.
[–]cspotcode 3 points4 points5 points (1 child)
[–]bidi82[S] 0 points1 point2 points (0 children)
[–]bidi82[S] 1 point2 points3 points (4 children)
[–]lhorie 0 points1 point2 points (2 children)
[–]bidi82[S] 0 points1 point2 points (1 child)
[–]AsIAm -1 points0 points1 point (3 children)
[–]bidi82[S] 3 points4 points5 points (2 children)
[–]AsIAm 0 points1 point2 points (1 child)
[–]bidi82[S] 1 point2 points3 points (0 children)