How to use the chevrotain.extendToken function in chevrotain

To help you get started, we’ve selected a few chevrotain examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / chevrotain / examples / parser / large_lookahead / large_lookahead.js View on Github external
var chevrotain = require("chevrotain");

// ----------------- lexer -----------------
var extendToken = chevrotain.extendToken;
var Lexer = chevrotain.Lexer;
var Parser = chevrotain.Parser;

var Assign = extendToken("Assign", /=/);
var Export = extendToken("Export", /export/);
var Interface = extendToken("Interface", /interface/);
var Identifier = extendToken("Identifier", /\w+/);

var WhiteSpace = extendToken("WhiteSpace", /\s+/);
WhiteSpace.GROUP = Lexer.SKIPPED; // marking WhiteSpace as 'SKIPPED' makes the lexer skip it.

var allTokens = [
    WhiteSpace, // whitespace is normally very common so it should be placed first to speed up the lexer's performance
    Assign,
    Export,
    Interface,
github SAP / chevrotain / examples / jison_lex / jsonParser.js View on Github external
var chevrotain = require("chevrotain");
var JisonLex = require('jison-lex');

// ----------------- lexer -----------------
var Parser = chevrotain.Parser;
var extendToken = chevrotain.extendToken;


// In ES6, custom inheritance implementation (such as the one above) can be replaced with simple "class X extends Y"...
var True = extendToken("True");
var False = extendToken("False");
var Null = extendToken("Null");
var LCurly = extendToken("LCurly");
var RCurly = extendToken("RCurly");
var LSquare = extendToken("LSquare");
var RSquare = extendToken("RSquare");
var Comma = extendToken("Comma");
var Colon = extendToken("Colon");
var StringLiteral = extendToken("StringLiteral");
var NumberLiteral = extendToken("NumberLiteral");

// DOCS: this object will act as a map between the TokenClass names and their constructors.