Python on Parrot Python on Parrot - under the hood #44

Parsing Python's indent rules

if_stmt   ::= "if" expression ":" suite
              ( "elif" expression ":" suite )*
              [ "else" ":" suite ]

In PGE:

rule if_stmt {
    <'if'> <expression> <':'> <suite>
    [ <'elif'> <expression> <':'> <suite> ]*
    [ <'else'> <':'> <suite> ]?
}
Copyright © 2007 Patrick Michaud