[il-antlr-interest: 33479] Re: [antlr-interest] Have I found an Antlr CSharp3 lexer bug if...

2011-08-04 Thread chris king
Sam, while trying build my pre-processor with a mixed parser/lexer I ran
across what I think might be a bug. I reduced the repro below. I expected
the program below to accept "/**/ " but instead fails because the lexer
prediction enters PP_SKIPPED_CHARACTERS. That rule has a gated semantic
predicate which is always false. I expected a lexer rule with a gated
semantic predicate which is always false to never be matched. If I comment
out the PP_SKIPPED_CHARACTERS rule then it does match "/**/ ". So the
inclusion of that rule is cause the problem. Let me know if you think this
is a bug and if you can repro.

Thanks,
Chris


grammar Bug;

options {
   language=CSharp3;
   output=AST;
}

public start
  : DELIMITED_COMMENT !EOF
  ;

PP_SKIPPED_CHARACTERS
  : { false }? => ~(F_NEW_LINE_CHARACTER | F_PP_POUND_SIGN)
F_INPUT_CHARACTER*
  ;

DELIMITED_COMMENT
  : { true }? => '/*' .* '*/'
  ;

WHITESPACE
  : F_WHITESPACE {skip();}
  ;

fragment F_WHITESPACE
  : (' ' | '\t' | '\v' | '\f')+
  ;

fragment F_NEW_LINE_CHARACTER
  : '\r'
  | '\n'
  ;

fragment F_PP_POUND_SIGN
  : '#'
  ;

fragment F_INPUT_CHARACTER
  : ~F_NEW_LINE_CHARACTER
  ;

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-inter...@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: 33480] Re: [antlr-interest] Exception when generating tree grammar

2011-08-04 Thread Stephen Tuttlebee
Hi Luigi,

At first I was thinking, why the heck are you getting an error about a 
missing StringTemplate file when you have an AST as your output 
(output=AST). Then I looked more closely at the name of the .st file -- 
rewriteWildcardLabelRefRoot.st. I think ANTLR sometimes throws these 
slightly misleading exceptions when you have a syntax error in your 
grammar.

The above StringTemplate file mentions 'wildcard' and 'label' in it, so 
I guess that the syntax error you have is possibly due to the space 
between 'single=' (the label) and '.' (the wildcard character). 
Therefore if you change 'single= .' to 'single=.', that might solve your 
problem.

Stephen



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-inter...@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: 33481] Re: [antlr-interest] Are the Eclipse ANTLR plugins stable?

2011-08-04 Thread Stephen Tuttlebee
By 'stable', do you mean, 'it's not updated very often', or 'there are 
not many bugs'? I'm guessing you meant the former.
Also, what exactly do you mean by an 'ANTLR appliance'?

I've used ANTLR IDE, and found it to be very good. I much prefer it to 
ANTLRWorks. (Although I do still use ANTLRWork's debugging 
functionality; ANTLR IDE seems to require you to put in breakpoints 
everywhere in your grammar if you want to be able to (meaningfully) 
debug your grammar). It seems pretty stable in terms of its 
'bug-freeness'. Looking at the website, 
http://antlrv3ide.sourceforge.net/, it also seems that the plug-in has 
not been updated for half a year or so. Looks like there were about 5 or 
so updates over 2010, whilst there's not been any yet this year. 
Therefore you could infer that it's becoming more stable (either because 
it does not need updates or because the developer is not actively 
working on it at the moment).

As for ANTLR DT, I don't know anything about it.

You might find better (i.e. more official) answers on these things by 
searching for posts on this mailing list which refer to ANTLR IDE or 
AntlrDT (using Google). There might be posts by the plug-in writers 
themselves.

Stephen



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-inter...@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: 33482] Re: [antlr-interest] Exception when generating tree grammar

2011-08-04 Thread Luigi Iannone
Hi,

unfortunately the removal of the whitespace does not solve it.
I get the same error.

Cheers,

Luigi

On 4 Aug 2011, at 14:02, Stephen Tuttlebee wrote:

> Hi Luigi,
> 
> At first I was thinking, why the heck are you getting an error about a 
> missing StringTemplate file when you have an AST as your output 
> (output=AST). Then I looked more closely at the name of the .st file -- 
> rewriteWildcardLabelRefRoot.st. I think ANTLR sometimes throws these 
> slightly misleading exceptions when you have a syntax error in your 
> grammar.
> 
> The above StringTemplate file mentions 'wildcard' and 'label' in it, so 
> I guess that the syntax error you have is possibly due to the space 
> between 'single=' (the label) and '.' (the wildcard character). 
> Therefore if you change 'single= .' to 'single=.', that might solve your 
> problem.
> 
> Stephen
> 
> 
> 
> 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-inter...@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: 33483] Re: [antlr-interest] Have I found an Antlr CSharp3 lexer bug if...

