var tokenStartMarker = this._input.mark(); is not a function in Lexer.js nextToken

12 views
Skip to first unread message

Odin Haus

unread,
Jan 7, 2019, 1:34:06 PM1/7/19
to antlr-di...@googlegroups.com
Just built a grammar and am trying to validate some input but I keep getting this._input.mark() is not a function.

Not sure where to go with this, was hoping someone here might have some ideas.

Compiled the js files using antlr4 -Dlanguage=JavaScript from a single .g4 grammar file.

The grammar appears to be valid when I test after compiling to java using the gui TestRig.

My javascript code is as follows:

var antlr4 = require('antlr4/index');
var BQLXLexer = require('grammar/BQLXLexer').BQLXLexer;
var BQLXParser = require('grammar/BQLXParser').BQLXParser;

function validatePipeline(script) {
var chars = antlr4.InputStream(script);
var lexer = new BQLXLexer(chars);
var tokens = new antlr4.CommonTokenStream(lexer);
var parser = new BQLXParser(tokens);
parser.buildParseTrees = true;
var ast = parser.pipeline();
console.log(ast);
}

It's blowing up on the var ast = parser.pipeline(); call on line 111 of Lexer.js, which is inside the nextToken method.

I'm using version 4.7.2 of antlr, but both 4.7.2 and 4.7.1 javascript runtimes produce the same error on the same line.

Odin Haus

unread,
Jan 7, 2019, 2:30:07 PM1/7/19
to antlr-discussion
I just found the issue - I was missing a new statement on the var chars = antlr4.InputStream(script); line.
Reply all
Reply to author
Forward
0 new messages