[antlr-interest] Backtracking and labels

Jim Idle jimi at temporal-wave.com
Mon Mar 19 19:44:04 PDT 2012


I have not had much time to look at anything recently, but I'll try and
look at this and a few other issues soon.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Kieran Simpson
> Sent: Monday, March 19, 2012 6:00 PM
> To: Eric
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Backtracking and labels
>
> Eric (and list),
>    I could revert back to Antlr 3.3 however I feel like I'm very close
> to fixing this bug for 3.4 which would help a lot of people.
>
> I made a few mistakes with my initial port and have corrected them and
> pushed to my Git Hub repo if you or anyone else wants to have a look.
>
> I think the one remaining problem is that variable types are now being
> ommitted from the resulting code which is the cause of the C compiler
> errors.  For example:
>
> static void
> synpred8_CoreConfiguration_fragment(pCoreConfigurationParser
> ctx )
> {
> 	pANTLR3_COMMON_TOKEN    value;
>
>
> 	value       = NULL;
>
> 	value_tree   = NULL;
>
>
> 	retval.tree  = NULL;
>
>          // rest of function
> }
>
> value, value_tree and retval have not been given types, hence the
> compiler errors.
>
> There are other errors of the generated code that are missing types
> however my assumption is that the cause is the same as the above
> example.
>
> If it's possible for Jim or another C target knowledgeable person to
> take a quick look they might be able to spot the reason in the
> templates
> quicker than it'll take me to figure it out (if I can figure it out :p)
>
> Cheers,
>
> On 19/03/12 1:24 AM, Eric wrote:
> >
> > Hi Kieran,
> > I looked at the github files and see that you are working with the C
> > target. I have never worked with the C target, that is Jim Idle's
> world.
> > I also noticed that you mention the grammar works with ANTLR 3.3 but
> > that you want to use ANTLR 3.4. If it were me and the grammar worked
> > with ANTLR 3.3, I would skip the path of trying to fix ANTLR 3.4; you
> > will learn a lot by trying to fix ANTLR 3.4 but will you actually be
> > productive on your ultimate goal? I have spent time modifying ANTLR
> to
> > extend for parsing binary files; learned a lot but all of the changes
> > went to bit heaven.
> > If there is something in the grammar forcing you to use 3.4, I would
> > take the easier route and see if I could modify the grammar to work
> with
> > 3.4 as is or 3.3.
> > One of the ways I view a grammar is as a high level language for
> > parsing. If I can't define what I need through the grammar, I use
> > actions. Think of a grammar as a high level language and actions as
> > assembly language. It is amazing how much you can do with actions.
> > Remember all parts of a grammar, including predicates are translated
> > into the target language. Instead of trying to patch ANTLR to use a
> > predicate, just recreate the predicate using actions; it should be
> > easier than fixing ANTLR for someone who doesn't understand all of
> > ANTLRs internals.I don't even understand all of ANTLRs internals.
> > Hope that helps,
> > Eric
> > On Sun, Mar 18, 2012 at 4:21 AM, Kieran Simpson <kierans777 at gmail.com
> > <mailto:kierans777 at gmail.com>> wrote:
> >
> >     Eric (and list)
> >
> >     I had a shot at porting Sam's fixes to the C target.  While it
> does
> >     indeed fix the label generation issue (yay!), it unfortunately
> >     introduces a number of other changes which results in
> uncompilable
> >     code :'( :'(
> >
> >     I've forked the antlr3 repo at
> https://github.com/kierans/__antlr3
> >     <https://github.com/kierans/antlr3> and pushed up my current
> >     changes.  If anyone has any suggestions (or wishes to fork and
> add
> >     some patches) they're more than welcome.  With some more tweaking
> >     hopefully this bug will go away :D
> >
> >     Cheers,
>
> 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