2011-08-04 Thread Sam Harwell
Hi Chris,

 

I'm using the released version 3.4.0 of the ANTLR CSharp3 target. I
copy/pasted the grammar below (aside from renaming it to Preprocessor) and
it passed the following unit test.

 

[TestMethod]

public void TestEmptyComment()

{

string inputText = "/**/";

var input = new ANTLRStringStream(inputText);

var lexer = new PreprocessorLexer(input);

var tokenStream = new CommonTokenStream(lexer);

tokenStream.Fill();

 

List tokens = tokenStream.GetTokens();

Assert.AreEqual(2, tokens.Count);

Assert.AreEqual(PreprocessorLexer.DELIMITED_COMMENT, tokens[0].Type);

Assert.AreEqual(inputText, tokens[0].Text);

Assert.AreEqual(PreprocessorLexer.EOF, tokens[1].Type);

}

 

Sam

 

From: chris king [mailto:kingce...@gmail.com] 
Sent: Thursday, August 04, 2011 3:48 AM
To: Sam Harwell; antlr-interest@antlr.org
Subject: Re: Have I found an Antlr CSharp3 lexer bug if...

 

Sam, while trying build my pre-processor with a mixed parser/lexer I ran
across what I think might be a bug. I reduced the repro below. I expected
the program below to accept "/**/ " but instead fails because the lexer
prediction enters PP_SKIPPED_CHARACTERS. That rule has a gated semantic
predicate which is always false. I expected a lexer rule with a gated
semantic predicate which is always false to never be matched. If I comment
out the PP_SKIPPED_CHARACTERS rule then it does match "/**/ ". So the
inclusion of that rule is cause the problem. Let me know if you think this
is a bug and if you can repro.

 

Thanks,
Chris

 

grammar Bug; 

 

options {

   language=CSharp3;

   output=AST;

}

 

public start

  : DELIMITED_COMMENT !EOF

  ;

  

PP_SKIPPED_CHARACTERS

  : { false }? => ~(F_NEW_LINE_CHARACTER | F_PP_POUND_SIGN)
F_INPUT_CHARACTER*

  ;

  

DELIMITED_COMMENT

  : { true }? => '/*' .* '*/'

  ;

  

WHITESPACE

  : F_WHITESPACE {skip();}

  ;

  

fragment F_WHITESPACE

  : (' ' | '\t' | '\v' | '\f')+ 

  ;

 

fragment F_NEW_LINE_CHARACTER

  : '\r'

  | '\n'

  ;

  

fragment F_PP_POUND_SIGN

  : '#'

  ;

  

fragment F_INPUT_CHARACTER

  : ~F_NEW_LINE_CHARACTER

  ;


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-inter...@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: 33484] Re: [antlr-interest] Exception when generating tree grammar

2011-08-04 Thread Stephen Tuttlebee
Well, to refresh my memory on this term rewriting stuff you're doing, I 
looked at Terence Parr's Language Implementation Patterns book which has 
a section about this (if you have the book, it's p138 in the pdf edition).

I think then it might be your tree construction rewrite rules that are 
syntactically incorrect.
Maybe it should be:
-> $single
rather than:
-> ^($single)

Hope it works this time...
Stephen


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-inter...@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: 33485] Re: [antlr-interest] Exception when generating tree grammar

2011-08-04 Thread Luigi Iannone
It works,

Thanks,

Luigi
On 4 Aug 2011, at 15:41, Stephen Tuttlebee wrote:

> Well, to refresh my memory on this term rewriting stuff you're doing, I 
> looked at Terence Parr's Language Implementation Patterns book which has 
> a section about this (if you have the book, it's p138 in the pdf edition).
> 
> I think then it might be your tree construction rewrite rules that are 
> syntactically incorrect.
> Maybe it should be:
> -> $single
> rather than:
> -> ^($single)
> 
> Hope it works this time...
> Stephen
> 
> 
> 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-inter...@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: 33490] Re: [antlr-interest] Have I found an Antlr CSharp3 lexer bug if...

2011-08-04 Thread Chris King
I should have called out the space after the comment. That's what caused the 
problem. "/**/ ". So the input string has 5 characters. 

Thanks,
Chris

On Aug 4, 2011, at 7:04 AM, "Sam Harwell"  wrote:

