Perl 6 Perl 6 #40

Parsing example

if                -- "if" keyword
  a == 4          -- an expression
then              -- "then" keyword
  print "Hello";  -- a statement

Our general pattern for an if statement is

"if"  <expression>   "then"  <statement>

As a BNF grammar, we might say

if_stmt ::=
    'if' expression 'then' statement
continued...
Copyright © 2008 Patrick Michaud