Skip to content

kristianmandrup/chevrotain-editor-utils

Repository files navigation

Chevrotain Editor Utils

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

Add SyntaxModel to Parser

const SyntaxParser = withSyntaxModeller(MyParser)

This will add the special API wrapper methods to your Parser:

  • consumeStx consume token with addition syntax meta data
  • subruleStx and subruleStx2 evaluate subrule with addition syntax meta data
  • syntax 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);

Documentation

About

Chevrotain utils to help add editor/IDE support to chevrotain based parser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published