22 | 22 |
Multi-character terminals.
|
23 | 23 |
|
24 | 24 |
Goal ::= "foo" "bar";
|
25 | |
===> Grammar [("Goal",[],Alt [Seq [Seq [Terminal 'f',Terminal 'o',Terminal 'o'],Seq [Terminal 'b',Terminal 'a',Terminal 'r']]])]
|
|
25 |
===> Grammar [("Goal",[],Alt [Seq [Terminal 'f',Terminal 'o',Terminal 'o',Terminal 'b',Terminal 'a',Terminal 'r']])]
|
26 | 26 |
|
27 | 27 |
Alternation and recursion.
|
28 | 28 |
|
|
47 | 47 |
|
48 | 48 |
Goal ::= "Hi" Sp<a> "there" Sp<b> "world" "!";
|
49 | 49 |
Sp<n> ::= <. n = 0 .> { " " <. n += 1 .> } <. n > 0 .>;
|
50 | |
===> Grammar [("Goal",[],Alt [Seq [Seq [Terminal 'H',Terminal 'i'],NonTerminal "Sp" [Var "a"],Seq [Terminal 't',Terminal 'h',Terminal 'e',Terminal 'r',Terminal 'e'],NonTerminal "Sp" [Var "b"],Seq [Terminal 'w',Terminal 'o',Terminal 'r',Terminal 'l',Terminal 'd'],Terminal '!']]),("Sp",[Var "n"],Alt [Seq [Constraint (UnifyConst (Var "n") 0),Loop (Alt [Seq [Terminal ' ',Constraint (Inc (Var "n") (CInt 1))]]) [],Constraint (GreaterThan (Var "n") (CInt 0))]])]
|
|
50 |
===> Grammar [("Goal",[],Alt [Seq [Terminal 'H',Terminal 'i',NonTerminal "Sp" [Var "a"],Terminal 't',Terminal 'h',Terminal 'e',Terminal 'r',Terminal 'e',NonTerminal "Sp" [Var "b"],Terminal 'w',Terminal 'o',Terminal 'r',Terminal 'l',Terminal 'd',Terminal '!']]),("Sp",[Var "n"],Alt [Seq [Constraint (UnifyConst (Var "n") 0),Loop (Alt [Seq [Terminal ' ',Constraint (Inc (Var "n") (CInt 1))]]) [],Constraint (GreaterThan (Var "n") (CInt 0))]])]
|
51 | 51 |
|
52 | 52 |
Comments.
|
53 | 53 |
|
|
61 | 61 |
//
|
62 | 62 |
// There are many ways to place comments.
|
63 | 63 |
"//";
|
64 | |
===> Grammar [("Goal",[],Alt [Seq [Seq [Terminal 'f',Terminal 'o',Terminal 'o']]]),("A",[],Alt [Seq [Terminal 'f',Terminal 'o',Seq [Terminal '/',Terminal '/']]])]
|
|
64 |
===> Grammar [("Goal",[],Alt [Seq [Terminal 'f',Terminal 'o',Terminal 'o']]),("A",[],Alt [Seq [Terminal 'f',Terminal 'o',Terminal '/',Terminal '/']])]
|
65 | 65 |
|
66 | 66 |
Misplaced semicolon is a syntax error.
|
67 | 67 |
|