[antlr-interest] To Sam Harwell

Sam Harwell sharwell at pixelminegames.com
Tue Aug 9 17:02:16 PDT 2011


Hi Chris,

 

I got rid of the use of Stack<T> and the call to ElementAt() quite a while
back. Instead I use a ListStack<T> which derives from List<T> and adds Push
and Pop methods. I recommend updating to ANTLR 3.4.1 to correct this issue.

 

Sam

 

From: chris king [mailto:kingces95 at gmail.com] 
Sent: Tuesday, August 09, 2011 6:29 PM
To: Sam Harwell; antlr-interest at antlr.org
Subject: Re: [antlr-interest] To Sam Harwell

 

Sam, hey, so I might have bumped into a code gen bug. I'm trying to access a
variable "skipSection" on the parent production of "pp_conditional". It
looks like the generated code is doing some computation involving the stack
count when really it should just pass my index without any calculation. For
example, below, shouldn't the highlighted code simply be my index? Or am I
missing something? Looks like the highlighted code is assuming TOS is Count
- 1 (like it would be with a stack implemented with a List<T>) but I don't
think that's the case. The stack is a System.Collections.Generic.Stack<T>
which maintains that TOS is always index 0. 

 

$pp_conditional[1]::skipSection

 

The code above is transformed to:

 

System.Linq.Enumerable.ElementAt(pp_conditional_stack,
pp_conditional_stack.Count-1-1).skipSection;

 

Also, you may want to ensure that all user expressions are enclosed in
parens. As I was trying to work around this issue I used "count -2" which
got translated to stack.Count-count -2 -1. I had to add the parens to get it
to be stack.Count-(count -2) -1.

 

Thanks,

Chris

 

On Thu, Aug 4, 2011 at 6:00 PM, chris king <kingces95 at gmail.com> wrote:

Ok. Thanks for looking into it. 

 

On Thu, Aug 4, 2011 at 5:56 PM, Sam Harwell <sharwell at pixelminegames.com>
wrote:

I did, and I can repro the issue but I haven't resolved it yet.

 

Sam

 

From: chris king [mailto:kingces95 at gmail.com] 
Sent: Thursday, August 04, 2011 6:48 PM
To: Sam Harwell
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] To Sam Harwell

 

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 <sharwell at pixelminegames.com>
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-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of chris king
Sent: Monday, July 25, 2011 6:39 PM
To: antlr-interest at 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


<AntlrBuildTaskPath>$(MSBuildProjectDirectory)\..\bin\Bootstrap</AntlrBuildT
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

 

 

 



More information about the antlr-interest mailing list