[il-antlr-interest: 26299] [antlr-interest] SEEMS NOBODY HERE LIKE TO HELP OTHERS

2009-10-16 Thread antlr_bill
I DONT HAVE ANY WORDS ANYMORE,
YEAH I REALLY WANNA GET SOME HELP FROM HERE 
BUT SEEMS IT'S IMPOSSIBLE
SURE ANTLR IS A GREAT PROJECT ,
BUT ...
ANYWAY ,SORRY THAT I DONT KNOW HOW TO UNSUBSCRIBE FROM THIS MAILIST


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26300] Re: [antlr-interest] Example code-generation target that outputs a state machine

2009-10-16 Thread David-Sarah Hopwood
Mike Samuel wrote:
> I'd like to derive a state machine that recognizes a combined lexical
> grammar of JS/HTML/CSS (hacked so that JS has a regular lexical
> grammar) and a mapping from states to the production they're part of.
> I need to keep the number of states small.
> 
> I saw something tantalizing about "dfaState() String Template" at
> http://www.antlr.org/wiki/display/ANTLR3/How+to+build+an+ANTLR+code+generation+target
> but am still unsure how to proceed.
> 
> Is this possible with ANTLR, and if so, does anyone know of existing
> code I could adapt?
> 
> For background, my end goal is to bolt string interpolation onto
> javascript, but in a way that doesn't introduce XSS problems as
> described at
> http://google-caja.googlecode.com/svn/changes/mikesamuel/string-interpolation-29-Jan-2008/trunk/src/js/com/google/caja/interp/index.html

Sounds like a fun project.

ANTLR normally only generates explicit DFAs when there is a nontrivial
decision between alternatives of a rule. In the case of the ECMAScript 5
lexical grammar I'm using, it only generates two DFAs, one for the main
tokens rule, and one for DecimalLiteral.

You can get ANTLRWorks to show a state machine diagram for any particular
decision, or for the tokens rule, but they're not particularly
enlightening. In principle, ANTLR computes all the information needed to
produce a pure FSM lexer, but I don't think it provides any way to actually
generate one, at least not without a lot of work. If that's definitely
what you need, ANTLR is probably not the right tool.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com


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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26301] Re: [antlr-interest] SEEMS NOBODY HERE LIKE TO HELP OTHERS

2009-10-16 Thread David Minor
I wouldn't shout about it, but I also have received scant (or no help) on
this forum. I'm not a parasite, I purchased the book, but... well... I'm
using Gold now and so far so good. I check back every now and then to see if
I got and answer. The unsubscribe link is at the bottom of this message.


2009/10/16 antlr_bill 

> I DONT HAVE ANY WORDS ANYMORE,
> YEAH I REALLY WANNA GET SOME HELP FROM HERE
> BUT SEEMS IT'S IMPOSSIBLE
> SURE ANTLR IS A GREAT PROJECT ,
> BUT ...
> ANYWAY ,SORRY THAT I DONT KNOW HOW TO UNSUBSCRIBE FROM THIS MAILIST
>
>
>
> 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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26302] Re: [antlr-interest] SEEMS NOBODY HERE LIKE TO HELP OTHERS

2009-10-16 Thread Graham Wideman

David:

> I also have received scant (or no help) on this forum

I see that you started two threads.  In one, Jim Idle gave you a thoughtful
response, and suggested some questions to pursue.  You did post some more, and
nobody answered so far as I can see. That could be because the subject line on
your post got wrapped after the first word, so that it appears as just "saving"
-- not a title that would attract much attention.

Your second thread was last week "stuck on tree parsing", in which you posted
two grammars as attachments of 300 and 500 lines each, and then asked:
"PearGrammerTree.g complains about an undefined rule, that is defined right
above it" ...  without mentioning what rule you are talking about.

So here you miss out on the possibility that someone could just glance at the
problem area, in the body of the email, and spot a problem. Instead, you're
obliging someone to have to fetch the attachments and run ANTLR or AW on them
(you don't mention which, what version etc) just to see where there might be a
problem, with no guarantee it's even the same problem you're seeing.

In short, doubtless inadvertantly, you happened to present your messages in a
manner most likely not to be quickly answerable by knowledgeable list members.

If you had simply mentioned which rule had the problem, and inserted the
relevant part of the file in your email (so that looking at the attachment was
optional) then it is possible that someone could just eyeball it and spot an
obvious problem. 

I should also say that one customary line of troubleshooting advice is to
whittle down the troublesome sample so that it's much smaller. Often that
causes the problem to become more conspicuous, and even if not makes for a much
better example to ask for help about.

For what it's worth, I did just run ANTLR on your files, and on
PearGramerTree.g it gave not just one error, but the following:

=
F:\Proj\ANTLR\Test\Minor>java -jar D:\Antlr20090923\antlr-3.2.jar
PearGrammerTree.g
error(100): PearGrammerTree.g:117:6: syntax error: antlr:
PearGrammerTree.g:117:6: unexpected token: roi_identifier
error(100): PearGrammerTree.g:123:1: syntax error: antlr:
PearGrammerTree.g:123:1: unexpected token: data_scope_expr
error(100): PearGrammerTree.g:124:6: syntax error: antlr:
PearGrammerTree.g:124:6: unexpected token: IDENTIFIER
error(100): PearGrammerTree.g:127:1: syntax error: antlr:
PearGrammerTree.g:127:1: unexpected token: parameter
error(100): PearGrammerTree.g:129:20: syntax error: antlr:
PearGrammerTree.g:129:20: expecting RPAREN, found '|'
error(100): PearGrammerTree.g:138:2: syntax error: antlr:
PearGrammerTree.g:138:2: expecting RPAREN, found ';'
error(100): PearGrammerTree.g:141:1: syntax error: antlr:
PearGrammerTree.g:141:1: unexpected token: param_list
error(100): PearGrammerTree.g:142:6: syntax error: antlr:
PearGrammerTree.g:142:6: unexpected token: parameter
error(100): PearGrammerTree.g:145:1: syntax error: antlr:
PearGrammerTree.g:145:1: unexpected token: input_param_list
error(100): PearGrammerTree.g:147:2: syntax error: antlr:
PearGrammerTree.g:147:2: expecting RPAREN, found ';'
error(100): PearGrammerTree.g:149:1: syntax error: antlr:
PearGrammerTree.g:149:1: unexpected token: output_param_list
error(100): PearGrammerTree.g:307:4: syntax error: antlr:
PearGrammerTree.g:307:4: unexpected token: binding_expr
error(100): PearGrammerTree.g:315:1: syntax error: antlr:
PearGrammerTree.g:315:1: unexpected token: expression
error(100): PearGrammerTree.g:317:2: syntax error: antlr:
PearGrammerTree.g:317:2: expecting RPAREN, found ';'
error(100): PearGrammerTree.g:319:1: syntax error: antlr:
PearGrammerTree.g:319:1: unexpected token: program
error(106): PearGrammerTree.g:109:17: reference to undefined rule: param_list
error(106): PearGrammerTree.g:150:17: reference to undefined rule: param_list
error(106): PearGrammerTree.g:155:6: reference to undefined rule:
output_param_list
error(106): PearGrammerTree.g:154:22: reference to undefined rule:
output_param_list
error(106): PearGrammerTree.g:177:14: reference to undefined rule:
data_scope_expr
error(106): PearGrammerTree.g:173:11: reference to undefined rule:
data_scope_expr
error(106): PearGrammerTree.g:154:5: reference to undefined rule:
input_param_list
error(106): PearGrammerTree.g:320:4: reference to undefined rule: expression
error(106): PearGrammerTree.g:285:11: reference to undefined rule:
data_scope_expr
error(106): PearGrammerTree.g:156:5: reference to undefined rule:
input_param_list
===

Many of these report undefined rules not because that particular rule has a
problem per se, but because some rule it depends on has a problem. It's
probably worth looking at the "unexpected token" errors with a view to
determining if the syntax you've used is legit.

-- Graham

At 10/16/2009 10:16 AM, David Minor wrote: 
>
> I wouldn't shout about it, but I also have received scant (or no help) on
> this forum. I'm not a parasi

[il-antlr-interest: 26303] Re: [antlr-interest] SEEMS NOBODY HERE LIKE TO HELP OTHERS

2009-10-16 Thread Joseph Areeda
I wouldn't want to get in the way of a good pity party but my experience 
has been the opposite.

I'm new to antlr, purchased the book, downloaded free software and got 
my project working in record time (for me).

I had help along the way and have watched others get helpful responses 
to their questions.

I wonder what are your expectations from a user mailing list?  It's 
really not customer support of a commercial product or free consulting 
services on your project.  It's a community of people with a common 
interest. 

May I suggest simple well formed questions that people can answer 
quickly from experience rather than ones that take a lot of work to 
understand. If the question is something like here's a 3 line grammar 
that doesn't work with this input, I've seen very good answers come 
quickly.  I've also seen questions like (OK this is hyperbole) I'm 
trying to translate Japanese into Sanskrit, attached is my grammar file 
it's only 80MB,  for some reason the past perfect tense is getting into 
an infinite loop, please help.

Joe

David Minor wrote:
> I wouldn't shout about it, but I also have received scant (or no help) 
> on this forum. I'm not a parasite, I purchased the book, but... 
> well... I'm using Gold now and so far so good. I check back every now 
> and then to see if I got and answer. The unsubscribe link is at the 
> bottom of this message.
>
>
> 2009/10/16 antlr_bill mailto:antlr_b...@yeah.net>>
>
> I DONT HAVE ANY WORDS ANYMORE,
> YEAH I REALLY WANNA GET SOME HELP FROM HERE
> BUT SEEMS IT'S IMPOSSIBLE
> SURE ANTLR IS A GREAT PROJECT ,
> BUT ...
> ANYWAY ,SORRY THAT I DONT KNOW HOW TO UNSUBSCRIBE FROM THIS MAILIST
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
> 
>
>
> 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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26304] [antlr-interest] [Antlr + ST] Huge output string - OutOfMemoryError

