How to use the antlr4/index.Lexer 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.

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

github cancerberoSgx / univac / univac / src / grammar / golang / GolangLexer.js View on Github external
GolangLexer.prototype.nextToken = function() {
      let next = antlr4.Lexer.prototype.nextToken.apply(this, arguments)//.call(this, parent, invokingState);
  //     this.parser = parser;
  //     this.ruleIndex = GolangParser.RULE_importSpec;
  //     return this;
  // }
        // Get the next token.
        // let next = super.nextToken();

        if (next.getChannel && next.getChannel() == antlr4.Token.DEFAULT_CHANNEL) {
            // Keep track of the last token on the default channel.
            this.lastToken = next;
        }

        return next;
    }
github cancerberoSgx / univac / univac / src / grammar / antlr4 / LexerAdaptor.js View on Github external
// Adapted from LexerAdaptor.py by Sebastián Gurin

// From ANTLRv4Lexer.js, use it like this:
// ```
// function ANTLRv4Lexer(input) {
//   antlr4.Lexer.call(this, input) 
//   this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
//   return this;
// }
// ANTLRv4Lexer.prototype = new LexerAdaptor()
// ANTLRv4Lexer.prototype.constructor = ANTLRv4Lexer;
// ```

var antlr4 = require('antlr4/index');

module.exports.LexerAdaptor = class LexerAdaptor extends antlr4.Lexer {

  getCurrentRuleType() {
    if (typeof this._currentRuleType === 'undefined') {
      this._currentRuleType = antlr4.Token.INVALID_TYPE;
    }
    return this._currentRuleType;
  }

  setCurrentRuleType(ruleType) {
    this._currentRuleType = ruleType;
  }

  handleBeginArgument() {
    if (this.inLexerRule()) {
      this.pushMode(require('./ANTLRv4Lexer').ANTLRv4Lexer.LexerCharSet);
      this.more();
github cancerberoSgx / univac / univac / src / grammar / abnf / AbnfLexer.js View on Github external
"\u0002\u00c8,\u0003\u0002\u0002\u0002\u001b\u0002?EKOUW]cgmou{\u007f",
    "\u0085\u0087\u008d\u0096\u0098\u009e\u00a4\u00a8\u00b6\u00bc\u0003\u0002",
    "\u0003\u0002"].join("");


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

var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });

function AbnfLexer(input) {
	antlr4.Lexer.call(this, input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
    return this;
}

AbnfLexer.prototype = Object.create(antlr4.Lexer.prototype);
AbnfLexer.prototype.constructor = AbnfLexer;

Object.defineProperty(AbnfLexer.prototype, "atn", {
        get : function() {
                return atn;
        }
});

AbnfLexer.EOF = antlr4.Token.EOF;
AbnfLexer.T__0 = 1;
AbnfLexer.T__1 = 2;
AbnfLexer.T__2 = 3;
AbnfLexer.T__3 = 4;
AbnfLexer.T__4 = 5;
AbnfLexer.T__5 = 6;
AbnfLexer.T__6 = 7;
github cancerberoSgx / univac / univac / src / grammar / golang / GolangLexer.js View on Github external
function GolangLexer(input) {
	antlr4.Lexer.call(this, input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
    return this;
}
github protofire / solhint / lib / grammar / SolidityLexer.js View on Github external
function SolidityLexer(input) {
	antlr4.Lexer.call(this, input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
    return this;
}
github quantastica / quantum-circuit / lib / qasm_import / QASMLexer.js View on Github external
"\u0002\u0002\u011c\u011a\u0003\u0002\u0002\u0002\u011d\u011e\b+\u0002",
    "\u0002\u011eV\u0003\u0002\u0002\u0002\u000e\u0002\u00dd\u00e5\u00e9",
    "\u00ee\u00f0\u00f3\u00f8\u00fd\u0104\u010c\u011a\u0003\b\u0002\u0002"].join("");


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

var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });

