You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everybody, currently I am using ANTLR4, more specifically the grammar from JavaScript, and I want to extend this grammar to recognize Cypress syntax. But, I don't know what ANTLR4 version you used to generate the file .js from the file JavaScriptLexer.g4 and JavaScriptParse.g4? When I execute the code that is attach below, with the command: antlr4 -Dlanguage=JavaScript MyGrammar.g4, I experience the following errors:
Class main.js
import * as antlr4 from 'antlr4';
import JavaScriptLexer from './antlr/JavaScriptLexer.js';
import JavaScriptParser from './antlr/JavaScriptParser.js';
import CustomErrorListene from './CustomErrorListener.js';
const sourceCode = `
function add(a, b) {
return a + b;
}
`;
export function parse (input)
{
const chars = new antlr4.InputStream(input);
const lexer = new JavaScriptLexer(chars);
lexer.removeErrorListeners();
const customErrorListener = new CustomErrorListene();
lexer.addErrorListener(customErrorListener);
const tokens = new antlr4.CommonTokenStream(lexer);
const parser = new JavaScriptParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(customErrorListener);
//parser.buildParseTrees = true;
// Initiate the parsing, and begin with the root rule.
const parserResult = parser.program();
//console.log("Resultado del análisis: ", parserResult);
const customErrors = customErrorListener.getErrors()
if (customErrors.length > 0 )
{
console.log("Hay errores: ", customErrors)
}
}
parse(sourceCode);
Errors:
TypeError: o.reportAttemptingFullContext is not a function
at file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:42297
at Array.map ()
at wt.reportAttemptingFullContext (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:42287)
at ie.reportAttemptingFullContext (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:82387)
at ie.execATN (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:68408)
at ie.adaptivePredict (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:67194)
at JavaScriptParser.singleExpression (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/src/antlr/JavaScriptParser.js:4313:34)
at JavaScriptParser.expressionSequence (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/src/antlr/JavaScriptParser.js:4006:15)
at JavaScriptParser.returnStatement (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/src/antlr/JavaScriptParser.js:2364:19)
at JavaScriptParser.statement (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/src/antlr/JavaScriptParser.js:847:19)
I am sorry if I commited something error, I am primiparous in it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everybody, currently I am using ANTLR4, more specifically the grammar from JavaScript, and I want to extend this grammar to recognize Cypress syntax. But, I don't know what ANTLR4 version you used to generate the file .js from the file JavaScriptLexer.g4 and JavaScriptParse.g4? When I execute the code that is attach below, with the command: antlr4 -Dlanguage=JavaScript MyGrammar.g4, I experience the following errors:
Class main.js
Errors:
TypeError: o.reportAttemptingFullContext is not a function
at file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:42297
at Array.map ()
at wt.reportAttemptingFullContext (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:42287)
at ie.reportAttemptingFullContext (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:82387)
at ie.execATN (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:68408)
at ie.adaptivePredict (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/node_modules/antlr4/dist/antlr4.node.mjs:1:67194)
at JavaScriptParser.singleExpression (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/src/antlr/JavaScriptParser.js:4313:34)
at JavaScriptParser.expressionSequence (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/src/antlr/JavaScriptParser.js:4006:15)
at JavaScriptParser.returnStatement (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/src/antlr/JavaScriptParser.js:2364:19)
at JavaScriptParser.statement (file:///home/camilo/Desktop/Proyecto_grado_Wilton/tesis/test_parser1/src/antlr/JavaScriptParser.js:847:19)
I am sorry if I commited something error, I am primiparous in it.
Beta Was this translation helpful? Give feedback.
All reactions