> I know this will be something stupid and obvious and trivial
>
And (sigh) it was...
The problem was not in the grammar, nor in how ANTLR processed it, but
in the way I was using the re-written AST.
As Douglas Adams said: you live and learn; at any rate you live...
Michael
List: http://www.a
Hi folks,
I have a grammar to rewrite an AST, most of which works wonderfully
well. But one bit has had me pulling what remains of my hair out...
The relevant excerpts are:
expr : ^(FUNC_CALL id=ID expr_list)
-> {isPosFunc($id.text)}?
IMAGE_POS_LOOKUP[getProxyVar($id.t
Many thanks Jim ! Using ANTLR in my maven projects has been a breeze
thanks to your efforts.
Michael
2009/11/6 Jim Idle :
> I note that the new Maven Archetype for building a starting project for
> Maven and the Java target is now synced in the Maven central repository and
> shows up in the IDE
Hi Mark,
Just out of interest, are working with the units supported by Java
JSR-275 which I think are based on UCUM http://unitsofmeasure.org/ ?
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-addre
Hi Ivan,
Details and advanced draft are here:
http://www.pragprog.com/titles/tpdsl/language-implementation-patterns
Michael
2009/9/23 Ivan Yu Titov :
> Hello,
>
> I've recently heard about new ANTLR book. Is there any release date for it?
> Thanks in advance.
>
> With best wishes,
> Ivan
>
> Li
Hi Bruce,
Just like this...
ANTLRNoCaseFileStream strm = new ANTLRNoCaseFileStream( myfilename );
MyLexer lexer = new MyLexer( strm );
That's all there is to it really. If only all things in life were so easy :)
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
Thanks Tommy, this is a very good idea.
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~-~--~~~---~--~~
You received this message because you are subscri
Here's a fragment of the pom.xml that I use...
org.antlr
antlr3-maven-plugin
3.1.3-1
antlr
Hi,
There are some fairly simple examples of tree rewriting in my Jiffle
language grammars:
http://code.google.com/p/jai-tools/source/browse/#svn/trunk/jiffle/src/main/antlr3/jaitools/jiffle/parser
Jiffle.g is the initial lexer / parser grammar.
The various MorphX.g files plus VarClassifier.g a
Hello Hugo,
Try this:
BufferedTreeNodeStream nodes = new BufferedTreeNodeStream(myTree);
LangWalker evaluator = new LangWalker(nodes);
for(int i = 0; i < 1; i++)
evaluator.rule();
evaluator.reset();
end
Hope this helps,
Michael
List: http://www.antlr.org/mailman/listinfo
2009/6/6 Sam Barnett-Cormack :
> Not as annoying as having complete working code that's an example of
> something that's insufficiently explained... a lot of books go with the
> approach of a full description, illustrative (but brief!) snippets, and
> full code downloadable. I like this approach.
I got the pragprog email late last night (local time) and had the beta
book about a minute later :-)
I've been looking forward to this for months !
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-add
Hi Juanjo
The short answer is yes :)
But is your use case really one of complete translation or more
searching for particular elements in the input data ? And, if so,
would it be less work to build a few language-specific search routines
(which ANTLR can help you do of course) rather than build
Very nice - thanks for the link Steve
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~-~--~~~---~--~~
You received this message because you are subscribe
many thanks for all that Jim !
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~-~--~~~---~--~~
You received this message because you are subscribed to th
> I wonder what the logic is there. One of the big benefits of a tree walker
> is to be able to repeatedly walk the nodes. I hope they don't remove that
> capability from the BufferedTreeNodeStream. Did that one work for you?
> Except for increased memory is there ever a reason not to use
> Buf
Hi Steve,
> I would think CommonTreeNodeStream should work however, so it
> seems like a bug.
but as I tried to explain, the new behaviour of CommonTreeNodeStream
is that its contents are discarded as they are accessed by the tree
walker, so you can reset the stream but there's nothing there any
Hi Steve,
I posted the message you're quoting. Just to clarify - I call the
reset method too. My problem was that prior to 3.1.3 reset worked
with CommonTreeNodeStream but with 3.1.3 the stream is empty after the
tree walker has used it once so reset is useless.
I think this should have been h
Hi Behdad,
I'm sorry - I didn't read your question properly. Here is an example
that might be more relevant...
grammar Test;
x returns [List values]
@init {
$values = new ArrayList();
}
: e=y {$values.add($e.value)} (',' e=y {$values.add($e.value)} )*
;
y returns [int va
Hi Behdad
You can do this...
x: foo+=y (',' foo+=y)* ;
The += notation tells ANTLR to create a List which, in the example
above, would be called list_foo.
ANTLR doesn't do generics though, so list_foo will be a List
and you will need to cast the elements to the appropriate type.
Hope this he
Hi Indhu,
Thanks very much for posting this example - it explains something that
I want to do too.
Michael
2009/4/3 Indhu Bharathi :
> As expected, there were some bugs :-) Here is a implementation that works
> fine:
>
> grammar Test;
>
> @members{
>
> private boolean newLineBef
2009/4/4 Jim Idle wrote:
> Please read the plugin docs.
Jim - is it possible to get the plugin docs linked from
http://www.antlr.org/wiki/display/ANTLR3/ANTLR+3+Wiki+Home ?
At the moment the only thing you see there is a link to the old page.
I put a note at the top of that page yesterday linkin
OK, a with a bit more delving I found the problem was caused by the
CommonTreeNodeStream stream being emptied after the first run of the
tree walker, so calling reset didn't achieve much. This differs from
ANTLR 3.1.1 behaviour but doesn't seem to be in the release notes for
3.1.2 or 3.1.3 (someo
Sorry, that should have been
"migrating an app from ANTLR 3.1.1 to 3.1.3"
I've now also looked in the release notes for 3.1.2 but don't see my
answer there either (or perhaps I just don't understand it :). So,
still hoping for advice.
cheers
Michael
2009/4/1
Dear ANTLRites,
I'm migrating an app from ANTLR 3.1.2 to 3.1.3, using the java target.
It seems that I can no longer use the reset method on a tree parser -
is that intentional ?
In 3.1.2, calling reset on the tree parser would rewind its node
stream, whereas in 3.1.3 this does not seem to happ
2009/4/1 Jim Idle wrote:
> I'll check the examples, but:
>
The Libraries example has goals within configuration. The Netbeans
editor, following the pom schema I guess, doesn't suggest goals as an
element when you are within a configuration block, only outside.
Michael
List: http://www.antlr.or
cheers Jim - I missed that
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Go
2009/4/1 Jim Idle wrote:
> Don't use the -SNAPSHOT versions, it should be just 3.1.3. You can only use
> the snapshot versions if you define the ANTLR snapshot repository in your
> pom, and you don't need to do that unless you absolutely require some fix
> from the latest snapshot, which is 3.1.4
That's terrific, thanks Jim.
I notice that in the different examples is sometimes inside
and sometimes outside. Is this right ? I ask because
when I'm editing the pom.xml file in Netbeans, the editor doesn't
suggest the goals element when inside configuration.
cheers
Michael
2009/4/1 Jim Id
Thanks for posting this Sam ! I want to do some editor-related ANTLR
work soon so it's nice to have your example.
cheers
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~-~--~--
Hello Des,
It's no problem to do this in a tree grammar. For instance, here is
an example from one of my tree grammars
expr: ^(ASSIGN assign_op var expr)
-> {isImageVar($var.text)}? ^(IMAGE_WRITE var expr)
-> ^(ASSIGN assign_op var expr)
Here I r
Hi,
First decide if you really need step 3 (the tree parser). If you want
to parse some program / script and then perform evaluation multiple
times, or you want to work on the AST to optimize execution or make it
easier to do translation etc. then the answer is yes. But if you just
want to pars
> How could I store value in AS.g and how can AS.g and AStree.g communicate?
> Could you plz give me a small example?
>
Hi Annie
Just define variables in the members section of each grammar.
Here's a general example where parser grammar A.g needs to collect
data which will then be used in tree
Hi Annie,
Sorry for the confusion on my part. I haven't used StringTemplate yet
and so went off in the wrong direction...
But luckily, I see that Johannes has proposed a solution for you on
the other thread about your question.
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interes
So back to your rule...
callExpression
: ^(CALL_EXPRESSION memberExpression indexSuffix*
propertyReferenceSuffix* argumentSuffix*)
-> {$memberExpression.text.equals("Math.abs")}?
mathabs(x={$argumentSuffix.text})
-> /* discard rule */
;
You want to rewrite the node if memberExpression is "Ma
> * ? - Match element one or more times.
>
> Does that what you mean?
I just hadn't seen an asterisk in front of a rule or token name before...
*propertyReferenceSuffix* argumentSuffix*)
^
This one.
It's probably just an email text thing - sorry to go off an a tangent :-)
Michael
List: h
Hi Annie,
One way to pass data between sub-trees is to use global scope. See
section 4.5 in the ANTLR book.
Hope this helps
Michael
2009/3/17 YINGAnnie :
>
> Hi everyone,
>
>
> What I want to do is to replace var t:Number=Math.ceil(1.5); to var
> t:int=int(1.5); The tree I got is something
Hi Annie,
> using-> before { } ?
Oops, you're quite right. The arrow should be before the predicate,
not after (although that page in the book is about writing output with
string templates. For rewriting ASTs you're better off looking at the
wiki pages, for example...
http://www.antlr.org/wi
Hi Anders,
This is how I distinguish between int and double in my lexer rules:
INT_LITERAL : '0' | NonZeroDigit Digit*
;
FLOAT_LITERAL : ('0' | NonZeroDigit Digit*)? Dot Digit* FloatExp?
;
fragment
Digit : '0'..'9'
;
fragment
Dot
Hi
You are re-writing an AST ? I ask because your question made it sound
like you are running actions but the grammar looks like re-writing.
I was under the impression that you MUST provide an explicit
alternative for when the predicate is not true.
So...
callExpression
: ^(CALL_EXPRESSION me
2009/3/14 Sam Barnett-Cormack :
> yourself. Of course, that would avoid the spurious includes that keep
> causing me warnings, but one almost expects them in generated code.
>
I've wondered about those includes. With the caveat that I've never
looked at the back-end code, I would have thought it
rustle, rustle...
that's the sound of me rubbing my hands together in anticipation :)
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~-~--~~~---~--~~
Yo
Hi Emmanuel,
I'm forwarding your post and this reply to the ANTLR list.
I was going to look into that issue myself but haven't got to it, so
it's really nice to hear from you :) But before you do too much
hacking have a look at this latest work if you haven't already...
http://antlr.org/hudson
Have a look at this page...
http://www.antlr.org/wiki/pages/viewpage.action?pageId=557063
Michael
2009/3/9 Sam Barnett-Cormack :
> The whole point of the hidden channel (rather than just discarding) is
> that the parser *can* tune to it, or use it for context checking in
> predicates, or use it
Hi Anders,
I have a fairly simpler grammar that has unary minus working ok.
Perhaps it might provide some hints...
http://code.google.com/p/jai-tools/source/browse/trunk/jiffle/src/main/antlr/jaitools/jiffle/parser/Jiffle.g
Look for the unary_expr rule. I doubt if how I do it is best practice
Hi Bob,
Have just written my first language, which is also quite C-ish, while
learning ANTLR at the same time my advice would be slightly different
to Jim's. Yes, it's really helpful to start from an example. No,
don't start with a giant C grammar because you're likely to get lost.
That was my
Hi folks,
Nice discussion - I'm finding it most interesting and helpful.
Andy: many thanks for your specific comments on Jiffle. That's just
the kind of feedback that I was hoping for.
Regarding "how to" info: I'm in the process of adding demo code and
updating the wiki pages to help people tr
also this wiki page...
http://www.antlr.org/wiki/display/ANTLR3/Using+ANTLR+3+with+Maven+2
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~-~--~~~---~--~
>
> Assume, there are two rules:
>
> 1) A : character_set_a;
>
> 2) B : character_set_b;
>
> How do I set up a rule for parsing a character which must be in the
>
> character_set_a but not in character_set_b?
>
Are the characters in the A and B sets mutually exclusive ? I'm
guessing they are n
2009/2/23 Vlastimil Adamovsky :
>
> I want to parse digits, that are from 0 to 9 except those that are from 4
> to 7.
> In reality, I want to parse only digits 0,1,2,3,8,9
>
A: '0'..'3' | '8' | '9' ;
Is this what you want ?
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-inter
> On Feb 21, 2009, at 6:00 PM, Jim Idle wrote:
>
>> Should make it to Maven central within about 4 hours. The main
>> development builds will now all be bumped to 3.1.3-SNAPSHOT...
>>
>> Also, maven antlr plugin becomes release 3.1.2 to reflect the fact
>> that that version will build using ANTLR
Hi folks,
This is a plug and a request for feedback on my first ANTLR project:
Jiffle - a simple language for creating raster images from maths
expressions.
You can find it at http://code.google.com/p/jai-tools/
Look for the Jiffle link at the bottom of that page. There is a
preliminary descri
> Shouldn't do - you are using the debug mode and not the interpreting mode?
>
yep
I must be doing something wrong but I can't spot it... (probably too
close to my nose :)
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antl
2009/2/20 Jim Idle wrote:
> COMMENT : '#'
> (
> ( 'ABCD')=> 'ABCD'
> | ~('\r' | '\n')* NEWLINE
> )
> { $channel = HIDDEN; }
> ;
>
> NEWLINE
Hi Joe,
How about this...
NONCOMMENT : '#ABCD' { $channel = HIDDEN; }
;
COMMENT : '#' ~('\r' | '\n')* NEWLINE { $channel = HIDDEN; }
;
NEWLINE : '\r' ('\n')?
| '\n'
;
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
that's terrific Jim - many thanks
Michael
2009/2/13 Jim Idle :
> As well as deploying the source and javadoc jars to the ANTLR snapshot
> repository (which means they will go to the maven central respository at the
> next point release), the ANTLR Hudson continuous build system is also aware
> o
super - thanks Jim
Michael
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Gro
Hi Jim
> Did you tell Netbeans to use the the Maven 2.0.9 installation, or di d
> you let it use its supplied one, which in Netbeans 6.1 is the
> development version M2 or M1 of 2.0.10 and has a few issues.
I've tried both, as well as running 2.0.9 from the command line just
in case it was an ID
At the start of the rule the generated parser code will have...
var e:Token=null;
var list_e:Array=null;
and then in the sumStat rule loop...
if (list_e==null) list_e=new Array();
list_e.push(e);
Hope this helps,
Michael
2009/2/12 Des Hartman :
> I have a simple function to sum values, where
Hi folks,
I'm using the org.antlr maven plugin. It does a great job - it just
seems to want to do it all the time :-) In other words, it _always_
wants to re-generate the sources, even when the existing files are
more recent that the grammar files.
I'm using maven from within Netbeans. I've f
> Yes - I like what I see so far. It needs some updates for actions and
> stuff like that (most of my grammar shows up red ;-), but I think that
> it will be really good as it develops.
Well your grammars would probably make excellent advanced test cases
for the developer Jim...
Michael
List: h
Just another plug for the netbeans plugin :-)
I've been using it with NB 6.1 and it's _so_ nice. The only real prob
that I've found with it so far is that it doesn't seem to like catch[
] clauses at the end of a rule - unless i'm doing something wrong...
Michael
List: http://www.antlr.org/mail
2009/2/9 Oliver Zeigermann:
>
> I set up a page where I share my experience with multiple tree
> transformer stages:
>
> http://www.antlr.org/wiki/display/ANTLR3/Complex+tree+transformations+using+cascading+tree+rewriters
>
> Maybe you would like to add yours?
>
Hi Oliver,
I'm loving the tree re
Andreas - many thanks for the tip about grammar imports. That sound
like a good way to do some of what I'm trying (and learning how) to
do. I didn't know about this since composite grammars are more recent
than the book (my primary learning resource so far).
Oliver - thanks for the useful page
Hi folks,
I'm working on a little DSL, called jiffle, to create raster images
from maths expressions. I build an initial AST from the input jiffle
script, and next use a couple of tree walkers to (1) check for
undefined vars and (2) categorize vars on whether thay depend on pixel
position or not
Hello all,
I search the list for this but only found a related bug report - no solution.
I have a rule and associated action (java) in my tree grammar...
expr: ^(MOD a=expr b=expr) {$value = a % b;}
This provokes get an invalid string template error. I imagine there
must be some simple option
Hello all,
I think I should probably apologize in advance for this question
because (a) it's probably really obvious and (b) I know it's been
asked before but as a newbie I've had trouble understanding the
previous posts or finding the solution in the book.
In my parser grammar:
expr_list
67 matches
Mail list logo