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

Markus Fröb grey_earl at web.de
Thu Sep 18 15:05:14 PDT 2008


> -----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



More information about the antlr-interest mailing list