On Tue, Oct 6, 2009 at 4:18 PM, Kaleb Pederson <[email protected]> wrote: > On Tuesday 06 October 2009 03:15:05 am Graham Wideman wrote: >> Hi folks: >> >> I see in the ANTLR grammar that you can place a BANG (exclamation point) >> after the initial rule id in a rule. Indeed it's used in the ANTLR v3 >> grammar itself: >> >> ---------------------------- >> range! >> : c1=CHAR_LITERAL RANGE c2=CHAR_LITERAL elementOptions? >> -> ^(CHAR_RANGE[$c1,".."] $c1 $c2 elementOptions?) >> ; >> ---------------------------- >> >> Could someone illuminate what this ! does? > > The exclamation mark is placed on a node when that node should not be present > in the AST when output=AST for a grammar. > > See: > > http://jnb.ociweb.com/jnb/jnbJun2008.html#CreatingASTs > http://www.antlr.org/wiki/display/ANTLR3/Tree+construction >
Kaleb, Neither of your example sites talk about what he is discussing. It isn't applied to a node, it is applied to a rule definition/declaration, not to a rule invoked as part of the production of a rule. I checked every '!' in those links and none of them mention are used like that, or as far as I can tell have a usage similarly. I don't know much about ANTLRv2, but I thought the ANTLRv3 wasn't self hosting, so the grammar for ANTLRv3 was written in ANTLRv2. Or at least that was the case during the early parts of ANTLRv3. Graham, you might try researching ANTLRv2 and see what it does. I'm guessing that this is mostly likely what you are looking for, assuming that I'm correct and the grammar you are looking at is really an ANTLRv2 grammar: http://www.antlr2.org/doc/lexer.html#Manipulating_Token_Text_and_Objects Kirby 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 [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 -~----------~----~----~----~------~----~------~--~---