2009-10-16 Thread Hieu Phung
Hi all,

I am writing a program using Antlr and StringTemplate to translate an input
file to an XML file. Input is small but output is huge: 720KB input file
will generate about 100MB output file. When my input reached 7608KB, I got
OOM error

time taken in second: 18 - file size in KB: 4804
time taken in second: 20 - file size in KB: 5205
time taken in second: 20 - file size in KB: 5605
time taken in second: 21 - file size in KB: 6006
time taken in second: 23 - file size in KB: 6406
time taken in second: 25 - file size in KB: 6806
time taken in second: 31 - file size in KB: 7207

at size 7608KB:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2882)
at
java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
at
java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:572)
at java.lang.StringBuffer.append(StringBuffer.java:320)
at java.io.StringWriter.write(StringWriter.java:60)
at
org.antlr.stringtemplate.AutoIndentWriter.write(AutoIndentWriter.java:172)
at
org.antlr.stringtemplate.language.ASTExpr.writePOJO(ASTExpr.java:702)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:683)
at
org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:660)
at
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:149)
at
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:705)
at
org.antlr.stringtemplate.language.ASTExpr.writeTemplate(ASTExpr.java:750)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:680)
at
org.antlr.stringtemplate.language.ASTExpr.writeIterableValue(ASTExpr.java:792)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:682)
at
org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:660)
at
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:149)
at
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:705)
at
org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1670)
at
org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1661)
at FFMParser.file(FFMParser.java:127)
at CSVTest.main(CSVTest.java:33)

Is there any suggestion so that program can generate 1GB file?

1)   Having multiple templates, each template generates small string,
then write the small strings to file.
My input has format: ((Part1) (Part2)+ (Part3)). For each part2, there is an
xml element in the output. I can have 3 templates here. In Antlr action, I
will write each part to file when parsing is done for the part.

2)   Any template engine that could write to file directly, instead of
returning a string...? (This might not be proper to discussed here :D)

I hope problem is stated clearly. Please let me know if you need more
information. Any suggestion is much appreciated. Thank you.

Regards,

Helen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26305] [antlr-interest] How do I output an alert box or something in the console in ANTLRWorks, in grammar actions?

2009-10-16 Thread Naveen Chawla
System.out.println("a string") doesn't seem to output anything, and
Window.alert("a string") doesn't work.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26306] Re: [antlr-interest] How to do "not" in a syntactic predicate?

2009-10-16 Thread Naveen Chawla
So, does anybody have a way of doing "Take *a* IF not followed by *b* (both
syntactic constructs)" ?

i.e.
q: (a !b)=> a;//("!" or "not" doesn't exist in
ANTLR)

I have unsuccessfully tried the following:

q: (a b?)=> {mark = input.mark();} a {bFoundYet=false; i=input.index();} b?
{if(input.index()>i){bFoundYet=true;input.rewind(mark);} }
{bFoundYet==false}?=> ;   //"mark" and "bFound" are my own variables,
already declared

Obviously something is wrong here and there may be a much, much simpler way.
Or I'm nearly right.

2009/10/15 Naveen Chawla 

> Yes, if you put "sentence: q b;" above q then it accepts "asdqwe", even
> though the *a* in q is followed by *b*. And in fact, on my side, accepts *a*
> regardless of what it's followed by. So the predicate seems to have no
> effect, on my side.
>
> I haven't yet been able to reproduce the problem itself in simpler form,
> and I agree about trying to find other ways, although unable so far. A
> working workaround of "not followed by" would fix the whole problem though.
>
> Jim posted in 2007 a PEG-style "followed by" solution using "foo: a
> {input.mark();} b {input.rewind();}".. which "takes *a* and *b* and then
> rewinds as if it it has just taken *a* "  so I was wondering if there was a
> solution for "not followed by" using mark(), rewind() and maybe reset()
> which "takes *a* and *b* and then (something or another?)..." ?
>   2009/10/14 Indhu Bharathi 
>
>>  Here is the complete grammar:
>>
>>
>>
>> grammar Test;
>>
>>
>>
>> q :   a ((b)=>NOWAY | /*nothing*/);
>>
>>
>>
>> a  :   'asd';
>>
>> b :   'qwe';
>>
>>
>>
>> fragment NOWAY:  ;
>>
>>
>>
>>
>>
>> ‘q’ will accept “asd” but not “asdqwe”. Am I missing something?
>>
>>
>>
>>
>>
>> BTW, if you can post a simplified example of your exact problem, you might
>> get more elegant solutions. This is only a hack for the specific problem you
>> posted. Maybe your original problem can be solved in a more elegant way.
>> Cases that require hacks of this kind are very rare and arises only while
>> parsing some very obscure languages.
>>
>>
>>
>> Cheers, Indhu
>>
>>
>>
>>
>>
>> *From:* Naveen Chawla [mailto:naveen.c...@googlemail.com]
>> *Sent:* Wednesday, October 14, 2009 11:38 PM
>> *To:* Indhu Bharathi
>> *Cc:* Jim Idle; antlr-inter...@antlr.org
>>
>> *Subject:* Re: [antlr-interest] How to do "not" in a syntactic predicate?
>>
>>
>>
>> Yikes, that doesn't seem to work, it seems to give a normal positive
>> predicate for me. (Or something). But not "if a not followed by b" => a.
>>
>>
>>
>> ?
>>
>> 2009/10/14 Indhu Bharathi 
>>
>> The other say I replied from my ipod and was not able to test it with
>> ANTLR. I checked it now and the code doesn’t work for me too. However you
>> can try a variant:
>>
>>
>>
>> q :   a ((b)=>NOWAY | /*nothing*/)
>>
>> ;
>>
>>
>>
>> fragment NOWAY
>>
>> :   ;
>>
>>
>>
>> This is tested J But note that this is only a hack and use it only when
>> there is no other alternative.
>>
>>
>>
>> Going by your “one of my "smaller" rules is "consuming" something that
>> should belong to a "larger" rule” description, it looks like you can
>> solve that problem by turning off greedy. Grep for ‘greedy’ in the book or
>> wiki.
>>
>>
>>
>> Cheers, Indhu
>>
>>
>>
>>
>>
>> *From:* antlr-interest-boun...@antlr.org [mailto:
>> antlr-interest-boun...@antlr.org] *On Behalf Of *Naveen Chawla
>> *Sent:* Wednesday, October 14, 2009 3:50 PM
>> *To:* Jim Idle
>> *Cc:* antlr-inter...@antlr.org
>> *Subject:* Re: [antlr-interest] How to do "not" in a syntactic predicate?
>>
>>
>>
>> Jim, being new to predicates I realised soon after this that you were
>> talking about token lookaheads. And yes I do need a syntactic lookahead (but
>> thas is negative). In beginner-speak, one of my "smaller" rules is
>> "consuming" something that should belong to a "larger" rule. This would be
>> correct if that particular something (e.g. "a") was *not* followed by a
>> syntactic construct conforming to "b". Hence (a !b)=>a (for the smaller
>> rule) seems the simplest solution to this to me. Is Indhu's version correct
>> for doing this trick? It doesn't seem to work for me (but I might be doing
>> something else wrong). If not correct, what is the correct way? My target is
>> Java.
>>
>> 2009/10/5 Jim Idle 
>>
>> Use a semantic predicate rather than syntactic. You possibly need a bated
>> predicate here too:
>>
>>
>>
>> { input.LA(1) == A && input.LA(2) != B}?=>
>>
>>
>>
>> However, if you need that kind of syntactic predicate, then I suggest you
>> may be approaching your problem incorrectly.
>>
>>
>>
>> Jim
>>
>>
>>
>> *From:* antlr-interest-boun...@antlr.org [mailto:
>> antlr-interest-boun...@antlr.org] *On Behalf Of *Naveen Chawla
>> *Sent:* Monday, October 05, 2009 7:02 AM
>>
>>
>> *To:* antlr-inter...@antlr.org
>> *Subject:* [antlr-interest] How to do "n

[il-antlr-interest: 26307] Re: [antlr-interest] How do I output an alert box or something in the console in ANTLRWorks , in grammar actions?

2009-10-16 Thread Indhu Bharathi
Sustem.out.println will print in the output tab.

 

From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Naveen Chawla
Sent: Friday, October 16, 2009 4:21 PM
To: antlr-inter...@antlr.org
Subject: [antlr-interest] How do I output an alert box or something in the
console in ANTLRWorks, in grammar actions?

 

System.out.println("a string") doesn't seem to output anything, and
Window.alert("a string") doesn't work. 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26308] Re: [antlr-interest] Example code-generation target that outputs a state machine

2009-10-16 Thread Todd Stout
Take a look at Ragel http://www.complang.org/ragel/, perhaps it can help
you.

On Fri, Oct 16, 2009 at 2:50 AM, David-Sarah Hopwood <
david-sa...@jacaranda.org> wrote:

> Mike Samuel wrote:
> > I'd like to derive a state machine that recognizes a combined lexical
> > grammar of JS/HTML/CSS (hacked so that JS has a regular lexical
> > grammar) and a mapping from states to the production they're part of.
> > I need to keep the number of states small.
> >
> > I saw something tantalizing about "dfaState() String Template" at
> >
> http://www.antlr.org/wiki/display/ANTLR3/How+to+build+an+ANTLR+code+generation+target
> > but am still unsure how to proceed.
> >
> > Is this possible with ANTLR, and if so, does anyone know of existing
> > code I could adapt?
> >
> > For background, my end goal is to bolt string interpolation onto
> > javascript, but in a way that doesn't introduce XSS problems as
> > described at
> >
> http://google-caja.googlecode.com/svn/changes/mikesamuel/string-interpolation-29-Jan-2008/trunk/src/js/com/google/caja/interp/index.html
>
> Sounds like a fun project.
>
> ANTLR normally only generates explicit DFAs when there is a nontrivial
> decision between alternatives of a rule. In the case of the ECMAScript 5
> lexical grammar I'm using, it only generates two DFAs, one for the main
> tokens rule, and one for DecimalLiteral.
>
> You can get ANTLRWorks to show a state machine diagram for any particular
> decision, or for the tokens rule, but they're not particularly
> enlightening. In principle, ANTLR computes all the information needed to
> produce a pure FSM lexer, but I don't think it provides any way to actually
> generate one, at least not without a lot of work. If that's definitely
> what you need, ANTLR is probably not the right tool.
>
> --
> David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com
>
>
> 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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26310] Re: [antlr-interest] How do I output an alert box or something in the console in ANTLRWorks, in grammar actions?

