How to use the antlr4.PredictionContextCache function in antlr4

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

github hyperledger-labs / weaver-dlt-interoperability / common / policy-dsl / parser / PolicyLexer.js View on Github external
constructor(input) {
        super(input)
        this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
    }
github Azure / cosmos-sql-language-service / dist / language-service / LanguageService.js View on Github external
LanguageService.prototype._parse = function (input) {
        var _this = this;
        this.PrepareParse();
        this._lexer = new this._lexerCtr(new InputStream_1.InputStream(input));
        this._parser = new this._parserCtr(new LSCommonTokenStream_1.LSCommonTokenStream(this._lexer));
        this._parser.getTokenStream().EofListener = function () {
            _this.RecordStateBeforeEof();
        };
        this._parser.removeErrorListeners();
        this._parser.addErrorListener(new LSErrorListener_1.LSErrorListener(function (msg, line, column) {
            _this.AddSyntaxError(msg, line, column);
        }));
        var decisionsToDFA = this._parser.atn.decisionToState.map(function (ds, index) { return new antlr4.dfa.DFA(ds, index); });
        this._parser._interp = new LSParserATNSimulator_1.LSParserATNSimulator(this._parser, this._parser.atn, decisionsToDFA, new antlr4.PredictionContextCache(), this);
        this._parser.root();
    };
    LanguageService.prototype.PrepareParse = function () {
github hyperledger-labs / weaver-dlt-interoperability / common / policy-dsl / parser / PolicyParser.js View on Github external
"\u0002\u0002\u0015\u0017\u0005\u0004\u0003\u0006\u0016\u0010\u0003\u0002",
    "\u0002\u0002\u0016\u0013\u0003\u0002\u0002\u0002\u0017\u001a\u0003\u0002",
    "\u0002\u0002\u0018\u0016\u0003\u0002\u0002\u0002\u0018\u0019\u0003\u0002",
    "\u0002\u0002\u0019\u0005\u0003\u0002\u0002\u0002\u001a\u0018\u0003\u0002",
    "\u0002\u0002\u001b\u001c\u0007\u0004\u0002\u0002\u001c\u001d\t\u0002",
    "\u0002\u0002\u001d\"\u0007\u0005\u0002\u0002\u001e\u001f\u0007\u0005",
    "\u0002\u0002\u001f \t\u0002\u0002\u0002 \"\u0007\u0004\u0002\u0002!",
    "\u001b\u0003\u0002\u0002\u0002!\u001e\u0003\u0002\u0002\u0002\"\u0007",
    "\u0003\u0002\u0002\u0002\u0006\u000e\u0016\u0018!"].join("");


const atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);

const decisionsToDFA = atn.decisionToState.map( (ds, index) => new antlr4.dfa.DFA(ds, index) );

const sharedContextCache = new antlr4.PredictionContextCache();

export default class PolicyParser extends antlr4.Parser {

    static grammarFileName = "Policy.g4";
    static literalNames = [ null, null, "'count'", null, "'&&'", "'||'", 
                            "'>'", "'<'", "'=='", "'>='", "'<='" ];
    static symbolicNames = [ null, "WS", "COUNT", "INTLIT", "AND", "OR", 
                             "GREATER_THAN", "LESS_THAN", "EQUAL", "GREATER_THAN_EQUAL", 
                             "LESS_THAN_EQUAL", "ID" ];
    static ruleNames = [ "root", "expression", "count_expression" ];

    constructor(input) {
        super(input);
        this._interp = new antlr4.atn.ParserATNSimulator(this, atn, decisionsToDFA, sharedContextCache);
        this.ruleNames = PolicyParser.ruleNames;
        this.literalNames = PolicyParser.literalNames;