kach / nearley

📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
https://nearley.js.org
MIT License
3.57k stars 231 forks source link

Allow the user to pick an output language #611

Closed DavidTanner closed 1 year ago

DavidTanner commented 2 years ago

I would like to be able to use the cli to generate typescript output. This change adds an optional language flag to specify which of the existing generators might be used.

the-jasoney commented 2 years ago

Just use @preprocessor in your grammar file. For example: @preprocessor typescript at the beginning of your grammar file lets you use typescript in your post-processors and generates typescript for you. @preprocessor also supports coffeescript.

DavidTanner commented 1 year ago

Awesome. Thank you for the answer. That took a bit of digging to find in the docs. https://nearley.js.org/docs/parser#using-preprocessors