914 questions
1 vote
1 answer
76 views
How to convert a lexer rule with a semantic predicate from ANTLR3 to ANTLR4?
I'm trying to convert the ActionSplitter.g grammar to ANTLR4 and came across a problem wrt. semantic predicates. The grammar has rules like this: QUALIFIED_ATTR : '$' x=ID '.' y=ID {input.LA(1)!=...
0 votes
0 answers
38 views
How to obtain parsing result in ANTLR 3 with C target language?
I have to use ANTLR 3 with C target and I have some problems to understand how to output different messages if the parsing is successfull or not. What I have to add to my main.c file to obtain this ...
0 votes
1 answer
141 views
Protobuf target for antlr4
I have some project with antlr3 grammar, I managed to migrate it to antlr4 (antlr4 accepts it and generates code). But this project also uses this grammar to generate protobuf to implement some typing ...
-2 votes
1 answer
232 views
ANTLR4 Visitor Method cannot find symbol Error in Java
I'm working with ANTLR4 in Java to create a custom language parser. I've generated my lexer and parser using a grammar file (CCAL.g4), and I'm implementing a visitor class (EvalVisitor) extending ...
0 votes
0 answers
75 views
How exactly does ANTLR3 match fragments?
I'm creating a parser for formulas. I encountered unexpected behavior of IDENT (see code below). Theoretically, it should match 1 or more occurrences of Upper/Lower case letters + digits + '_'. But in ...
0 votes
1 answer
103 views
What are the steps to generate a C target in ANTLR3, brew does not support ANTLR3, and I cannot find a solution online
I am currently working on rewriting a parser project of mine from java to C. I'd love to stick with ANTLR as I find it easy to use, but unfortunately ANTLR4 no longer supports C targets. Luckily, ...
0 votes
0 answers
86 views
Compilation error on antlr3 files in Eclipse 2022-09
Eclipse version: 2022-09 Eclipse m2e version: 2.0.4 antlr version: 3 antlr3-maven-plugin: 3.5.3 I have a project with a Logic.g file. Everything was working OK on a previous version of Eclipse (where ...
0 votes
0 answers
54 views
antlr3: following token definitions can never be matched
For the below grammar: grammar Test; options { language = Java; output=AST; } reference : TASK | NAME ; TASK : (~'^')+ EOF ; NAME : ('A'..'Z')+ ; I get the following error: error(208): ...
1 vote
1 answer
135 views
Is it possible to use multiple Java versions within same build.xml - ANT build. - ANTLR3.3
I am working on a legacy project which needs to be upgraded to use Java8. During the upgrade we are facing issues with ANTL3.3 as it not compatible with Java8. Now because of certain dependencies we ...
0 votes
1 answer
264 views
ANTLR arithmetic and comparison expressions grammer ANTLR
how to add relational operations to my code Thanks My code is grammar denem1; options { output=AST; } tokens { ROOT; } parse : stat+ EOF -> ^(ROOT stat+) ; ...
0 votes
1 answer
195 views
Post process antlr maven goal
I'm running antlr with maven. Antlr generates .java file from .g file and I need to post process generated java file (do some changes in it). How can I do it? <plugin> <groupId>...
3 votes
1 answer
2k views
Is there a way to extract tokens in order with ANTLR?
Hi I'm currently trying to extract all tokens from ANTLR in C#, i'm using Antlr4.CodeGenerator and Antlr4.Runtime packages. I want them structured in a way i can manipulate them, change their content ...
3 votes
1 answer
95 views
Listener vs visitor in this exercise
We have this exercise that we have to do in class and the professor asked us to figure out good reasons to choose the listener method over visitor method in order to implement a solution for a ...
0 votes
1 answer
281 views
Antlr4 parser ignoring lexer rules and generating implicit tokens [duplicate]
As a simple example, let's say I have the following. parse_rule0 : parse_rule1 ',' parse_rule2 ';' ; pare_rule1 : ... ; parse_rule2: ... ; PUNCTUATION : ',' | '.'| ';' | ':' ; When Antlr4 (...
0 votes
0 answers
149 views
Xtext left recursion issue in an expression language
I've been recently working on a small demo expression grammar in Xtext: The Grammar grammar org.example.expressions.Expressions with org.eclipse.xtext.common.Terminals generate expressions "http:...