2009-10-16 Thread Naveen Chawla
Thanks Indhu! This might help me a lot now.

2009/10/16 Indhu Bharathi 

>  Sustem.out.println will print in the output tab.
>
>
>
> *From:* antlr-interest-boun...@antlr.org [mailto:
> antlr-interest-boun...@antlr.org] *On Behalf Of *Naveen Chawla
> *Sent:* Friday, October 16, 2009 4:21 PM
> *To:* antlr-inter...@antlr.org
> *Subject:* [antlr-interest] How do I output an alert box or something in
> the console in ANTLRWorks, in grammar actions?
>
>
>
> System.out.println("a string") doesn't seem to output anything, and
> Window.alert("a string") doesn't work.
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26311] [antlr-interest] Which version do I need for a CSharp target and VS 2008

2009-10-16 Thread Robert van der Hulst

I am using Antlr 2.7.6 (CPP target) at this moment for our Language project.

I  need  to  do make some serious changes, so I am considering to move
the project to Antlr 3 and a CSharp

Which version do people recommend that I should use.

I looked at the Antlr website and found two options:

- CSharp
- CSharp3

but  I  am  not  sure  if they are both available for the latest Antlr build.

Which one do you recommend ?

I   would   also  like  to have a binary that does not need Java (like
there is for Antlr 2). Does that exist ?

Finally:  Who has experience using Antlr in a VS 2008 environment (and
setting up the necessary MsBuild steps to automate the build process)?

-- 
Robert van der Hulst


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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26312] [antlr-interest] Semantic predicates

2009-10-16 Thread Robert Wentworth

There appears to be something fundamental that I am not "getting"  
about the way semantic predicates work. In the grammar below, the  
input "cat" is recognized using the rule "cat" but in not recognized  
by either the rule "expr" or the rule "pexpr". Could someone explain  
to me why this is so and what the fix is?

Thanks,
Bob Wentworth

//==


grammar ATest;

options {
backtrack = true;
memoize = true;
output = template;
}

@parser::header { package dummy; }
@lexer::header { package dummy; }


WS  :   ( ' '
 | '\t'
 | '\r'
 | '\n'
 ) {$channel=HIDDEN;}
 ;

WHEN:   'when' ;

WORD: ('a'..'z')+ ;

expr:   cat
| cat WHEN dog
| dog
;

pexpr   :   {input.LT(1).getText().equals("cat")}?=> cat
| {input.LT(1).getText().equals("cat")}?=> cat WHEN dog
| {input.LT(1).getText().equals("dog")}?=> dog
;

cat : {input.LT(1).getText().equals("cat")}?=> WORD ;

dog : {input.LT(1).getText().equals("dog")}?=> WORD ;


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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26314] [antlr-interest] Bug or misunderstanding?: missing attribute access on rule scope

2009-10-16 Thread Kaleb Pederson

I'm getting an error that doesn't make any sense, either because I've
missed something fundamental or I've stumbled across a bug. I'm doing
some type checking within a tree parser.  I have a plusMinusExpression
which can either be a negation or a subtraction expression.  In order
to to check to see which it is, I have `if ($rhs != null)` within my
action.  That line, however, causes the following error:

SemanticChecker.g:163:3: missing attribute access on rule scope: rhs

The grammar fragment follows:

plusMinusExpression returns [Type type]
:   ^(PLUS lhs=baseExpression rhs=baseExpression) { /*...*/ }
|   ^(MINUS lhs=baseExpression rhs=baseExpression?)
{
typeChecker.assertIsNumericType($lhs.type);
if ($rhs != null)
{
typeChecker.assertIsNumericType($rhs.type);
typeChecker.assertEqualTypes($lhs.type, 
$rhs.type);
}
$type = $lhs.type;
}
;
Am I missing something fundamental or should this work? I tried
changing rhs to something unique throughout the application, but the
error persists.  I see the exact same behavior on both ANTLR-3.1 and
3.2.

Thanks.

--
Kaleb Pederson
Twitter - http://twitter.com/kalebpederson
Blog - http://kalebpederson.com

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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26315] Re: [antlr-interest] Semantic predicates

2009-10-16 Thread Kaleb Pederson
On Fri, Oct 16, 2009 at 10:39 AM, Robert Wentworth  wrote:
> There appears to be something fundamental that I am not "getting"
> about the way semantic predicates work. In the grammar below, the
> input "cat" is recognized using the rule "cat" but in not recognized
> by either the rule "expr" or the rule "pexpr". Could someone explain
> to me why this is so and what the fix is?

[... snip ...]
> cat : {input.LT(1).getText().equals("cat")}?=> WORD ;
>
> dog : {input.LT(1).getText().equals("dog")}?=> WORD ;

You're using a gated semantic predicate.  A gated semantic predicate
is used to distinguish between multiple alternatives, but as you have
only one alternative, this isn't what you want. See
https://wincent.com/wiki/ANTLR_predicates for more information on
predicates.

> expr    :       cat
>                | cat WHEN dog
>                | dog

You could do:

expr: cat (WHEN dog)? | dog;

You should also be able to use a syntactic predicate:

expr: (cat WHEN)=> cat WHEN dog
| cat
| dog;

HTH,

--
Kaleb Pederson
Twitter - http://twitter.com/kalebpederson
Blog - http://kalebpederson.com

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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26316] Re: [antlr-interest] How to do "not" in a syntactic predicate?

2009-10-16 Thread Kaleb Pederson
On Fri, Oct 16, 2009 at 4:39 AM, Naveen Chawla
 wrote:
> So, does anybody have a way of doing "Take *a* IF not followed by *b* (both
> syntactic constructs)" ?
>
> i.e.
> q: (a !b)=> a;    //("!" or "not" doesn't exist in
> ANTLR)

I think that would be a nice syntax for ANTLR to support.

I would guess that you could generally accomplish the same thing by
placing the "opposite" syntactic predicate on your other
alternative(s) in your production.  In other words:

(a b)=> alternative_1
| alternative_2 ...

Rather than:

(a !b)=> alternative_2
| alternative_1

--
Kaleb Pederson
Twitter - http://twitter.com/kalebpederson
Blog - http://kalebpederson.com

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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26317] Re: [antlr-interest] SEEMS NOBODY HERE LIKE TO HELP OTHERS

2009-10-16 Thread Bill Andersen

To those complaining about the ANTLR list...

I've heard this complaint before and have even felt the same way from  
time to time.  But I'm still here.

No matter what anyone says and even if you have the book, if you don't  
live and breathe language design, starting out with ANTLR isn't really  
that easy.  So you have to stumble around a bit and after a while,  
you'll get better with the lingo and better at asking tighter, more  
targeted questions that are worthy of the time of the busy folks on  
this list to answer.  They *will* help you, but only if you help them  
help you.

But if you ask a big, amorphous, poorly worded question (as I have on  
a number of occasions) don't expect a lot of help.  I'm certain that  
it's not personal.

Just hang in there, take your lumps and, after a while you'll learn  
and find you'll get a lot more help.  In the end it's way worth it.   
ANTLR is great stuff.

.bill

Bill Andersen
Ontology Works, Inc. (www.ontologyworks.com)
3600 O'Donnell Street, Suite 600
Baltimore, MD 21224
Office: +1.410.675.1201
Cell: +1.443.858.6444
Fax: +1.410.675.1204





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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26318] Re: [antlr-interest] Semantic predicates

2009-10-16 Thread Robert Wentworth

Kaleb,

Thanks for your response. Although I've read the web page you  
referenced and the ANTLR book chapter on semantic predicates, I remain  
with just as many questions as I started out with.

Note that the point of my example is to understand how semantic  
predicates can be used in this sort of context. I am not interested in  
a solution to the toy problem that doesn't use semantic predicates.  
There are obviously simpler ways of solving the toy problem, but the  
example is meant as a vehicle for understanding how to use semantic  
predicates to solve more complicated problems.

On Oct 16, 2009, at 3:35 PM, Kaleb Pederson wrote:

> On Fri, Oct 16, 2009 at 10:39 AM, Robert Wentworth  
>  wrote:
>> There appears to be something fundamental that I am not "getting"
>> about the way semantic predicates work. In the grammar below, the
>> input "cat" is recognized using the rule "cat" but in not recognized
>> by either the rule "expr" or the rule "pexpr". Could someone explain
>> to me why this is so and what the fix is?
>
> [... snip ...]
>> cat : {input.LT(1).getText().equals("cat")}?=> WORD ;
>>
>> dog : {input.LT(1).getText().equals("dog")}?=> WORD ;
>
> You're using a gated semantic predicate.  A gated semantic predicate
> is used to distinguish between multiple alternatives, but as you have
> only one alternative, this isn't what you want.

My understanding was that gated predicates are hoisted into rules that  
indirectly reference them, at which point they should influence the  
decision in "expr".

> See
> https://wincent.com/wiki/ANTLR_predicates for more information on
> predicates.
>
>> expr:   cat
>>| cat WHEN dog
>>| dog
>
> You could do:
>
> expr: cat (WHEN dog)? | dog;


In any event, this doesn't match "cat" either, retaining the old  
definition of the rule "cat" with the semantic predicate. (And taking  
out the semantic predicate would change the grammar.)

