[antlr-interest] White space needed in the parsing.

jack zhang jackgzhang2 at yahoo.com
Thu Sep 18 16:38:14 PDT 2008


Thanks for pointing this out. I am reading 12-1.

--- On Thu, 9/18/08, Markus Fröb <grey_earl at web.de> wrote:
From: Markus Fröb <grey_earl at web.de>
Subject: Re: [antlr-interest] White space needed in the parsing.
To: antlr-interest at antlr.org
Date: Thursday, September 18, 2008, 3:05 PM

> -----Ursprüngliche Nachricht-----
> Von: "jack zhang" <jackgzhang2 at yahoo.com>
> Gesendet: 18.09.08 23:58:03
> An: antlr-interest at antlr.org
> Betreff: Re: [antlr-interest] White space needed in the parsing.

> 
> 
> Thx. In this case, what does => and -> means?
> I guess -> means it will will be matched in the TreeWalker's rule :
(
> Something like:)
> 

-> means give the following tree as result of the (parser) rule. So it will
be matched in the TreeWalker's rule for a simple lexer-parser-treewalker
grammar, right.
=> is a syntactic predicate and means: match the following only if you see
this in advance, i.e. (abc) => def means match def only if you see abc. This
is useful to resolve ambiguities in a grammar at the cost of slowing down the
parsing (read the Definitive ANTLR Handbook on this, it's very well
explained there).

> 
> expr returns [String s]
>  : ^(STRING[$text]) {s=$test;}
> 
> Is that correct ?
> Then what does 
> (WORD+)=>WORD+ 
> 
> means?

So this means, if the parser sees some words it should match the words. It is
absolutly unnecessary for this grammar, imho, since there are no ambiguities.

> 
> Thx !
> --- On  *Thu, 9/18/08, $B8~2m(B *<fyaoxy at gmail.com> wrote:
> From: $B8~2m(B <fyaoxy at gmail.com>
> Subject: Re: [antlr-interest] White space needed in the parsing.
> To: jackgzhang2 at yahoo.com
> Cc: antlr-interest at antlr.org
> Date: Thursday, September 18, 2008, 2:42 PM
> 
> Hi,
> If you have AST, you would wanna this in parser:
> string : ( (WORD+)=>WORD+ | SingleQSTRING |
> DoubleQSTRING)->^(STRING[$text]);
> 
> hope this make happy.
> 

_________________________________________________________________________
In 5 Schritten zur eigenen Homepage. Jetzt Domain sichern und gestalten! 
Nur 3,99 EUR/Monat! http://www.maildomain.web.de/?mc=021114


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080918/1bc8dd7b/attachment.html 


More information about the antlr-interest mailing list