4 ms·
Thanks for the feedback. The Lexer and Parser both expose a collection of Errors. http://sap.github.io/chevrotain/documentation/0_5_19/classes/parser.html#erro
by bd82 11y ago
Thanks for the feedback.
The Lexer and Parser both expose a collection of Errors.
http://sap.github.io/chevrotain/documentation/0_5_19/classes/parser.html#errors http://sap.github.io/chevrotain/documentation/0_5_19/classes...
http://sap.github.io/chevrotain/documentation/0_5_19/interfaces/ilexingresult.html#errors http://sap.github.io/chevrotain/documentation/0_5_19/interfa...
Both contain information regarding the position of the error.
For a lexer Error it is an offset.
For a Parsing Error the erroneous Token is referenced,
It contains line/column/offset and more...
If you want to build an Editor using codeMirror
you will have to extract that error position information
and highlight it using codeMirror's APIs.
example:
https://github.com/SAP/chevrotain/blob/gh-pages/playground/errorMarkers.js#L1 https://github.com/SAP/chevrotain/blob/gh-pages/playground/e...
Chevrotain is not aware of codeMirror/ACE or any other Editor frameworks. It is just a ±3,000 LOC library meant for building parsers.
If you are indeed interested in building an Online Editor
for some language, you may want to have a look here:
https://github.com/SAP/demos_json_editor_services_chevrotain https://github.com/SAP/demos_json_editor_services_chevrotain
It is a work in progress on using Chevrotain to build Editor services (outline/formatting/Ast Building/...).
- david-given 11y agoThat's ideal. It's so nice to have a parser which actually does proper error handling. So many really nice parsers completely fail to do this --- e.g. Lua's PEG works really, really well, except when you give it invalid input, at which point it usually just gives up and goes home...