>
> You should also be able to use a syntactic predicate:
>
> expr: (cat WHEN)=> cat WHEN dog
>| cat
>| dog;

Isn't this done implicity, without the explicit syntactic predicate?

>
> HTH,
>
> --
> Kaleb Pederson
> Twitter - http://twitter.com/kalebpederson
> Blog - http://kalebpederson.com
>


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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26319] Re: [antlr-interest] Semantic predicates

2009-10-16 Thread Andreas Meyer

Robert Wentworth schrieb:
> There appears to be something fundamental that I am not "getting"  
> about the way semantic predicates work. In the grammar below, the  
> input "cat" is recognized using the rule "cat" but in not recognized  
> by either the rule "expr" or the rule "pexpr". Could someone explain  
> to me why this is so and what the fix is?
>   

I think the generated code is wrong. Looking at the decision-code for 
expr, it seems that the only input expr can accept is plain "dog":

try {
if ( state.backtracking>0 && alreadyParsedRule(input, 1) ) { 
return retval; }
// C:\\projects\\test\\ATest\\ATest.g:24:6: ( cat | cat WHEN 
dog | dog )
int alt1=3;
int LA1_0 = input.LA(1);

if ( (LA1_0==WORD) && 
((input.LT(1).getText().equals("dog" { ... }
else { throw ... }
 
and indeed, using ANTLRWorks, dog is accepted.

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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26320] Re: [antlr-interest] Bug or m isunderstanding?: missing attribute access on rule scope

2009-10-16 Thread David-Sarah Hopwood
Kaleb Pederson wrote:
> I'm getting an error that doesn't make any sense, either because I've
> missed something fundamental or I've stumbled across a bug. I'm doing
> some type checking within a tree parser.  I have a plusMinusExpression
> which can either be a negation or a subtraction expression.  In order
> to to check to see which it is, I have `if ($rhs != null)` within my
> action.  That line, however, causes the following error:
> 
> SemanticChecker.g:163:3: missing attribute access on rule scope: rhs

You can use "if ($rhs.tree != null)".

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com


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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26321] [antlr-interest] "No Past Experience Required"

2009-10-16 Thread Peter Boughton

Hi all,

I'm looking to figure out ANTLR and so I'm reading this page:
http://www.antlr.org/wiki/display/ANTLR3/Quick+Starter+on+Parser+Grammars+-+No+Past+Experience+Required

But there are a number of things I'm stuck on - and so I'm asking here
for both a good explanation and so that someone with edit permission
can hopefully update the wiki page to actually be "no past experience"
and more helpful for future newbies.


"Left recursion."
Maybe it's me being dim, but it took me a while to figure how "a : a B
| C ;" translated to "a : C B*;" - and whilst I get it now, perhaps a
quick sentence to explain the transition might be helpful for the wiki
page?


"syntactic predicates"
So, they're an advanced category discussed in a book... yippee! I
don't have the book, and the absolute earliest I could get it (if I
choose to) is Tuesday, so that's not particularly helpful. If they're
going to be mentioned, they should at least have a brief explanation
of when they apply, and preferably a link to an online resource that
covers them.
(I tried reading the Wikipedia article, but that waffles on without
being very helpful.)

Can anyone provide [a link to] a good, concise definition of syntactic
predicates and semantic predicates and any other terms like this - for
that matter, is there a good online glossary for all this sort of
compiler/parser related stuff?


"Difference between lexer and parser rules"
This whole paragraph leaves me going "wha?". I don't know what the
difference between a lexer and a parser is, so attempting to explain
the difference between their rules doesn't mean much yet.

There's a vague suggestion that lexers look at literals (whether
explicit or combined via multiple rules), and parsers look at
everything else, but even then I'm not sure I get the implications of
that?

What's a symbolic name?

In the example, what does the "EQUALS='=';" syntax do? Should that be
a colon, or is something else happening?
What about IMAGINERY_TOKEN - what's that doing?

I'm now confused about tokens and non-terminal symbols - they are
obviously different, but how?

In the example for "How to build a grammar from a language
specification", the FILE rule is not in the tokens section
Does that make it a non-terminal symbol?
Is this example grammar handled by a lexer or a parser or both?


I do have some other questions, but they're not directly related to
the wiki page, so I'll leave them for a later email, once I have a
better idea of what's what.


Thanks,

Peter

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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26322] Re: [antlr-interest] Bug or misunderstanding?: missing attribute access on rule scope

2009-10-16 Thread Kaleb Pederson
On Fri, Oct 16, 2009 at 2:15 PM, David-Sarah Hopwood
 wrote:
> Kaleb Pederson wrote:
>> I'm getting an error that doesn't make any sense, either because I've
>> missed something fundamental or I've stumbled across a bug. I'm doing
>> some type checking within a tree parser.  I have a plusMinusExpression
>> which can either be a negation or a subtraction expression.  In order
>> to to check to see which it is, I have `if ($rhs != null)` within my
>> action.  That line, however, causes the following error:
>>
>> SemanticChecker.g:163:3: missing attribute access on rule scope: rhs
>
> You can use "if ($rhs.tree != null)".

You're right, thank you.  Here's what ANTLR generates:

...
if ((rhs!=null?((CommonTree)rhs.tree):null) != null)
{
typeChecker.assertIsNumericType((rhs!=null?rhs.type:null));
typeChecker.assertEqualTypes((lhs!=null?lhs.type:null),
(rhs!=null?rhs.type:null));
}

So it places a guard around my check making sure that it only happens
if rhs isn't null.  To pose my next question, isn't what I had
perfectly legal? I.e. Isn't it pefectly legal to reference $labelName
without referencing an attribute, such as in my null check?

--
Kaleb Pederson

Twitter - http://twitter.com/kalebpederson
Blog - http://kalebpederson.com

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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26323] Re: [antlr-interest] Semantic predicates

2009-10-16 Thread Andreas Meyer

Andreas Meyer schrieb:
> Robert Wentworth schrieb:
>   
>> There appears to be something fundamental that I am not "getting"  
>> [...] 
>> 
>
> I think the generated code is wrong. [...]
>   
btw, when changing the gated semantic predicates:
> > cat : {input.LT(1).getText().equals("cat")}?=> WORD ;
> >
> > dog : {input.LT(1).getText().equals("dog")}?=> WORD ;
>   
into plain semantic predicates
> > cat : {input.LT(1).getText().equals("cat")}? WORD ;
> >
> > dog : {input.LT(1).getText().equals("dog")}? WORD ;
>   
the generated code looks good and expr can accept cat, cat when dog and 
dog. Now, as the other poster already mentioned, gated semantic 
predicates are there to distinguish between alternatives (that are not 
syntactically ambiguous). Maybe that's where ANTLR (or the user?!) get's 
confused, because cat only has one alternative (which get's effectively 
disabled if the predicate fails), but the context in which it is used 
has more alternatives, which effectively boil down to the same gated 
predicates.

Best,
Andreas Meyer

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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26324] Re: [antlr-interest] Bug or misunderstanding?: missing attribute access on rule scope

2009-10-16 Thread David-Sarah Hopwood
Kaleb Pederson wrote:
> On Fri, Oct 16, 2009 at 2:15 PM, David-Sarah Hopwood
>  wrote:
>> Kaleb Pederson wrote:
>>> I'm getting an error that doesn't make any sense, either because I've
>>> missed something fundamental or I've stumbled across a bug. I'm doing
>>> some type checking within a tree parser.  I have a plusMinusExpression
>>> which can either be a negation or a subtraction expression.  In order
>>> to to check to see which it is, I have `if ($rhs != null)` within my
>>> action.  That line, however, causes the following error:
>>>
>>> SemanticChecker.g:163:3: missing attribute access on rule scope: rhs
>>
>> You can use "if ($rhs.tree != null)".
> 
> You're right, thank you.  Here's what ANTLR generates:
> 
> ...
> if ((rhs!=null?((CommonTree)rhs.tree):null) != null)
> {
>   typeChecker.assertIsNumericType((rhs!=null?rhs.type:null));
>   typeChecker.assertEqualTypes((lhs!=null?lhs.type:null),
> (rhs!=null?rhs.type:null));
> }
> 
> So it places a guard around my check making sure that it only happens
> if rhs isn't null.  To pose my next question, isn't what I had
> perfectly legal? I.e. Isn't it pefectly legal to reference $labelName
> without referencing an attribute, such as in my null check?

The syntax $labelName can be used in a parser or lexer grammar to refer
to a Token object, in cases where the reference is statically guaranteed
to correspond to a single token or fragment.

In a tree grammar, or in other cases in a parser grammar, the reference
might correspond to more than one token. So there are two possible design
choices for that situation: either make $labelName evaluate to something
other than a Token object reference, or disallow it. Making it evaluate to
something other than a Token would be inconsistent and possibly error-
prone, so disallowing it is reasonable.

In the case where all you're doing is testing the reference against null,
it may seem as though it wouldn't matter whether it corresponds to a
single token or more than one token. But ANTLR doesn't analyse
expressions in the target language, so it can't special-case this
situation.

This restriction tripped me up as well when I first came across it.
Arguably, it would have been better to *always* require an attribute
access -- say, "$labelName.token" in cases where you want a Token, and
"$labelName.isPresent" to test whether labelName matched any tokens
(or characters in the case of a lexer grammar).
That would have been easier to remember, and more consistent between
different kinds of grammar. Currently lexer grammars are not even self-
consistent: depending on context a bare $labelName reference evaluates
sometimes to an integer code point value, and sometimes to a Token
object reference.


[The other thing I think is suboptimal about ANTLR's behaviour in this
area (at least the Java target; I haven't checked other targets) is
that it generates a variable in the target language that has the same
name as the label. This means that leaving off the '$' will result in
code that may compile, and if it does compile, usually does something
unintended. It also causes errors if a label name matches a target
language keyword. Just mangling the name slightly would have prevented
these problems, although doing so now might be incompatible with any
grammars that rely on this property of the generated code.]

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com


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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26325] Re: [antlr-interest] Semantic predicates

