I'm working on an ANTLR grammar that looks like...
A : B+;
...and I'd like to be able to perform an action before and after each instance of B. For example, I'd like something like...
A : A {out("Before");} B {out("After");}
| {out("Before");} B {out("After");};
So that on the input stream A B B I would see the output...
Before...
Does ANTLR marks somehow return values, just like other parser-generators do, for instance with $$ token ? Or do I have to explicitly mark every rule with returns [object value] statement?
...
Is there a tool for converting an ANTLR grammar to a Bison grmmar?
...
I am looking objective-c file for antlr and java compiler compiler.
I have tried the objectivec grammar file from antlr site http://www.antlr.org/grammar/1212699960054/ObjectiveC2ansi.g
but it is look like it broken. it failed in any source file.
...
Hi, everybody,
Please help me this problem:
I do the example on the page: http://www.antlr.org/wiki/pages/viewpage.action?pageId=1760
in order use this example, i have built the grammar P on ANTLRWork 1.4 and generate code to have class PLexer and PParser.
But when i run this code on java Jcreator 4.5:
import org.antlr.runtime.*;
impor...
Problem: Can't get Unicode character to print correctly.
Here is my grammar:
options { k=1; filter=true;
// Allow any char but \uFFFF (16 bit -1)
charVocabulary='\u0000'..'\uFFFE';
}
ANYCHAR :'$'
| '_' { System.out.println("Found underscore: "+getText()); }
| 'a'..'z' { System.out.println("Found alpha: "+getText()); }
| '\u...
Hi, i like to define a very simple rule, which should represent identifiers. This works quite well for identifiers which are longer than one characters, but for identifiers with exactly one character I get a MismatchedTokenException(64!=45). This is the rule:
ID : ('a'..'z' | 'A'..'Z')+
;
What is wrong with that?
Thanks!
...
Hi I'm looking to make a pseudo Markdown kind of language and a parser to parse it into xhtml.
I've never written a compiler... I've taken brief looks at ANTLR and am wondering if ANTLR can handle parsing things with meaningful whitespace?
So say I have something like this:
some text
some other text
# bullet point
# nest...
I am trying to get the simple expression evaluator example on the ANTLR
website working within ActionScript, I have been able to get the java
version to work. But my ActionScript version is getting the following
error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at org.antlr.runtime:...
Hi!
I am currently servicing an old VBA (visual basic for applications) application. I've got a legacy tool which analyzes that application and prints out dead variables. As there are more than 2000 of them I do not want to do this by hand.
Therefore I had the idea to transform the separate codefiles which contain the dead variable acc...
Where can I find good documentation to use Antlr in C/C++?
I've the Definitive Antlr reference book, but it only explains things in Java.
Thanks
Ajay
...
I'm writing a language using Antlr and Expression trees.
I've defined a standard factory method for my Tree Parser to use when generating addition, and it works very nicely for the built in integral types, now I'm moving on to more general types.
At the moment it's incredibly naive, it simply does this (in-progress TDD code often looks...
Given a Maven project generated by :
mvn archetype:generate -B -DarchetypeGroupId=org.antlr \
-DarchetypeArtifactId=antlr3-maven-archetype \
-DarchetypeVersion=3.2 \
-DgroupId=com.yourcompany \
-DartifactId=yourproject \
-Dversion=yourversion \
-Dpackage=com.yourcompany.package.path
cf : http://www.antlr.org/wiki/display/...
I am using the .Net port of ANTLR StringTemplate, but have been struggling with doing case insensitive replacements in the template.
I know that StringTemplate doesn't support case-insensitivity out of the box (because of language variation difficulties), but was able to find the following that shows how to implement a CaseInsensitiveSt...
In my master's I've seen how to write parsers, compilers using ANTLR. But in the real world, often times we have a requirement of parsing and extracting relevant content from a heavy load of in-coming stream data. Each language has it's own regular expression engine which can be conveniently used to parse the data. Alternatively we can w...
Hi all,
I am trying to use semantic predicates in ANTLR for the following grammar rule
test[n]
:({n==0}? => ~('a'))
|({n==1}? => ~('b'))
|({n==2}? => ~('c'))
;
However, ANTLR does not let me define the grammar in such a way, requiring that at least one of the alternatives be default. The exact error displ...
I have the following code written in ANTLRWorks 1.4
grammar hmm;
s : (put_a_in_b)|(put_out_a)|(drop_kick)|(drop_a)|(put_on_a);
put_a_in_b : (PUT_SYN)(ID)(IN_SYN)(ID);
put_out_a : (PUT2_SYN)(OUT_SYN)(ID) | (E1)(ID);
drop_kick : ('drop')('kick')(ID);
drop_a : (DROP_SYN)(ID);
put_on_a : (E2)(ID);
PU...
Is the following even possible? I want to "reverse" the input given to antlr and make each token a child of the previous one.
So, for the input (Assume each token is separated by the '.' char) :
Stack.Overflow.Horse
I would like my grammar to produce the following AST:
Horse
|---Overflow
|---Stack
So far, I've managed ...
I've been using the ANTLR supplied ECMAScript grammar with the objective of identifying JavaScript global variables. An AST is produced and I'm now wondering what the based way of filtering out the global variable declarations is.
I'm interested in looking for all of the outermost "variableDeclaration" tokens in my AST; the actual how-t...
My requirements are that I provide a way for Business Analyst-types to specify XSLT-like transformations without the complexity of XSLT or XPath. Basically there are incoming XML documents and the client needs to be able to specify situations where elements/subtrees should be edited/removed/replaced/added. It will essentially be a rule...