> Hi Chris,
> 
>  
> 
> I’m using the released version 3.4.0 of the ANTLR CSharp3 target. I 
> copy/pasted the grammar below (aside from renaming it to Preprocessor) and it 
> passed the following unit test.
> 
>  
> 
> [TestMethod]
> 
> public void TestEmptyComment()
> 
> {
> 
> string inputText = "/**/";
> 
> var input = new ANTLRStringStream(inputText);
> 
> var lexer = new PreprocessorLexer(input);
> 
> var tokenStream = new CommonTokenStream(lexer);
> 
> tokenStream.Fill();
> 
>  
> 
> List tokens = tokenStream.GetTokens();
> 
> Assert.AreEqual(2, tokens.Count);
> 
> Assert.AreEqual(PreprocessorLexer.DELIMITED_COMMENT, tokens[0].Type);
> 
> Assert.AreEqual(inputText, tokens[0].Text);
> 
> Assert.AreEqual(PreprocessorLexer.EOF, tokens[1].Type);
> 
> }
> 
>  
> 
> Sam
> 
>  
> 
> From: chris king [mailto:kingce...@gmail.com] 
> Sent: Thursday, August 04, 2011 3:48 AM
> To: Sam Harwell; antlr-interest@antlr.org
> Subject: Re: Have I found an Antlr CSharp3 lexer bug if...
> 
>  
> 
> Sam, while trying build my pre-processor with a mixed parser/lexer I ran 
> across what I think might be a bug. I reduced the repro below. I expected the 
> program below to accept "/**/ " but instead fails because the lexer 
> prediction enters PP_SKIPPED_CHARACTERS. That rule has a gated semantic 
> predicate which is always false. I expected a lexer rule with a gated 
> semantic predicate which is always false to never be matched. If I comment 
> out the PP_SKIPPED_CHARACTERS rule then it does match "/**/ ". So the 
> inclusion of that rule is cause the problem. Let me know if you think this is 
> a bug and if you can repro.
> 
>  
> 
> Thanks,
> Chris
> 
>  
> 
> grammar Bug; 
> 
>  
> 
> options {
> 
>language=CSharp3;
> 
>output=AST;
> 
> }
> 
>  
> 
> public start
> 
>   : DELIMITED_COMMENT !EOF
> 
>   ;
> 
>   
> 
> PP_SKIPPED_CHARACTERS
> 
>   : { false }? => ~(F_NEW_LINE_CHARACTER | F_PP_POUND_SIGN) F_INPUT_CHARACTER*
> 
>   ;
> 
>   
> 
> DELIMITED_COMMENT
> 
>   : { true }? => '/*' .* '*/'
> 
>   ;
> 
>   
> 
> WHITESPACE
> 
>   : F_WHITESPACE {skip();}
> 
>   ;
> 
>   
> 
> fragment F_WHITESPACE
> 
>   : (' ' | '\t' | '\v' | '\f')+ 
> 
>   ;
> 
>  
> 
> fragment F_NEW_LINE_CHARACTER
> 
>   : '\r'
> 
>   | '\n'
> 
>   ;
> 
>   
> 
> fragment F_PP_POUND_SIGN
> 
>   : '#'
> 
>   ;
> 
>   
> 
> fragment F_INPUT_CHARACTER
> 
>   : ~F_NEW_LINE_CHARACTER
> 
>   ;

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-inter...@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: 33491] Re: [antlr-interest] Are the Eclipse ANTLR plugins stable?

2011-08-04 Thread The Researcher
Stephen,

Thanks for the response.

An appliance is a application that can run as a virtual machine. I am making
one for people just learning ANTLR but that have trouble installing the
various components, or possibly in classroom use. Think VMware or Virtual
Box.

Since posing the question I checked the licenses and only ANTLR IDE can be
used.

One interesting thing is that Eclipse is up to version 3.7 (Indigo) but as
you note ANTLR IDE has not been updated. Its latest version is for Eclipse
3.6 (Helios).

I have never used it, but your notes will be of value when I document using
it.

Thanks

Eric

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-inter...@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: 33492] [antlr-interest] Line oriented parsing with Unix files on Windows machine

2011-08-04 Thread Stevenson, Todd (GE Healthcare)
I have a line-oriented grammar that uses the following rule to define an
end of line:

 

EOL : ('\r' | '\n')+;

 

My grammar parses input files fine when they are in windows format
(lines end with '\r\n'), however the parser doesn't work when the input
files are in unix format (lines end with '\n' only).  It seems to ignore
the new line character and attach it to the subsequent rule.   Is there
something I need to do the process these files correctly?  Any ideas?

 

Thanks.

 

 

 

 


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-inter...@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: 33493] [antlr-interest] Looking for an example of tree walking using push/pop