2009-10-16 Thread David-Sarah Hopwood
Andreas Meyer wrote:
> Andreas Meyer schrieb:
>> Robert Wentworth schrieb:
>>   
>>> There appears to be something fundamental that I am not "getting"  
>>> [...] 
>>> 
>> I think the generated code is wrong. [...]
>>   
> btw, when changing the gated semantic predicates:
>>> cat : {input.LT(1).getText().equals("cat")}?=> WORD ;
>>>
>>> dog : {input.LT(1).getText().equals("dog")}?=> WORD ;
>>   
> into plain semantic predicates
>>> cat : {input.LT(1).getText().equals("cat")}? WORD ;
>>>
>>> dog : {input.LT(1).getText().equals("dog")}? WORD ;
>>   
> the generated code looks good and expr can accept cat, cat when dog and 
> dog. Now, as the other poster already mentioned, gated semantic 
> predicates are there to distinguish between alternatives (that are not 
> syntactically ambiguous). Maybe that's where ANTLR (or the user?!) get's 
> confused, because cat only has one alternative (which get's effectively 
> disabled if the predicate fails), but the context in which it is used 
> has more alternatives, which effectively boil down to the same gated 
> predicates.

I think we have to interpret this as an ANTLR bug, not the grammar writer
being confused. Conceptually, a gated semantic predicate with a single
alternative has a clear meaning: if the predicate fails then it should be
equivalent to a rule that never matches. It would be very strange for it
to mean anything else.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com


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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26326] Re: [antlr-interest] Bug or misunderstanding?: missing attribute access on rule scope

2009-10-16 Thread Kaleb Pederson

On Fri, Oct 16, 2009 at 3:58 PM, David-Sarah Hopwood
 wrote:
> Kaleb Pederson wrote:
>> To pose my next question, isn't what I had
>> perfectly legal? I.e. Isn't it pefectly legal to reference $labelName
>> without referencing an attribute, such as in my null check?
>
> The syntax $labelName can be used in a parser or lexer grammar to refer
> to a Token object, in cases where the reference is statically guaranteed
> to correspond to a single token or fragment.
>
> In a tree grammar, or in other cases in a parser grammar, the reference
> might correspond to more than one token. So there are two possible design
> choices for that situation: either make $labelName evaluate to something
> other than a Token object reference, or disallow it. Making it evaluate to
> something other than a Token would be inconsistent and possibly error-
> prone, so disallowing it is reasonable.

Ahh, that's the difference.  In this case I'm working with a tree
grammar which doesn't behave the same.

> In the case where all you're doing is testing the reference against null,
> it may seem as though it wouldn't matter whether it corresponds to a
> single token or more than one token. But ANTLR doesn't analyse
> expressions in the target language, so it can't special-case this
> situation.

True, and this even holds for comments in the target language, which
bit me once.

> This restriction tripped me up as well when I first came across it.
> Arguably, it would have been better to *always* require an attribute
> access -- say, "$labelName.token" in cases where you want a Token, and
> "$labelName.isPresent" to test whether labelName matched any tokens
> (or characters in the case of a lexer grammar).
> That would have been easier to remember, and more consistent between
> different kinds of grammar. Currently lexer grammars are not even self-
> consistent: depending on context a bare $labelName reference evaluates
> sometimes to an integer code point value, and sometimes to a Token
> object reference.

I'll have to remember that.

> [The other thing I think is suboptimal about ANTLR's behaviour in this
> area (at least the Java target; I haven't checked other targets) is
> that it generates a variable in the target language that has the same
> name as the label. This means that leaving off the '$' will result in
> code that may compile, and if it does compile, usually does something
> unintended. It also causes errors if a label name matches a target
> language keyword. Just mangling the name slightly would have prevented
> these problems, although doing so now might be incompatible with any
> grammars that rely on this property of the generated code.]

Thanks for the great explanation and details.

--
Kaleb Pederson
Twitter - http://twitter.com/kalebpederson
Blog - http://kalebpederson.com

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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26327] Re: [antlr-interest] How to do "not" in a syntactic predicate?

2009-10-16 Thread Gavin Lambert

At 00:39 17/10/2009, Naveen Chawla wrote:
>So, does anybody have a way of doing "Take *a* IF not followed by 
>*b* (both syntactic constructs)" ?
>
>i.e.
>q: (a !b)=> a;//("!" or "not" doesn't 
>exist in ANTLR)

Actually there is a negation operator, ~ -- but this operates on 
sets, not on sequences.  So in the lexer you can use "any single 
character not in this set" and in the parser you can use "any 
single token not in this set", but you can't get it to match on 
longer sequences without splitting them up into single-char/token 
decisions.

Without knowing more about what your a and b are, it's hard to 
give any more specific advice; for example, if b is a fixed 
sequence, such as DOT STAR, then you can do the above like so:

q : (a (~DOT | DOT ~STAR)) => a
   | /* nothing */
   ;

(I'm fairly sure you have to explicitly provide an alternative, 
either explicitly like this or via ?; if you don't then I think 
ANTLR will discard the predicate.  With no alternatives a 
predicate is useless.)

If b is not a fixed sequence, then you still need to provide the 
alternative choice, but by reversing the predicate:

q : (a b) => /* nothing */
   | a
   ;

Note that I haven't actually tested either of these, but in 
principle they ought to work. :)


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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26328] Re: [antlr-interest] "No Past Experience Required"

2009-10-16 Thread Horst Dehmer

Hello Peter,

i myself am not too familiar with ANTLR 3 (and parser generators in general)
and for that reason i feel tempted to try to give some answers.

A symbol is a 'word' in a grammar, like a word in a natural language. A
symbol can be a terminal (symbol) which can no further be 'reduced', like
reserved words in a programming language: 'for', 'while', 'if'... You get
the picture. Non-terminals are the left side of a grammar (production) rule.
Non-terminals are reduced during parsing according to the defined grammar
and the stream of available tokens.

A lexer usually takes a character stream as an input and converts it in a
stream of tokens. The characters 'f', 'o', 'r', ' ', '(' for example become
the tokens 'for' and '('. In the old times (and still today with certain
lexers) lexer rules were defined just by regular expressions, which
restricts the class of what can be recognized by a parser pretty much
compared to ANTLR.

The parser takes a token stream as a input and tries to recognize a higher
level order. Think of it as sentences of a language following a certain
grammar. The rules which make up a parser grammar are usually much more
complex than lexer rules. (E)BNF can not be expressed by regular expression.

LL(k), LL(*) parsers (top-down, results are build by working their way from
left to right) are classes of parsers which are not very popular. I might be
wrong (or to old) but LR parsers are much more common. So maybe have a quick
look at lex/yacc. For me that's the father of all parser generators (for C).

Predicates (syntactic and semantic) help a LL parser determine which 'way to
go' or which alternatives to ignore. I guess they are quite unique to LL
parsers which have the "problem" with left-recursion or common prefix, which
really is no problem once you got your head around it.

For what it's worth: i would not start with ANTLR to build my first
grammars. The documentation is far too sophisticated for my taste and you
definitivly have to have some experiences to get started. If you don't know
what to look for even the book is useless. Don't get me wrong ANTLR 3 is a
very powerful and reliable tool, but before you use it make sure you really
need it. If you'd like to stick to ANTLR, have a look at the example
grammars. There are lots of 'em around and they give good hints on how to
solve promlems. 

And last but not least, if you are really interested in things, read the
Dragon Book: Principles of Compiler Design, by Alfred Aho and Jeffrey D.
Ullman

Regards,

Horst

PS: For those recognizing my errors and misunderstandings, help Peter to get
going.


On 16.10.09 23:28, "Peter Boughton"  wrote:

> Hi all,
> 
> I'm looking to figure out ANTLR and so I'm reading this page:
> http://www.antlr.org/wiki/display/ANTLR3/Quick+Starter+on+Parser+Grammars+-+No
> +Past+Experience+Required
> 
> But there are a number of things I'm stuck on - and so I'm asking here
> for both a good explanation and so that someone with edit permission
> can hopefully update the wiki page to actually be "no past experience"
> and more helpful for future newbies.
> 
> 
> "Left recursion."
> Maybe it's me being dim, but it took me a while to figure how "a : a B
> | C ;" translated to "a : C B*;" - and whilst I get it now, perhaps a
> quick sentence to explain the transition might be helpful for the wiki
> page?
> 
> 
> "syntactic predicates"
> So, they're an advanced category discussed in a book... yippee! I
> don't have the book, and the absolute earliest I could get it (if I
> choose to) is Tuesday, so that's not particularly helpful. If they're
> going to be mentioned, they should at least have a brief explanation
> of when they apply, and preferably a link to an online resource that
> covers them.
> (I tried reading the Wikipedia article, but that waffles on without
> being very helpful.)
> 
> Can anyone provide [a link to] a good, concise definition of syntactic
> predicates and semantic predicates and any other terms like this - for
> that matter, is there a good online glossary for all this sort of
> compiler/parser related stuff?
> 
> 
> "Difference between lexer and parser rules"
> This whole paragraph leaves me going "wha?". I don't know what the
> difference between a lexer and a parser is, so attempting to explain
> the difference between their rules doesn't mean much yet.
> 
> There's a vague suggestion that lexers look at literals (whether
> explicit or combined via multiple rules), and parsers look at
> everything else, but even then I'm not sure I get the implications of
> that?
> 
> What's a symbolic name?
> 
> In the example, what does the "EQUALS='=';" syntax do? Should that be
> a colon, or is something else happening?
> What about IMAGINERY_TOKEN - what's that doing?
> 
> I'm now confused about tokens and non-terminal symbols - they are
> obviously different, but how?
> 
> In the example for "How to build a grammar from a language
> specification", the FILE rule is not in the tokens section
> Do

