This library containts a set of utilies aimed at making it easier to add Editor/IDE support for chevrotain parsers.
The library currently consists of:
- Syntax Generator
- Syntax Model
- Parser utilities
const SyntaxParser = withSyntaxModeller(MyParser)
This will add the special API wrapper methods to your Parser:
consumeStx
consume token with addition syntax meta datasubruleStx
andsubruleStx2
evaluate subrule with addition syntax meta datasyntax
add additional syntax information to syntax model
These methods lets you build an internal syntax model when you parse.
To use the full syntax infrastructure:
import { writeSyntaxFile } from "chevrotain-editor-utils";
// configure parser
const parser = new Parser(config, tokenTypes, tokens, performSelfAnalysis);
parser.tokenMap = tokenMap;
// "fake" parse
parser.parse(doc);
// write to syntax file
const syntaxJsonStr = generateSyntaxJson(parser.syntaxModel.model);
writeSyntaxFile("sqlx", syntaxJsonStr);