function QASMLexer(input) {
	antlr4.Lexer.call(this, input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
    return this;
}

QASMLexer.prototype = Object.create(antlr4.Lexer.prototype);
QASMLexer.prototype.constructor = QASMLexer;

Object.defineProperty(QASMLexer.prototype, "atn", {
        get : function() {
                return atn;
        }
});

QASMLexer.EOF = antlr4.Token.EOF;
QASMLexer.T__0 = 1;
QASMLexer.T__1 = 2;
QASMLexer.T__2 = 3;
QASMLexer.T__3 = 4;
QASMLexer.T__4 = 5;
QASMLexer.T__5 = 6;
QASMLexer.T__6 = 7;
github stencila / mini / parser / MiniLexer.js View on Github external
"\u00bf\u0003\u0002\u0002\u0002\u00bf\u00c0\b\"\u0002\u0002\u00c0D\u0003",
    "\u0002\u0002\u0002\u000e\u0002\u0089\u008f\u0095\u009a\u00a0\u00a6\u00a8",
    "\u00b0\u00b2\u00b6\u00bd\u0003\b\u0002\u0002"].join("");


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

var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });

function MiniLexer(input) {
	antlr4.Lexer.call(this, input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
    return this;
}

MiniLexer.prototype = Object.create(antlr4.Lexer.prototype);
MiniLexer.prototype.constructor = MiniLexer;

MiniLexer.EOF = antlr4.Token.EOF;
MiniLexer.T__0 = 1;
MiniLexer.T__1 = 2;
MiniLexer.T__2 = 3;
MiniLexer.T__3 = 4;
MiniLexer.T__4 = 5;
MiniLexer.T__5 = 6;
MiniLexer.T__6 = 7;
MiniLexer.T__7 = 8;
MiniLexer.T__8 = 9;
MiniLexer.T__9 = 10;
MiniLexer.T__10 = 11;
MiniLexer.T__11 = 12;
MiniLexer.T__12 = 13;
github mongodb-js / bson-transpilers / lib / antlr / ECMAScriptLexer.js View on Github external
function ECMAScriptLexer(input) {
	antlr4.Lexer.call(this, input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
    return this;
}
github cancerberoSgx / univac / univac / src / grammar / sexpression / sexpressionLexer.js View on Github external
"\u0002EG\t\u0005\u0002\u0002FE\u0003\u0002\u0002\u0002G\u0012\u0003",
    "\u0002\u0002\u0002HI\u00042;\u0002I\u0014\u0003\u0002\u0002\u0002\r",
    "\u0002\u0019\u001b#(-35:<F\u0003\b\u0002\u0002"].join("");


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

var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });

function sexpressionLexer(input) {
	antlr4.Lexer.call(this, input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
    return this;
}

sexpressionLexer.prototype = Object.create(antlr4.Lexer.prototype);
sexpressionLexer.prototype.constructor = sexpressionLexer;

Object.defineProperty(sexpressionLexer.prototype, "atn", {
        get : function() {
                return atn;
        }
});

sexpressionLexer.EOF = antlr4.Token.EOF;
sexpressionLexer.STRING = 1;
sexpressionLexer.WHITESPACE = 2;
sexpressionLexer.NUMBER = 3;
sexpressionLexer.SYMBOL = 4;
sexpressionLexer.LPAREN = 5;
sexpressionLexer.RPAREN = 6;
sexpressionLexer.DOT = 7;
github mongodb-js / bson-transpilers / lib / antlr / Python3Lexer.js View on Github external
"\u033b\u0343\u0349\u034e\u0351\u0355\u0358\u035c\n\u0003%\u0002\u0003",
    "2\u0003\u00033\u0004\u00039\u0005\u0003:\u0006\u0003F\u0007\u0003G\b",
    "\b\u0002\u0002"].join("");


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

var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });

function Python3Lexer(input) {
	antlr4.Lexer.call(this, input);
    this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
    return this;
}

Python3Lexer.prototype = Object.create(antlr4.Lexer.prototype);
Python3Lexer.prototype.constructor = Python3Lexer;

Object.defineProperty(Python3Lexer.prototype, "atn", {
        get : function() {
                return atn;
        }
});

Python3Lexer.EOF = antlr4.Token.EOF;
Python3Lexer.DEF = 1;
Python3Lexer.RETURN = 2;
Python3Lexer.RAISE = 3;
Python3Lexer.FROM = 4;
Python3Lexer.IMPORT = 5;
Python3Lexer.AS = 6;
Python3Lexer.GLOBAL = 7;