[il-antlr-interest: 26330] free software

2009-10-16 Thread free software


download free software click here
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a

===
download new vedios 2009 click here
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a
http://www.banatmsr.com/a7a


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26331] Re: [antlr-interest] Bug or misunderstanding?: missing attribute access on rule scope

2009-10-16 Thread John B. Brodie

Greetings!

Sorry about this message, I think I have broken any threading to the
original message. I am replying from the mail-list archive and seem to
be unable to figure out how to graft my reply into its proper thread.
Sorry.

On Fri Oct 16 12:21:33 PDT 2009, Kaleb Pederson asked:
> I'm getting an error that doesn't make any sense, either because I've
> missed something fundamental or I've stumbled across a bug. I'm doing
> some type checking within a tree parser.  I have a plusMinusExpression
> which can either be a negation or a subtraction expression.  In order
> to to check to see which it is, I have `if ($rhs != null)` within my
> action.  That line, however, causes the following error:
> 
> SemanticChecker.g:163:3: missing attribute access on rule scope: rhs
> 
> The grammar fragment follows:
> 
> plusMinusExpression returns [Type type]
>   :   ^(PLUS lhs=baseExpression rhs=baseExpression) { /*...*/ }
>   |   ^(MINUS lhs=baseExpression rhs=baseExpression?)
>   {
>   typeChecker.assertIsNumericType($lhs.type);
>   if ($rhs != null)
>   {
>   typeChecker.assertIsNumericType($rhs.type);
>   typeChecker.assertEqualTypes($lhs.type, 
> $rhs.type);
>   }
>   $type = $lhs.type;
>   }
>   ;

Others in this thread have pointed out that you should use ($rhs.tree != null) 
in your if statement.

I would like to, respectfully, suggest that you are doing the Wrong Thing(TM) 
in your action code.
And it is wrong on two levels - the first mis-use is rather shallow and the 
second is a rather more
deeper mis-use.

I mean nothing personal nor pejorative by these comments. I am just trying to 
point out a couple
of "better" ways to do the above. And of course "better" is a qualitative 
assessment unique to each
reader of this message (e.g. what is "better" to me may not be "better" to 
you...).



The first, shallow, mis-use (IMHO) is to not simply let the Tree Walker code 
decide for you whether
or not the rhs tree node is present. That is, instead of

   | ^(MINUS lhs=baseExpression rhs=baseExpression?) { /* figure out what to do 
*/ }

do something like this:

   | ^(MINUS lhs=baseExpression) { /* handle the 1-arity '-' operator here */ }
   | ^(MINUS lhs=baseExpression rhs=baseExpression) { /* handle the 2-arity 
subtraction here */ }

e.g. the Tree Walker code has to already poke around in your tree in order to 
determine whether or 
not the rhs is present (as part of its tree pattern matching) --- so let it 
control the invocation
of your actions.



The second, i think deeper, mis-use is that you have (apparently) discarded 
information discovered
during parsing and AST creation that you could use to guide your subsequent AST 
processing.

Surely in your Parser the 1-arity '-' appears in a different syntactic context 
from the 2-arity '-'
operator  so when parsing "a+-b" we know that the '-' must be the 1-arity 
operator, but when we
parse "a-b" we know that the '-' must be the 2-arity operator.

So I suggest to you that your Parser should differentiate the MINUS tree --- 
since, I assert, that
it already does so as part of the parse --- by creating a different (with 
imaginary root) node for
the 1-arity case. So "a+-b" obtains the tree (PLUS a (NEGATE b)) and "a-b" 
obtains the tree
(MINUS a b) or something similar in accord with your taste...

And so, with this approach, in all of your post-processing of the AST, the 
1-arity and 2-arity
operations have already been differentiated in the tree itself and therefore 
can be directly
determined --- no need to noodle around about whether or not 1 or 2 children 
are present.

Your Mileage May Vary.



Hope this helps...
   -jbb
(again, sorry for breaking the threading of the replies to the original message)

and there is also the possibility of having ONLY the 2-arity '-' operator 
because in Algebra
the 1-arity '-' is an implicit 2-arity operation involving zero. so the "a+-b" 
would become
(PLUS a (MINUS 0 b)) --- but this just tends to break my brain so i do not do 
that. ;-)

and, please, can we just not discuss the whole treatment of 2-arity '-' as an 
addition
with multiply by -1 . my brain tends to just shutdown at that prospect ;-)



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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---

[il-antlr-interest: 26332] Re: [antlr-interest] accepting nested code blocks

2009-10-16 Thread Jim Idle

Yes you can do it - you probably need to keep state flags and either trigger 
lexer rules based upon them or perhaps better would be to trigger an external 
lexer. The main problem is error recovery - what does your lexer do if the 
Javascript does not have perfectly matched '{' '}' and so the lexer rules drops 
out. 

However, if all you need do is consume the JS and say "this is a blob of JS", 
then I would write a small method that knows how to consume a Javascript 
function. Probably easier than writing it all out as recursive lexer rules. 

I have used this recursive technique for embedded XML and similar.

However, another thought is that if you have any control over the language, you 
should change it so that it does not just arbitrarily generate Javascript but 
delimits it in some reasonable way with say << javascript >> or some other 
delimiter. Then your lexer can just pick that out and strip off the delimiters.

Jim


> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Espák Miklós
> Sent: Tuesday, October 13, 2009 11:11 PM
> To: Indhu Bharathi
> Cc: antlr-inter...@antlr.org
> Subject: Re: [antlr-interest] accepting nested code blocks
> 
> Hi,
> 
> I understand your point of view, but the book states explicitly the
> following:
> 
> "ANTLR generates recursive-descent recognizers
> for lexers just as it does for parsers and tree parsers. Consequently,
> ANTLR supports recursive lexer rules, unlike other tools such as lex."
> 
> Using recursion it should be possible to create such a lexer rule. If
> not, what it can be used for?
> 
> My original problem is that the input files contain a JavaScript
> function definition. The other parts of the input are covered by the
> grammar. However, I do not need to check the validity of the JS
> function, just extract it as is, and pass to the JS engine later. So
> if it is not necessary, I do not want to parse it.
> 
> Is it possible somehow? Or should I denote the beginning and the end
> of the JS function by some special token to allow catching it by a
> lexer rule?
> 
> Cheers,
> Miklos
> 
> 2009/10/13 Indhu Bharathi :
> > Balanced parenthesis cannot be expressed using regular expression
> which
> > means you cannot recognize it using lexer. You need a push down
> automata
> > which means you need a parser to recognize it. Try doing it using
> parser
> > rules.
> >
> >
> >
> > Cheers, Indhu
> >
> >
> >
> >
> >
> > From: antlr-interest-boun...@antlr.org
> > [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Espák Miklós
> > Sent: Tuesday, October 13, 2009 10:04 PM
> > To: antlr-inter...@antlr.org
> > Subject: [antlr-interest] accepting nested code blocks
> >
> >
> >
> > Hi,
> >
> > I want to create a lexer rule accepting nested code blocks.
> >
> > I tried out the example of the Definitive ANTLR Reference (Section
> 4.3), but
> > it does not work.
> > It accepts only such inputs which do not contain any character other
> than
> > curly braces. Moreover, one closing brace is enough.
> >
> > The error is the following:
> > MismatchedTokenException: line 1:1 mismatched input UNKNOW expecting
> 125
> >
> > The original code of the book:
> >
> > fragment
> > CODE[boolean stripCurlies]:
> >   '{' ( CODE[stripCurlies] | ~('{' |'}' ) )* '}'
> >   {
> >     if ( stripCurlies ) {
> >   setText(getText().substring(1, getText().length()));
> >     }
> >   }
> >   ;
> >
> > The simplified version of the rule results the same:
> > fragment
> > Block: '{' ( Block | ~('{'|'}') )* '}';
> >
> > I use ANTLR 3.2.
> >
> > Does anybody have an idea, how to get around this?
> >
> > Thanks,
> >
> > Miklos
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address




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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26333] Re: [antlr-interest] Example code-generation target that outputs a state machine

2009-10-16 Thread Mike Samuel

> Mike Samuel wrote:
> > I'd like to derive a state machine that recognizes a combined lexical
> > grammar of JS/HTML/CSS (hacked so that JS has a regular lexical
> > grammar) and a mapping from states to the production they're part of.
> > I need to keep the number of states small.
> >
> > I saw something tantalizing about "dfaState() String Template" at
> > http://www.antlr.org/wiki/display/ANTLR3/How+to+build+an+ANTLR+code+generation+target
> > but am still unsure how to proceed.
> >
> > Is this possible with ANTLR, and if so, does anyone know of existing
> > code I could adapt?
> >
> > For background, my end goal is to bolt string interpolation onto
> > javascript, but in a way that doesn't introduce XSS problems as
> > described at
> > http://google-caja.googlecode.com/svn/changes/mikesamuel/string-interpolation-29-Jan-2008/trunk/src/js/com/google/caja/interp/index.html

David-Sarah Hopwood wrote:
> Sounds like a fun project.

> ANTLR normally only generates explicit DFAs when there is a nontrivial
> decision between alternatives of a rule. In the case of the ECMAScript 5
> lexical grammar I'm using, it only generates two DFAs, one for the main
> tokens rule, and one for DecimalLiteral.

> You can get ANTLRWorks to show a state machine diagram for any particular
> decision, or for the tokens rule, but they're not particularly
> enlightening. In principle, ANTLR computes all the information needed to
> produce a pure FSM lexer, but I don't think it provides any way to actually
> generate one, at least not without a lot of work. If that's definitely
> what you need, ANTLR is probably not the right tool.

Thanks for the response, David-Sarah.  Fancy running into you here.  I
guess you're using ANTLR for Jacaranda then?
How do you get a lexical grammar to distinguish division
operators/regex literal using ES5 rules, or are you using the lexical
grammar from Waldemar's JS 1.9 then?

