[antlr-interest] anybody help with me a python grammar rule?

Terence Parr parrt at cs.usfca.edu
Sat Feb 21 18:29:01 PST 2004


For example, won't this rule generate the same language?

parameter_list:
     defparameter (',' defparameter)*
     ( ','
       ('*' NAME [',' '**' NAME]       | '**' NAME
       )
     )
  | '*' NAME [',' '**' NAME]
  | '**' NAME

and it's LL(1).

arglist has the same problem.  I wonder what kinda parser they build 
from this grammar.  Ick.

Ter

On Feb 21, 2004, at 6:10 PM, Terence Parr wrote:

> Folks, the formal parameter list for functions looks wacky in the
> distribution and on the net.
>
> First the grammar in the distribution:
>
> varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**'
> NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']
> fpdef: NAME | '(' fplist ')'
> fplist: fpdef (',' fpdef)* [',']
>
> The one from the doc is
>
> parameter_list ::=
>               (defparameter ",")*
>                  ("*" identifier [, "**" identifier]
>                  | "**" identifier
>                    | defparameter [","])
>
> defparameter ::=
>               parameter ["=" expression]
>
> sublist ::=
>               parameter ("," parameter)* [","]
>
> parameter ::=
>               identifier | "(" sublist ")"
>
> My question here is why have the final '| defparameter [","]' alt in
> parameter_list????  Surely it's redundant (might have to move a comma,
> but...)
>
> Can anybody give me some examples of the various things parameters
> might look like in the wacky cases?
>
> Thanks!
>
> --
> Professor Comp. Sci., University of San Francisco
> Creator, ANTLR Parser Generator, http://www.antlr.org
> Cofounder, http://www.jguru.com
> Cofounder, http://www.knowspam.net enjoy email again!
> Cofounder, http://www.peerscope.com pure link sharing
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Cofounder, http://www.peerscope.com pure link sharing





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list