4,315 questions
Advice
0 votes
2 replies
54 views
antlr-ng and CMake
Was anyone able to use antlr-ng successfully with CMake to automate C++ target builds? Is it possible at all? There is no information regarding this topic on www.antlr-ng.org, despite the claims to ...
0 votes
2 answers
79 views
How to express a terminal rule that requires at least one other rule somewhere
Given the following grammar snippet: tag : ID #TagID | <what to enter here> #TokenTagID ; TOKENID : DOLLARDOLLAR ID DOLLARDOLLAR ; DOLLARDOLLAR :...
0 votes
0 answers
45 views
Lexer Challenge on New Markup Lang
I'm trying to create a new markup language for manuscripts that supports inline notes and other directives. For example, here would be a simple "chapter": // Origins section demonstrating ...
1 vote
1 answer
51 views
How to parse optional separator that can be part of formatted text?
I'm currently trying to parse a custom configuration format using ANTLR4. Here is what the input may look like (in reality it's a lot more technical, but I had to change it for SO bc I want to keep my ...
1 vote
1 answer
85 views
is it safe to use a mode-switch rule that matches nothing?
I’m working on a custom Javadoc lexer in ANTLR 4, and I’m trying to handle special mode switching when I reach the start of a line. I have a simplified example like this: mode START_OF_LINE; ...
1 vote
2 answers
67 views
Antlr PostgreSQLParser.java not getting identified in the PostgreSQLParserBase.java inspite of successfull compile
I'm new to antlr4 and I was trying to create the Postgres parser for which I was using the grammar files and. I followed the below steps. Please note all the files are used from master branch: https://...
1 vote
1 answer
78 views
Limiting the starting rule of an expression in ANTLR4
I'm trying to create a grammar which allows certain expressions only as part of an expression and not at the very beginning of an expression statement. In the grammar below those certain expressions ...
0 votes
1 answer
58 views
Is there a programatic way to determine which ANTLR lexer a given ANTLR parser uses?
Let's assume I have a given ANTLR parser assembly with many Parser and Lexer classes contained within. Is there a programmatic way to determine which of the lexer classes a given parser class ...
0 votes
0 answers
38 views
Gradle ow2.asm dependency conflict when using ANTLR4
I'm using ANTLR4 in my build.gradle, added as dependencies { ... antlr4 group: 'org.antlr', name: 'antlr4', version: '4.13.2' // other dependencies like config1 group: 'org.ow2.asm', ...
0 votes
0 answers
77 views
ANTLR4 unused rule affecting prediction
This ANTLR4 grammar program : elems* EOF ; elems : stmt EOL | WS | EOL ; stmt : expr | ifStmt | block ; tryStmt : TRY EOL* stmt elseProd ; ...
0 votes
1 answer
75 views
Can't correctly split the input string into tokens if they are merged into each other
when there is no separation between fractions, and the lexer merges it all into one token → unknown to the FRACTION token: 2|1+4|15|2-18|5 line 1:11 no viable alternative at input '2|1+4|15|2-18|5' 2|...
1 vote
1 answer
48 views
precedence in antl4 OR rules
Suppose I have a simple grammar which recognizes lower-case words. Among the words I have some reserved words that I need to address differently. grammar test; prog: Reserved | Identifier; Reserved: ...
2 votes
1 answer
73 views
ANTLR4 no viable alternative at input
I am still learning to work with ANTLR4 to reimplement a grammar for a language I am familiar with. I have been using lab.antlr.org to help with debugging. I have the following grammar defined: ...
0 votes
1 answer
111 views
How to extract raw contents (including comments) within braces in specific situations?
I am trying to write an ANTLR4 grammar for the .asl file format (LiveSplit Autosplitting Language). It is a script format with one custom block (state) and several action blocks (startup, init, etc.) ...
0 votes
0 answers
35 views
How to improve an antlr no viable alternative error message
I have an antlr grammer for cypher queries and ran into the following invalid case: MATCH (u:person) where (u.firstName = 'foo' RETURN u.id org.cytosm.common.Cypher2SqlException: Syntax error: line 1:...