I poked about a bit more, and when I generate a lexer, I get code that
looks like the below which sees to create instances of
org.antlr.runtime.DFA as described at
http://www.antlr.org/api/Java/classorg_1_1antlr_1_1runtime_1_1_d_f_a.html
.  I think I can probably poke at those to produce both (1) an
alphabet reduction, and (2) a transition table.
It won't integrate nicely into a build from grammar, and it's hacky,
but if the DFA just isn't exposed to code-generation targets, then
it'll be easier than trying to engineer a way through the front door.

==
static final short[] DFA19_eot = DFA.unpackEncodedString(DFA19_eotS);
// more unpacking elided

static {
int numStates = DFA19_transitionS.length;
DFA19_transition = new short[numStates][];
for (int i=0; ihttp://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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26334] Re: [antlr-interest] Example code-generation target that outputs a state machine

2009-10-16 Thread David-Sarah Hopwood
Mike Samuel wrote:
>> Mike Samuel wrote:
>>> For background, my end goal is to bolt string interpolation onto
>>> javascript, but in a way that doesn't introduce XSS problems as
>>> described at
>>> http://google-caja.googlecode.com/svn/changes/mikesamuel/string-interpolation-29-Jan-2008/trunk/src/js/com/google/caja/interp/index.html
> 
> David-Sarah Hopwood wrote:
>> Sounds like a fun project.
> 
>> ANTLR normally only generates explicit DFAs when there is a nontrivial
>> decision between alternatives of a rule. In the case of the ECMAScript 5
>> lexical grammar I'm using, it only generates two DFAs, one for the main
>> tokens rule, and one for DecimalLiteral.
> 
>> You can get ANTLRWorks to show a state machine diagram for any particular
>> decision, or for the tokens rule, but they're not particularly
>> enlightening. In principle, ANTLR computes all the information needed to
>> produce a pure FSM lexer, but I don't think it provides any way to actually
>> generate one, at least not without a lot of work. If that's definitely
>> what you need, ANTLR is probably not the right tool.
> 
> Thanks for the response, David-Sarah.  Fancy running into you here.  I
> guess you're using ANTLR for Jacaranda then?

Yes. Should be released fairly soon.

> How do you get a lexical grammar to distinguish division
> operators/regex literal using ES5 rules, or are you using the lexical
> grammar from Waldemar's JS 1.9 then?

I'm using feedback from the parser to the lexer. I looked carefully at
trying to use a finite state machine for this, but that approach can't
work if you want to parse full ES5 in all corner cases. The problematic
cases are things like "while (expr) /regexp/;", because it's impossible
to tell whether the '/' is part of a regexp literal without counting
whether the parentheses in 'expr' are balanced. Since expressions are
obviously not a regular language, that would require an infinite state
machine; parser -> lexer feedback turns out to be simpler.

Actually, if I had known how much complexity parsing regexp literals
correctly was going to add, I wouldn't have bothered; it's horrendous.
But that part is done now and seems to work.

Here's the comment I wrote about it:


ES5 says,

# There are two goal symbols for the lexical grammar. The InputElementDiv
# symbol is used in those syntactic grammar contexts where a leading
# division (/) or division-assignment (/=) operator is permitted. The
# InputElementRegExp symbol is used in other syntactic grammar contexts.

("Permitted" means syntactically valid in the *ES5* grammar.)

We don't quite follow this specification literally: we lex as a
RegularExpressionLiteral only in expression contexts, where a
regexp literal is permitted, rather than in all contexts where a
DivisionPunctuator is *not* permitted. This is equivalent for
syntactically valid input, since there are no contexts in which
both are permitted (the ES3 spec suggested otherwise, but see
).

This has the advantage that for error recovery it is more sensible to
lex a misplaced '/' or '/=' as a misplaced DivPunctuator, rather than
as part of a RegularExpressionLiteral, since the latter are less
common (and would result in code up to the next '/' being ignored).

Implementation:

The lexer first lexes '/' as part of a DIV or DIVASSIGN token
(see the DIV rule in Punctuators above). If the parser finds such a
token in an expression context, then it resets the lexer and its
input stream so that the '/' will be the next char to be consumed.
A flag is also set in the lexer so that the next invocation of the
DIV rule will expect a regular expression literal. Then, the token
stream is reset to before the DIV or DIVASSIGN, discarding that
token and any following tokens read due to lookahead. This ensures
that when rewriting, the rewritten token stream does not contain
spurious tokens.

To support this functionality we must use a custom LazyTokenRewriteStream.
If the usual CommonTokenStream or TokenRewriteStream were used, the
lexer would lex all tokens on the first call to it (see the fillBuffer()
method of CommonTokenStream). Even if that were not the case, the lexer
necessarily runs ahead of the parser, due to token lookahead in the
parser. If the lexer may be reset, then lexing too far ahead is
inefficient, and more importantly causes spurious errors to be reported.

To solve this problem, LazyTokenRewriteStream only lexes tokens that
have been requested (typically by consume() or LA(k)). Each JacarandaToken
object records the errors associated with that token, so that these errors
can be reported only if the token remains part of the final token stream.
This also has the advantage of reporting all errors in the order of their
associated token position, which is a deterministic order independent of
lookahead depth.


> I poked about a bit more, and when I generate a lexer, I get code that
> looks like the below which sees to create instances of
> org.ant

[il-antlr-interest: 26335] Re: [antlr-interest] ANTLR C: Question regarding the portability of generated lexer C code

2009-10-16 Thread Jim Idle
However, I am pretty sure that all the C compilers on such systems allow 
specification of ASCII assumptions rather than the stupid EBCDIC (designed by 
committee to be stupid). For instance I know that the zOS compiler allows this. 
EBCDIC is a ridiculous encoding, which I won’t be supporting directly I am 
afraid.

 

So, compile the code with ASCII assumptions and feed the EBCDIC as 8 bit 
Unicode and you will be fine.

 

Jim

 

From: Lego Haryanto [mailto:legoharya...@gmail.com] 
Sent: Thursday, October 15, 2009 8:27 PM
To: Jim Idle
Cc: antlr-inter...@antlr.org
Subject: Re: [antlr-interest] ANTLR C: Question regarding the portability of 
generated lexer C code

 

Jim, thanks for your response ...

I know that in the EBCDIC system we feed a Unicode stream into the lexer, thus 
I'm pretty sure when the generated lexer code I pasted before is executed, it 
is already operating on the 32-bit unicode stream.

The problem is more about the native C compilation in an EBCDIC system like IBM 
z/OS mainframe.

To see if a character from the Unicode stream is an 'A', we have to compare 
with a value 0x0041 ... If we match it with a native 'A' in the code, this will 
not be a match in an EBCDIC C compilation.

Best,
-Lego

On Fri, Oct 16, 2009 at 3:07 AM, Jim Idle  wrote:

ANTLR works internally with 32 bit Unicode (UTF32), not EBCDIC, even if it is 
in 8 bit mode. So you need to convert the EBCDIC to Unicode 8 bits and use the 
‘ASCII’ input stream. A simple way to do this would be to write your own EBCDIC 
input stream that just converted to Unicode code points (essentially 
EBCDIC->ASCII) on the fly via a lookup table. Trivial and should be pretty 
quick.

 

Jim

 

From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Lego Haryanto
Sent: Tuesday, October 13, 2009 3:51 AM
To: antlr-inter...@antlr.org
Subject: [antlr-interest] ANTLR C: Question regarding the portability of 
generated lexer C code

 

I just recently noticed that the generated code from my lexer grammar contains 
something like the following snippet:

.
.
else if ( (((LA17_0 >= 'A') && (LA17_0 <= 'Z'))) ) 
{
alt17=2;
}
else if ( (((LA17_0 >= 'a') && (LA17_0 <= 'z'))) ) 
{
alt17=3;
}
else if ( (((LA17_0 >= 0x00A0) && (LA17_0 <= 0xD7FF))) ) 
{
alt17=4;
}
.
.

The generated code seems to comfortably use 'A' ... 'Z' literals.  This may not 
be good if let's say I compile the generated code in an IBM z/OS EBCDIC 
environment as ['A' .. 'Z'] range contains more than just the 26 alphabet codes 
and the value of the codes are not the same as the ones in Unicode character 
set.

I'm expecting something like in the third expression where 'A' is written 
explicitly as 0x0041 (Unicode for 'A').

Please confirm.

-Lego




-- 
Fear of the LORD is the beginning of knowledge (Proverbs 1:7)




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26336] Re: [antlr-interest] ANTLR C: Question regarding the portability of generated lexer C code

2009-10-16 Thread Jim Idle
Well, you could pay me to make an EBCDIC version ;) However, there is in 
practice no problem with mixing this – I have done it before on zOS.

 

I think that you need to look at this in the opposite light in that it isn’t 
that ANTLR code isn’t portable, but your lexer specification (and the fact that 
EBCDIC is stupid).

 

Why are you specifying your rule as:

 

ID: ‘a’..’z’

 

When that is not a valid range in your target environment? 

 

Change the ranges to:

 

ID: ‘a’..’k’ | ‘l’..’t’ …

 

Or whatever the valid ranges are. ANLTR might be ‘clever’ here and assuming 
ASCII, may merge those ranges, so you might need to fold the ranges into 
fragments and so on. However, if you rework your lexer rules, I am sure that 
this can be done in portable fashion that does not require ASCII assumptions 
within the compiler.

 

Jim

 

From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Lego Haryanto
Sent: Friday, October 16, 2009 2:59 AM
To: David-Sarah Hopwood
Cc: antlr-inter...@antlr.org
Subject: Re: [antlr-interest] ANTLR C: Question regarding the portability of 
generated lexer C code

 

Thanks for the response, ...

Unfortunately, it won't work in our situation without major changes.  We 
already have legacy C code which is compiled with default/native, and while we 
can use a different compile option for the ANTLR generated code, I'm not sure 
if it's good moving forward with mixed compilation rules.

