On Wed, 2008-10-15 at 21:11 -0500, Shaun Bogan wrote: > Is anyone aware of an example for the C target that doesn't use a tree > parser. I prefer to walk the AST myself for my application. I've had > considerable luck using the C# target, but the C target seems to elude > me. I can't even do simple things like print out the text of a node, > etc. If anyone has an example that would help me greatly. Unless I > missed one, none of the examples in the downloads section walk the > tree manually.
Well, if you have worked out how to walk the tree manually in C# there is really little difference in C. A good way to find out things is to use VS 2008 and just type '->', which gives you all the 'methods' and which you will find are pretty much exactly the same, other than being nX faster. The C source code also shows you how to do so, but where are you having problems getting started? It might be easier to help if I know what you are trying to do as walking the tree manually is just a few (i =0; ... and getChild() calls. For instance a good example in the 3.1.1 source is the methods that produce a .dot spec of any tree. The codes is about 40 lines worth. I may also be guilty of assuming that anyone using my C target is willing to dive in to the sources and so on, but I have tried to document the code :-) Jim > > Thanks, > Shaun Bogan > > On Wed, Oct 15, 2008 at 2:00 PM, <[EMAIL PROTECTED]> wrote: > > Send antlr-interest mailing list submissions to > > [EMAIL PROTECTED] > > > > To subscribe or unsubscribe via the World Wide Web, visit > > http://www.antlr.org:8080/mailman/listinfo/antlr-interest > > or, via email, send a message with subject or body 'help' to > > [EMAIL PROTECTED] > > > > You can reach the person managing the list at > > [EMAIL PROTECTED] > > > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of antlr-interest digest..." > > > > > > Today's Topics: > > > > 1. Re: Understanding ANTLR's 'multiple alternatives' (Gavin Lambert) > > 2. Re: VS2008 Integration Example (Gavin Lambert) > > 3. Re: VS2008 Integration Example (Sam Harwell) > > 4. is there any good example can change prolog to .dot file by > > antlr? (Su Zhang) > > 5. Problem with multiple treeparser ... (LdK ^^) > > > > > > ---------------------------------------------------------------------- > > > > Message: 1 > > Date: Wed, 15 Oct 2008 09:13:53 +1300 > > From: Gavin Lambert <[EMAIL PROTECTED]> > > Subject: Re: [antlr-interest] Understanding ANTLR's 'multiple > > alternatives' > > To: `VL <[EMAIL PROTECTED]>, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> > > Message-ID: <[EMAIL PROTECTED]> > > Content-Type: text/plain; charset="us-ascii"; format=flowed > > > > At 07:54 15/10/2008, `VL wrote: > > >Hmm. This looks better. But it doesn't match construction > > >like this: $(VAR)/some/path. > > > > That's a different form than what you were showing before :) > > > > To match that, you can treat them all as equals: > > > > PATH : ('/' | ENVAR | ID | INT)+; > > > > Of course, this no longer guarantees that there is a '/' present > > at all. > > > > Another option specifically for the leading-ENVAR case (basically > > assuming that all paths must be absolute, but the base path may be > > contained in an ENVAR): > > > > PATH : ENVAR? ('/' (ID | INT)*)+; > > > > > > You do need to be careful you're not doing too much work in the > > lexer, though. Remember that the lexer is context-free, and all > > top-level rules are always candidates to match the input. You may > > therefore end up with a different token type than you're > > expecting, if there is overlap between the token rules. > > > > > > > > ------------------------------ > > > > Message: 2 > > Date: Wed, 15 Oct 2008 09:22:53 +1300 > > From: Gavin Lambert <[EMAIL PROTECTED]> > > Subject: Re: [antlr-interest] VS2008 Integration Example > > To: "Sam Harwell" <[EMAIL PROTECTED]>, Andr? van der Merwe > > <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> > > Message-ID: <[EMAIL PROTECTED]> > > Content-Type: text/plain; charset="us-ascii"; format=flowed > > > > At 05:28 15/10/2008, Sam Harwell wrote: > >>Here's how you can get the Clean and Rebuild tasks working as > >>well. If you delete the .tokens files associated with each > >>grammar, then the grammar will get properly rebuilt: > >> > >><PropertyGroup> > >> > >><CoreCleanDependsOn>$(CoreCleanDependsOn);CleanAntlrCode</CoreCleanDependsOn> > >></PropertyGroup> > >><Target Name="CleanAntlrCode"> > >> <ItemGroup> > >> <_CleanAntlrFileWrites > >> Include="@(Antlr3->'%(RelativeDir)%(Filename).tokens')" /> > >> </ItemGroup> > >> <Message Importance="normal" Text="Antlr: Deleting > >> output files '@(_CleanAntlrFileWrites)'" /> > >> <Delete Files="@(_CleanAntlrFileWrites)" /> > >></Target> > > > > Wouldn't it be better to remove all the output files, not just the > > .tokens file? You should be able to do that by using this line > > instead (though I haven't tested it): > > > > <Delete Files="%(Antlr3.OutputFiles)" /> > > > > > > > > ------------------------------ > > > > Message: 3 > > Date: Tue, 14 Oct 2008 15:25:01 -0500 > > From: "Sam Harwell" <[EMAIL PROTECTED]> > > Subject: Re: [antlr-interest] VS2008 Integration Example > > To: "Gavin Lambert" <[EMAIL PROTECTED]>, Andr? van der Merwe > > <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> > > Message-ID: > > <[EMAIL PROTECTED]> > > Content-Type: text/plain; charset="iso-8859-1" > > > > Delete doesn't properly handle ; delimited lists of files. :( Plus we check > > the generated .cs files into Perforce so it's good to have them around (in > > our case). > > > > Sam > > > > -----Original Message----- > > From: Gavin Lambert [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, October 14, 2008 3:23 PM > > To: Sam Harwell; Andr? van der Merwe; [EMAIL PROTECTED] > > Subject: RE: [antlr-interest] VS2008 Integration Example > > > > At 05:28 15/10/2008, Sam Harwell wrote: > >>Here's how you can get the Clean and Rebuild tasks working as > >>well. If you delete the .tokens files associated with each > >>grammar, then the grammar will get properly rebuilt: > >> > >><PropertyGroup> > >> > >><CoreCleanDependsOn>$(CoreCleanDependsOn);CleanAntlrCode</CoreCleanDependsOn> > >></PropertyGroup> > >><Target Name="CleanAntlrCode"> > >> <ItemGroup> > >> <_CleanAntlrFileWrites > >> Include="@(Antlr3->'%(RelativeDir)%(Filename).tokens')" /> > >> </ItemGroup> > >> <Message Importance="normal" Text="Antlr: Deleting > >> output files '@(_CleanAntlrFileWrites)'" /> > >> <Delete Files="@(_CleanAntlrFileWrites)" /> > >></Target> > > > > Wouldn't it be better to remove all the output files, not just the > > .tokens file? You should be able to do that by using this line > > instead (though I haven't tested it): > > > > <Delete Files="%(Antlr3.OutputFiles)" /> > > > > > > > > ------------------------------ > > > > Message: 4 > > Date: Tue, 14 Oct 2008 18:18:01 -0700 > > From: "Su Zhang" <[EMAIL PROTECTED]> > > Subject: [antlr-interest] is there any good example can change prolog > > to .dot file by antlr? > > To: [EMAIL PROTECTED] > > Message-ID: > > <[EMAIL PROTECTED]> > > Content-Type: text/plain; charset="iso-8859-1" > > > > question is the same as subject > > -------------- next part -------------- > > An HTML attachment was scrubbed... > > URL: > > http://www.antlr.org:8080/pipermail/antlr-interest/attachments/20081014/c522c87f/attachment-0001.html > > > > ------------------------------ > > > > Message: 5 > > Date: Wed, 15 Oct 2008 20:56:16 +0200 > > From: "LdK ^^" <[EMAIL PROTECTED]> > > Subject: [antlr-interest] Problem with multiple treeparser ... > > To: [EMAIL PROTECTED] > > Message-ID: > > <[EMAIL PROTECTED]> > > Content-Type: text/plain; charset="iso-8859-1" > > > > Hi, > > I have a problem when i use multiple treeparser, > > the first is in same file that the parser > > but the second is in a other file and i always get an "" when i make a > > get.text() in this tree parser > > so i dont uderstand, are there any options to share informations ??? > > thx a lot, > > > > Herve > > -------------- next part -------------- > > An HTML attachment was scrubbed... > > URL: > > http://www.antlr.org:8080/pipermail/antlr-interest/attachments/20081015/852c2d6f/attachment-0001.html > > > > ------------------------------ > > > > _______________________________________________ > > antlr-interest mailing list > > [EMAIL PROTECTED] > > http://www.antlr.org:8080/mailman/listinfo/antlr-interest > > > > > > End of antlr-interest Digest, Vol 47, Issue 15 > > ********************************************** > > > > List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org:8080/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 [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
