We have been using regex for our grammar requirement. However there are about 20+ patterns that needs to be supported and maintaining RegEx has become very difficult when the patterns started becoming recursive. We tried migrating to ANTLR, and looked at the following two critical points required for us.
Performance
Performance seems...
Dear ladies and sirs.
The title says it all.
Thanks.
...
I'm trying to use ILMerge to internalize some transitively referenced assemblies into an assembly I'm referencing to eliminate conflicts with those transitive dependencies elsehwere in my project.
In particular, I'm referencing Antlr3.StringTemplate (hereafter referred to as AS, available here: http://www.stringtemplate.org/download.htm...
I want to write a translator between two languages, and after some reading on the Internet I've decided to go with ANTLR. I had to learn it from scratch, but besides some trouble with eliminating left recursion everything went fine until now.
However, today some guy told me to check out Happy, a Haskell based parser generator. I have no...
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...
I am new to parser generators and I am wondering how the ANTLR grammar for an embedded language like JSP/ASP/PHP might look like, but unfortunately the ANTLR site doesn't provide any such grammar files.
More precisely I don't know exactly how to define an AnyText token which matches everything (including keywords which aren't having any...
Let's say I have two rules like the below:
printable_characters : '\u0020' .. '\uFFEF' ;
newline_characters : '\n' | '\r' ;
Now let's say that I want to make a new rule called printable_no_newlines. I would like to do this by subtracting newline_characters from printable_characters like so:
printable_no_newlines : printable_charact...
How is operator precedence implemented in ANTLR?
I'm using the XText/Antlr package at the moment.
Edit:
I did what sepp2k suggested, and operator precedence works now, but stuff like 3 +* also work now. The operators are basically "falling through" the tree.
Also, I tried the C grammar on ANTLR's website and the same thing happened...
VARIABLE: ...
UNARYOP: 'not' Expression; // unary operation
BINARYOP: 'or' VARIABLE;
Expression : (NIL | INTEGER | UNARYOP) BINARYOP?;
In the above scenario, 'or' can either be reached through
Expression->BINARYOP
or
EXPRESSION->UNARYOP->Expression->BINARYOP
Is there a systematic way to remove ambiguities such as the above?
...
I'm trying to implement a expression handling grammar (that deals with nested parenthesis and stuff). I have the following so far, but they can't deal with some cases (successful/failure cases appear after the following code block). Anyone know what's going on?
Note: The varname += and varname = stuff are just some additional AST genera...
I have maven configured to run gunit (an ANTLR grammar unit testing tool) through the maven-gunit-plugin. gunit, however, has two different modes. The first mode causes gunit to act as an interpreter, reading through the *.gunit (or *.testsuite) file, interpreting it, and displaying the results. It can be configured as such:
<plugi...
Hi I have this grammar for now,
but when I have after a service, a note. Antlr doesn't want to recognize that it's not the service, but note. And service and note have different structure.
How to write this?
I'm trying to parse this. but NOTE bla bla; is in service
777014322;O2 Optimum Profi Promo;
Free sms;0:00;250:00;0:00;
NOTE b...
I have couple of ANTLR rules that I don't know how to make them work
The first rule is:
STRING_LITERAL
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
;
The second rule is:
element
: name '=' math_formula ;
math_formula
: '"' expression '"';
The expression is a regular C like expression
Example for the sy...
We are using Antlr StringTemplates to give control over how a Entity's Name is output.
The basic Stringtemplate is
$FirstName$ $Initial$ $LastName$,
$Suffix$, $Degree$
I want to add some smarts to that template so that the commas are only output when necessary i.e. The first comma is only output when there is a Suffix or Deg...
The recommended pattern for ANTLR usage is to have the Parser construct an Abstract Syntax Tree, and then build Tree walkers (AKA tree grammars) to process them.
I'm trying to get to the bottom of why my tree grammar isn't working and would love to use ANTLRWorks' debugger the same way I used it for the parser itself. The input to the ...
I'm planning to write a C# 3.0 compiler in C#. Where can I get the grammar for parser generation?
Preferably one that works with ANTLR v3 without modification.
...
In ANTLR version 2.X you could specify something was to go before or after the ANTLR includes via the code below.
header "pre_include_hpp"
{
#pragma warning( push )
#pragma warning( disable : 4511 ) // couldn't generate copy constructor
}
header "post_include_hpp"
{
#pragma warning( pop )
}
With ANTLR v3.X it looks li...
numberrange returns [String value]
: numberrangesub
{
String numberRange = ($numberrangesub.text);
String [] v = numberRange.split(",");
if ( Integer.parseInt(v[0].trim()) < Integer.parseInt(v[1].trim())) $value =numberRange;
else throw new RecognitionException();
}
;
Please obs...
I'd like to add a keyword to my language.
This keyword would only have to be matched during one particular parser grammar rule.
Due to backward compatibility I'd like to allow this keyword to continue to be used as a variable name, ie it can be matched by the lexer rule that determines if a token is suitable for a variable name.
The ...
I have downloaded ANTLR 1.3 and ANTLRWorks and can generate rules and syntax diagrams OK. When I try to generate code (e.g. by GenerateCode in ANTLRWorks or with java org.antlr.Tool Temp.g I get
error(100): C:\temp\Temp.g 0:0: syntax error: codegen: <AST>: 0:0: unexpected end of subtree
I'm on Windows 7 beta, Java 1.6. I have not spe...