I've got a rule like this:
declaration returns [RuntimeObject obj]:
DECLARE label value { $obj = new RuntimeObject($label.text, $value.text); };
Unfortunately, it throws an exception in the RuntimeObject constructor because $label.text is null. Examining the debug output and some other things reveals that the match against "label...
Hello,
For my GAE app I need to do some natural language processing to extract the subject and object from an input sentence.
Apparently NLTK can't be installed (easily) on GAE so I am looking for another solution.
I noticed GAE comes with Antlr3 but from browsing their documentation it solves a different kind of grammar problem.
Any...
The Definitive ANTLR Guide starts with a simple recognizer. Using grammar verbatim to target C-runtime fails because '%s' means something to ANTLR:
$ cat T.g
grammar T;
options {
language = C;
}
@parser::includes
{
#include <stdio.h>
}
/** Match things like "call foo;" */
r : 'call' ID ';' {printf("invoke %s\n", $ID.t...
I've been trying to learn ANTLR and get it working with C output code using this tutorial (also referenced in this question). I successfully got ANTLR to generate the lexer and parser as C source, but I cannot get them to compile using gcc on Mac OS X Snow Leopard (i686-apple-darwin10-gcc-4.2.1). Below is the result when I try to compile...
Hiya,
I have just started using antlr3 and am trying to serialize the AST output of a .g grammar.
Thanks,
Lezan
...
I am attempting to get a basic ECMAScript parser working, and found a complete ANTLR grammar for ECMAScript 3, which appears to compile ok and produces the appropriate Lexer/Parser/Walker Java files.
(Running inside ANTLR IDE plugin for Eclipse 3.5)
However, when actually trying to use it with some simple test code (following guide on A...
I see a few sample main() for C floating about, e.g. http://www.antlr.org/wiki/display/ANTLR3/Five+minute+introduction+to+ANTLR+3 and http://www.antlr.org/api/C/index.html
The dereference seems to be AST. I don't know what that is , and - please excuse me - don't want to if I can avoid it.
I woudl like to just define the lexer & gramm...
Hi, I was trying hard to make ANTLR 3.2 generate parser/lexer in C++. It was fruitless. Things went well with Java & C though.
I was using this tutorial to get started: http://www.ibm.com/developerworks/aix/library/au-c%5Fplusplus%5Fantlr/index.html
When I checked the *.stg files, I found that:
CPP has only
./tool/src/main/resources/...
I have a (badly specified) requirement that I recognize certain keywords, but there is also provision for 'any string' ...
For instance, in the input "let's have a " I have to handle == "beer", == "curry" and == anything else at all (in theory, the keywords beer & curry have priority over all other strings).
When I try to define th...
When sending an AT command it is normally terminated by \r\n, but, in fact, these are really two 'register variables' S3 and S4.
By default S3=='\r' and S4=='\n', but the user can change these at runtime with the command ATSx=
How can I handle this in my Antlr lexer/parser?
Each command has the form AT[parameters]S3S4, how can I hand...
Let's say that I want to match "beer", but don't care about case sensitivity.
Currently I am defining a token to be ('b'|'B' 'e'|'E' 'e'|'E' 'r'|'R') but I have a lot of such and don't really want to handle 'verilythisisaverylongtokenindeedomyyesitis'.
The antlr wiki seems to suggest that it can't be done (in antlr) ... http://www.an...
I am short on funds and can only afford one. I am a total novice.
Thanks in advance for any help.
...
I want to accept a decimal number between 0 and 255. This is the best I can come up with:
fragment my_token :
('0'..'9') | // 0 -> 9
('1'..'9' '0'..'9') | // 0 -> 99
('1' '0'..'9' '0'..'9') | // 100 -> 199
('2' '0'..'4' '0'..'9') | // 200 -> 249
('25' '0'..'5'); // 250 -...
I'm planning to make an implementation of Lua for the DLR, and i would like to use the listed Lua 5.1 grammar here. However i can't see a license that it was released under, so can someone please kindly point me in the direction of the license it uses?
...
I'm looking for a syntax reference to ANTLR3 and a quick search didn't find one, can someone tell me where one exists?
...
I'm trying to get the feel for antlr3, and i pasted the Expression evaluator into an ANTLRWorks window (latest version) and compiled it. It compiled successfully and started, but two problems:
Attempting to use a input of 1+2*4/3; resulted in the actual input for the parser being 1+2*43.
One of the errors it shows in it's graphical pa...
All of the examples which I see read in a file the lex & parse it.
I need to have a function which takes a string (char *, I'm generating C code) as parameter, and acts upon that.
How can I do that best? I thought of writing the string to a stream, then feeding that to the lexer, but it doesn't feel right. Is there any better way?
Th...
I'm new to ANTLR and i've come up with this lexer rule to parse out comments, will it work?
COMMENT_LINE : (COMMENT (. - LINE_ENDING)* LINE_ENDING){$channel=hidden};
(I couldn't find anything regarding syntax such as this in the docs)
...
so, I am parsing Hayes modem AT commands. Not read from a file, but passed as char * (I am using C).
1) what happens if I get something that I totally don't recognize? How do I handle that?
2) what if I have something like
my_token: "cmd param=" ("value_1" | "value_2");
and receive an invalid value for "param"?
I see some advice to ...
I am trying to make unit tests for multiple return values in Antlr. I have regular unit tests working using gunit. However, I am not too sure what to do with the junit Testgrammar.java file that is generated as per the instructions at http://www.antlr.org/wiki/display/ANTLR3/gUnit+-+Grammar+Unit+Testing
I've tried running:
java -cp "./...