All Questions
8 questions
1
vote
1
answer
85
views
interact with a third party ANTLR-based recognizer
I am trying to interact, mostly, writing an interpreter, for a language, I have only an API through a dll that permits me to compile files or strings, check syntax errors, etc. What I would like is ...
0
votes
1
answer
359
views
How to generate a list from a * rule in ANTLR3?
I have the following grammar:
grammar Test;
options {
lang = Python;
}
declaration returns [value]
: 'enum' ID { statement* }
{ $value = {'id': $ID.text,
...
1
vote
1
answer
1k
views
ANTLR 3.5.1 (latest 3.x release) with Python runtime 3.1.3 (only available Python runtime)
It looks like 3.5.1 is the latest 3.x version, and 3.1.3 is the only available version (http://www.antlr.org/download/Python/). However, when I try to run the parser using the example, I get a ...
0
votes
1
answer
388
views
Building a parse tree in ANTLR with python target
I have a grammar for parsing SQL scripts. The lexer for the grammar works fine with the following code:
with open("/path/to/sql/script.sql") as f:
query = f.read().upper()
tokenStream = ...
4
votes
1
answer
621
views
How do I perform custom error reporting in ANTLR using python?
I'm writing a simple parser for my compilers class (just a proof of concept that I can get the tools working) and am using ANTLR with python bindings. I've gotten our trivial grammar to properly ...
1
vote
1
answer
2k
views
What's wrong with this example ANTLR 3 Python grammar?
I'm trying to learn to use ANTLR, and seem to have come across an error while following this "tutorial":
https://theantlrguy.atlassian.net/wiki/display/ANTLR3/Five+minute+introduction+to+ANTLR+3
...
2
votes
1
answer
221
views
Multiple alternatives with the same label, only the last gets anything assigned to it
I have some non-reserved keywords I'm matching with rules like:
kFOO = {self.input.LT(1).text.lower() == 'foo'}? ID;
Where the ID token is a standard alpha-numeric string. These kinds of rules work ...
2
votes
2
answers
2k
views
How to check the ranges of numbers in ANTLR 3?
I know this might end up being language specific, so a Java or Python solution would be acceptable.
Given the grammar:
MONTH : DIGIT DIGIT ;
DIGIT : ('0'..'9') ;
I want a check constraint on ...