2011-08-04 Thread Janet.Hurwitz
Hello- I'm working on a grammar that has nested subtrees. I am successfully 
parsing the input to create the AST, but am having trouble navigating the tree 
to build the structure my Java program needs. The output is a 
HashMap.  When it's not a leaf node, the Object in the map will 
be a HashMap. Can you point me to some examples of more 
complicated tree walkers than the ones I've been able to find? I have been 
though the video tutorial as well. Thanks in advance.



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-inter...@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: 33494] Re: [antlr-interest] Looking for an example of tree walking using push/pop

2011-08-04 Thread Jeff Hair
This has an example of how to go down the AST and then back up.

http://www.antlr.org/wiki/display/ANTLR3/Tree+pattern+matching

This is a concrete example of the method on the wiki. I used it in my
experiment about learning how to make an interpreter. EveCore calls the
downup method. The .g file is the grammar, of course.

https://github.com/ProjectMoon/eve2/blob/master/src/eve/core/EveCore.java#L227
https://github.com/ProjectMoon/eve2/blob/master/src/eve/core/ASTParser.g

On Thu, Aug 4, 2011 at 3:48 PM,  wrote:

> Hello- I'm working on a grammar that has nested subtrees. I am successfully
> parsing the input to create the AST, but am having trouble navigating the
> tree to build the structure my Java program needs. The output is a
> HashMap.  When it's not a leaf node, the Object in the map
> will be a HashMap. Can you point me to some examples of more
> complicated tree walkers than the ones I've been able to find? I have been
> though the video tutorial as well. Thanks in advance.
>
>
>
> 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-inter...@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: 33495] Re: [antlr-interest] Line oriented parsing with Unix files on Windows machine

2011-08-04 Thread Bart Kiers
Hi Todd,

Well, `EOL : ('\r' | '\n')+;` matches a single `\n`. So my guess is that
some other  rule in your grammar matches a `\n` as well. Can you post a
complete (small) grammar that shows the problem you're having?

Regards,

Bart.


On Thu, Aug 4, 2011 at 8:37 PM, Stevenson, Todd (GE Healthcare) <
todd.t.steven...@ge.com> wrote:

> I have a line-oriented grammar that uses the following rule to define an
> end of line:
>
>
>
> EOL : ('\r' | '\n')+;
>
>
>
> My grammar parses input files fine when they are in windows format
> (lines end with '\r\n'), however the parser doesn't work when the input
> files are in unix format (lines end with '\n' only).  It seems to ignore
> the new line character and attach it to the subsequent rule.   Is there
> something I need to do the process these files correctly?  Any ideas?
>
>
>
> Thanks.
>
>
>
>
>
>
>
>
>
>
> 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-inter...@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: 33497] Re: [antlr-interest] To Sam Harwell

2011-08-04 Thread Sam Harwell
Hi Chris,

In build 3.4.1.9004 that I released today, I switched all the projects to
using $(ProjectDir) with relative paths.

http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases

Sam

-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of chris king
Sent: Monday, July 25, 2011 6:39 PM
To: antlr-interest@antlr.org
Subject: [antlr-interest] To Sam Harwell

Sam, hey, hope this finds you. Very small suggestion follows :). In
Antlr3.StringTemplate.csproj could you use


$(MSBuildProjectDirectory)\..\bin\Bootstrap

to reference the bootstrap directory? Originally it used the solutionDir and
that prevented me from including a subset of the projects in my project (so
I could simply reference them and have all the debugging, pdb, source, etc
just work).

Thanks,
Chris

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-inter...@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: 33498] Re: [antlr-interest] To Sam Harwell

2011-08-04 Thread chris king
Awesome! I'll give it try. Did you see my follow up email that the parse
string is 5 characters (there is a trailing space)? "/**/ "

And again, love the tool chain. I only really started to get traction on my
project after I installed it. It's working great.

Thanks,
Chris

On Thu, Aug 4, 2011 at 4:34 PM, Sam Harwell wrote:

> Hi Chris,
>
> In build 3.4.1.9004 that I released today, I switched all the projects to
> using $(ProjectDir) with relative paths.
>
> http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases
>
> Sam
>
> -Original Message-
> From: antlr-interest-boun...@antlr.org
> [mailto:antlr-interest-boun...@antlr.org] On Behalf Of chris king
> Sent: Monday, July 25, 2011 6:39 PM
> To: antlr-interest@antlr.org
> Subject: [antlr-interest] To Sam Harwell
>
> Sam, hey, hope this finds you. Very small suggestion follows :). In
> Antlr3.StringTemplate.csproj could you use
>
>
>
> $(MSBuildProjectDirectory)\..\bin\Bootstrap askPath>
>
> to reference the bootstrap directory? Originally it used the solutionDir
> and
> that prevented me from including a subset of the projects in my project (so
> I could simply reference them and have all the debugging, pdb, source, etc
> just work).
>
> Thanks,
> Chris
>
> 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-inter...@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: 33499] [antlr-interest] Another (hopefully easy) newby question

