I'm trying to build a simple interpreted language for learning purposes. I've read countless theory and tutorials on ANTLR and JavaCC, but I can't figure out how to actually make it do something useful.
I learn best by "taking something apart and putting it back together again", so, are there any working examples of simple languages imp...
I'm writing a converter between some dialects of the same programming language. I've found a grammar on the net - it's complex and handles all the cases. Now I'm trying to write the appropriate actions.
Most of the input is just going to be rewritten to output. What I need to do is parse function calls, do my magic (rename function, reo...
I want to integrate ANTLR with my c# desktop application.
I could not find many articles that talk about integration of ANTLR wirh C#.
Can you recommend a book that explains it step by step through real world examples?
...
What's the difference between this grammar:
...
if_statement : 'if' condition 'then' statement 'else' statement 'end_if';
...
and this:
...
if_statement : IF condition THEN statement ELSE statement END_IF;
...
IF : 'if';
THEN: 'then';
ELSE: 'else';
END_IF: 'end_if';
....
?
If there is any difference, as this impacts on performa...
Can I construct a token
ENDPLUS: '+' (options (greedy = false;):.) * '+'
;
being considered by the lexer only if it is preceded by a token PREwithout including in ENDPLUS?
PRE: '<<'
;
Thanks.
...
Hello,
I have been using ANTLR to generate a parser + tree grammar for a mark up language with Java target which works fine. Now I am trying to get the target in JavaScript to use it in my web browser.
However, I have not been able to locate any good documentation on how to go about doing this. I am using eclipse with ANTLR IDE, and ...
Hi all,
I need to both parse incoming messages and generate outgoing messages in EDIFACT format (basically a structured delimited format).
I would like to have a Java model that will be generated by parsing a message. Then I would like to use the same model to create an instance and generate a message.
The first half is fine, I've us...
Hello,
I'm trying to translate a grammar from bison to ANTLR. The grammar itself is pretty simple in bison but I cannot find a simple way for doing this.
Grammar in bison:
expr = expr or expr | expr and expr | (expr)
Any hints/links/pointers are welcome.
Thanks,
Iulian
...
How do I build a token in lexer that can handle recursion inside as this string:
${*anythink*${*anything*}*anythink*}
?
thanks
...
What are and how to use the "island grammar" in antlr3?
...
I'm dusting off an old project of mine which calculates a number of simple metrics about large software projects. One of the metrics is the length of files/classes/methods. Currently my code "guesses" where class/method boundaries are based on a very crude algorithm (traverse the file, maintaining a "current depth" and adjusting it whe...
To have a general-purpose documentation system that can extract inline documentation of multiple languages, a parser for each language is needed. A parser generator (which actually doesn't have to be that complete or efficient) is thus needed.
http://antlr.org/ is a nice parser generator that already has a number of grammars for popular...
Hello,
I am quite new to ANTLR, so this is likely a simple question.
I have defined a simple grammar which is supposed to include arithmetic expressions with numbers and identifiers (strings that start with a letter and continue with one or more letters or numbers.)
The grammar looks as follows:
grammar while;
@lexer::header {
pack...
Is there a way to specify custom class name (meaning independent of the grammar name) for the ANTLRv3 generated Parser and Lexer classes?
So in the case of
grammar MDD;
//other stufff
Automatically it would crate MDDParser and MDDLexer, but i would like to have them for example as MDDBaseParser and MDDLexer.
...
I have a simple ANTLR grammar, which I have stripped down to its bare essentials to demonstrate this problem I'm having. I am using ANTLRworks 1.3.1.
grammar sample;
assignment : IDENT ':=' NUM ';' ;
IDENT : ('a'..'z')+ ;
NUM : ('0'..'9')+ ;
WS : (' '|'\n'|'\t'|'\r')+ {$channel=HIDDEN;} ;
Obviously, thi...
I have a project containing files generated from a .g file (antlr 2.7.x). The guy who wrote the whole thing has left me with it. Until now, I did not need to modify the grammar and all was fine. But now, I cannot continue without modifying the grammar (i.e. the .g-file).
I have the source code of the used antlr and the visual studio 200...
For expressions like 3+4 I would like to use the value 7 in an intermediate representation tree.
I cannot work out how to get the returns value into a rewrite rule.
expression returns [int v]:
etc.
How do I get expression.v into WR? At the moment I get (+ 3 4), I want (7)
|^( WRITE c=expression) -> ^(WRINT ^(INTC ^($c))
the next s...
There're several ways to generate data for tests (not only unit tests), for example, Object Mother, builders, etc. Another useful approach is to write test data as plain text:
product: Main; prices: 145, 255; Expire: 10-Apr-2011; qty: 2; includes: Sub
product: Sub; prices: 145, 255; Expire: 10-Apr-2011; qty: 2
and then parse it into...
By default, a parser generated using ANTLR-3 extends from org.antlr.runtime.Parser. How do I have it extend my custom class instead?
...
Hello,
I want to parser a simple matlab-like for-loop, using ANTLR.
The loop is like :
for i=1:8
y(i) = a(i) + i;
end
I want to parse the loop and parse 8 times the y(i) = a(i) + i statement, in order to do some actions on each statement.
My rule is as follows (actions are described in C#) :
forloop
@init
{
string ...