The argument remains that it means the generated C lexer code has to be 
compiled by an ASCII-based compiler which may not be that portable.

Best,
-Lego

On Thu, Oct 15, 2009 at 12:30 PM, David-Sarah Hopwood 
 wrote:

Lego Haryanto wrote:
> Jim, thanks for your response ...
>
> I know that in the EBCDIC system we feed a Unicode stream into the lexer,
> thus I'm pretty sure when the generated lexer code I pasted before is
> executed, it is already operating on the 32-bit unicode stream.
>
> The problem is more about the native C compilation in an EBCDIC system like
> IBM z/OS mainframe.
>
> To see if a character from the Unicode stream is an 'A', we have to compare
> with a value 0x0041 ... If we match it with a native 'A' in the code, this
> will not be a match in an EBCDIC C compilation.

The z/OS C compiler is able to compile in a mode where string and character
literals are treated as ISO-8859-1.


--
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address




-- 
Fear of the LORD is the beginning of knowledge (Proverbs 1:7)




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26338] Re: [antlr-interest] SEEMS NOBODY HERE LIKE TO HELP OTHERS

2009-10-16 Thread Jim Idle
Perhaps you guys are not asking the right questions. There is a tendency for 
some people to jump straight in to huge grammars without the appropriate 
practicing on smaller examples (which are provided). I try to answer everyone 
if I can but I am travelling at the moment and don't have lots of spare time. 
If no one else is jumping in, then I suggest that your questions are more akin 
to "can you write this for me" than you realize and that going back to basics 
might help. Switching to other parser generators won't get you over the 
fundamental problems of not having enough experience, you will just encounter 
different problems at different stages.

 

One does need to help oneself sometimes and perhaps consider what the basic 
reason is that others are not having similar problems.

 

Jim

 

From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of David Minor
Sent: Friday, October 16, 2009 1:46 PM
To: antlr_bill
Cc: antlr-interest
Subject: Re: [antlr-interest] SEEMS NOBODY HERE LIKE TO HELP OTHERS

 

I wouldn't shout about it, but I also have received scant (or no help) on this 
forum. I'm not a parasite, I purchased the book, but... well... I'm using Gold 
now and so far so good. I check back every now and then to see if I got and 
answer. The unsubscribe link is at the bottom of this message.



2009/10/16 antlr_bill 

I DONT HAVE ANY WORDS ANYMORE,
YEAH I REALLY WANNA GET SOME HELP FROM HERE 
BUT SEEMS IT'S IMPOSSIBLE
SURE ANTLR IS A GREAT PROJECT ,
BUT ...
ANYWAY ,SORRY THAT I DONT KNOW HOW TO UNSUBSCRIBE FROM THIS MAILIST



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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26337] Re: [antlr-interest] String template return val propagation

2009-10-16 Thread Jim Idle



> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Bill Andersen
> Sent: Friday, October 16, 2009 1:22 AM
> To: antlr-inter...@antlr.org
> Subject: [antlr-interest] String template return val propagation
> 

> Thanks in advance
> 
> text_block
>   : ^(AS_TEXT name phrase+)
> -> text(name={$name.st})
>   ;
> 
> name
>   : prefixed_name

{ $st = prefixed_name.st; }

You need to be explicit here :-)

>   ;
> 





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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26339] Re: [antlr-interest] [Antlr + ST] Huge output string - OutOfMemoryError

2009-10-16 Thread Jim Idle
Run Java with   - Xmx1500M

 

Or some other option that increases available memory size. However this could 
point to something that can be better organized in terms of recursion or 
whatever.

 

You may also consider running Java with a better garbage collector such as:

 

-Xincgc

 

JIm

 

 

From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Hieu Phung
Sent: Friday, October 16, 2009 4:03 PM
To: antlr-inter...@antlr.org
Subject: [antlr-interest] [Antlr + ST] Huge output string - OutOfMemoryError

 

Hi all,

I am writing a program using Antlr and StringTemplate to translate an input 
file to an XML file. Input is small but output is huge: 720KB input file will 
generate about 100MB output file. When my input reached 7608KB, I got OOM error

time taken in second: 18 - file size in KB: 4804
time taken in second: 20 - file size in KB: 5205
time taken in second: 20 - file size in KB: 5605
time taken in second: 21 - file size in KB: 6006
time taken in second: 23 - file size in KB: 6406
time taken in second: 25 - file size in KB: 6806
time taken in second: 31 - file size in KB: 7207

at size 7608KB:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2882)
at 
java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
at 
java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:572)
at java.lang.StringBuffer.append(StringBuffer.java:320)
at java.io.StringWriter.write(StringWriter.java:60)
at 
org.antlr.stringtemplate.AutoIndentWriter.write(AutoIndentWriter.java:172)
at org.antlr.stringtemplate.language.ASTExpr.writePOJO(ASTExpr.java:702)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:683)
at 
org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:660)
at 
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:149)
at 
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:705)
at 
org.antlr.stringtemplate.language.ASTExpr.writeTemplate(ASTExpr.java:750)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:680)
at 
org.antlr.stringtemplate.language.ASTExpr.writeIterableValue(ASTExpr.java:792)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:682)
at 
org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:660)
at 
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:149)
at 
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:705)
at 
org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1670)
at 
org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1661)
at FFMParser.file(FFMParser.java:127)
at CSVTest.main(CSVTest.java:33)
   
Is there any suggestion so that program can generate 1GB file?

1)   Having multiple templates, each template generates small string, then 
write the small strings to file.
My input has format: ((Part1) (Part2)+ (Part3)). For each part2, there is an 
xml element in the output. I can have 3 templates here. In Antlr action, I will 
write each part to file when parsing is done for the part.

2)   Any template engine that could write to file directly, instead of 
returning a string...? (This might not be proper to discussed here :D)

I hope problem is stated clearly. Please let me know if you need more 
information. Any suggestion is much appreciated. Thank you.

Regards,

Helen

 

 

 

 

 




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


[il-antlr-interest: 26340] Re: [antlr-interest] Which version do I need for a CSharp target and VS 2008

2009-10-16 Thread Jim Idle

Not sure if the Csharp3 target is ready for production yet - I wanted to ask 
this myself as I would like to switch to it if it is ;-)

But I use Csharp2 as the target, and the runtime is on the download pages.

Jim

> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Robert van der Hulst
> Sent: Friday, October 16, 2009 9:41 PM
> To: antlr-inter...@antlr.org
> Subject: [antlr-interest] Which version do I need for a CSharp target
> and VS 2008
> 
> I am using Antlr 2.7.6 (CPP target) at this moment for our Language
> project.
> 
> I  need  to  do make some serious changes, so I am considering to move
> the project to Antlr 3 and a CSharp
> 
> Which version do people recommend that I should use.
> 
> I looked at the Antlr website and found two options:
> 
> - CSharp
> - CSharp3
> 
> but  I  am  not  sure  if they are both available for the latest Antlr
> build.
> 
> Which one do you recommend ?
> 
> I   would   also  like  to have a binary that does not need Java (like
> there is for Antlr 2). Does that exist ?
> 
> Finally:  Who has experience using Antlr in a VS 2008 environment (and
> setting up the necessary MsBuild steps to automate the build process)?
> 
> --
> Robert van der Hulst
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address




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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26341] Re: [antlr-interest] Bug or misunderstanding?: missing attribute access on rule scope

2009-10-16 Thread Jim Idle

You need to rewrite the unary operators with imaginary tokens in your parser, 
which then means your tree parser need not care:

unary:  PLUS unary -> ^(UPLUS unary)
 | primary
 ;

Jim

> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Kaleb Pederson
> Sent: Saturday, October 17, 2009 12:52 AM
> To: antlr-inter...@antlr.org
> Subject: [antlr-interest] Bug or misunderstanding?: missing attribute
> access on rule scope
> 
> I'm getting an error that doesn't make any sense, either because I've
> missed something fundamental or I've stumbled across a bug. I'm doing
> some type checking within a tree parser.  I have a plusMinusExpression
> which can either be a negation or a subtraction expression.  In order
> to to check to see which it is, I have `if ($rhs != null)` within my
> action.  That line, however, causes the following error:
> 
> SemanticChecker.g:163:3: missing attribute access on rule scope: rhs
> 
> The grammar fragment follows:
> 
> plusMinusExpression returns [Type type]
>   :   ^(PLUS lhs=baseExpression rhs=baseExpression) { /*...*/ }
>   |   ^(MINUS lhs=baseExpression rhs=baseExpression?)
>   {
>   typeChecker.assertIsNumericType($lhs.type);
>   if ($rhs != null)
>   {
>   typeChecker.assertIsNumericType($rhs.type);
>   typeChecker.assertEqualTypes($lhs.type,
> $rhs.type);
>   }
>   $type = $lhs.type;
>   }
>   ;
> Am I missing something fundamental or should this work? I tried
> changing rhs to something unique throughout the application, but the
> error persists.  I see the exact same behavior on both ANTLR-3.1 and
> 3.2.
> 
> Thanks.
> 
> --
> Kaleb Pederson
> Twitter - http://twitter.com/kalebpederson
> Blog - http://kalebpederson.com
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address




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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---



[il-antlr-interest: 26342] Re: [antlr-interest] ANTLR C: Question regarding the portability of generated lexer C code

2009-10-16 Thread David-Sarah Hopwood
Jim Idle wrote:
[...]
> Change the ranges to:
> 
> ID: ‘a’..’k’ | ‘l’..’t’ …

I doubt that will work. The generated code sometimes uses character
literals, sometimes string literals, and sometimes Unicode code point
values. The code can't be compiled as EBCDIC because the code point
values are not EBCDIC codes.

It would be easier to hack the C target so that it avoids character
literals, and uses only \x escapes in string literals.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com


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 Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-interest@googlegroups.com
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~--~~~~--~~--~--~---