2011-08-04 Thread Scott Smith
I have created a parser/lexer.  When I run it as a standard parser (no ASTs), 
it runs fine.  I've verified with the debugger, that it generates a reasonable 
tree.

But, I want to run it to generate ASTs.  So, I modified the code to do that 
(using ^ to promote operators and ! to eliminate some things).  I believe that 
is working just fine as well.

So, here's the problem.  My test harness looks like:

  String filename = ".\\somefile.txt";
  CharStream stream = new ANTLRFileStream(filename);
MyFilterLexer lexer = new MyFilterLexer(stream);
TokenStream tokenStream = new CommonTokenStream(lexer);
  MyFilterParser parser = new MyFilterParser(tokenStream);
  filter_return f = parser.filter();
  System.out.println(f.getTree().toString());

I want the print out to display the AST version of the parsed data.  I know it 
exists (at least mostly) because I can modify the top level parser item in my 
combined grammer as follows:

filter:
  FQ '='^ filter_expr EOF!
{
  if ($filter_expr.tree != null)
System.out.println($filter_expr.tree.toStringTree());
  else
System.out.println("must be null");
}
  ;

This compiles and does display (almost all) the ASTs as I would expect.  Note 
that it is referencing the "filter_expr" and not the "filter".  It does not 
display the "(= FQ" but the rest of my ASTs appear to be properly parsed and 
ordered.  If I change to use $filter instead, then I get the "must be null" 
message.

Isn't there a way to display the string of ASTs from the filter_return object?  
Scott Stanchfield's video would say you could do 
"System.out.println(f.tree.getStringTree());", but that doesn't compile with 
Antlr 3.4.

If I run the harness as I have it above, it simply prints "=".

What am I missing?

Thanks

Scott


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-inter...@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: 33500] Re: [antlr-interest] Another (hopefully easy) newby question

2011-08-04 Thread John B. Brodie
On Fri, 2011-08-05 at 01:15 +, Scott Smith wrote:
> I have created a parser/lexer.  When I run it as a standard parser (no ASTs),
> it runs fine.  I've verified with the debugger, that it generates a 
> reasonable tree.
> 
> But, I want to run it to generate ASTs.  So, I modified the code to do that
> (using ^ to promote operators and ! to eliminate some things).  I believe that
> is working just fine as well.
> 
> So, here's the problem.  My test harness looks like:
> 
>   String filename = ".\\somefile.txt";
>   CharStream stream = new ANTLRFileStream(filename);
> MyFilterLexer lexer = new MyFilterLexer(stream);
> TokenStream tokenStream = new CommonTokenStream(lexer);
>   MyFilterParser parser = new MyFilterParser(tokenStream);
>   filter_return f = parser.filter();
>   System.out.println(f.getTree().toString());
> 
> I want the print out to display the AST version of the parsed data.  I know it
> exists (at least mostly) because I can modify the top level parser item in my
> combined grammer as follows:
> 
> filter:
>   FQ '='^ filter_expr EOF!
> {
>   if ($filter_expr.tree != null)
> System.out.println($filter_expr.tree.toStringTree());
>   else
> System.out.println("must be null");
> }
>   ;
> 
> This compiles and does display (almost all) the ASTs as I would expect.  Note 
> that
> it is referencing the "filter_expr" and not the "filter".  It does not 
> display the
> "(= FQ" but the rest of my ASTs appear to be properly parsed and ordered.  If 
> I
> change to use $filter instead, then I get the "must be null" message.

when using the ^ and/or ! meta-operators, the result tree is not created
until the end of the rule.

technically your printing action is not at the end of the rule because
stuff could appear after that action.

put your print code in the rule's @after{...} section and a reference to
the rulename.tree will not be null.

> 
> Isn't there a way to display the string of ASTs from the filter_return 
> object? 
> Scott Stanchfield's video would say you could do 
> "System.out.println(f.tree.getStringTree());",
> but that doesn't compile with Antlr 3.4.
> 
> If I run the harness as I have it above, it simply prints "=".
> 

the toString() method of CommonTree does not recurse into the tree's
children (if any). so that is why you see just the root node printed by
your driver.

need to use the toStringTree() method in your driver in order to get the
entire tree printed --- just as you did in your rule's printing action.




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-inter...@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.