Created
February 4, 2011 20:05
-
-
Save tene/811670 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar eria::Grammar is HLL::Grammar; | |
token TOP { | |
<statementlist> | |
} | |
rule statementlist { <affectation>+ } | |
rule affectation { | |
<declaration> ':=' <EXPR> ';' | |
} | |
token term:sym<integer> { <integer> } | |
token term:sym<id> { <id> } | |
INIT { | |
eria::Grammar.O(':prec<u>, :assoc<left>', '%additive'); | |
} | |
token infix:sym<+> { <sym> <O('%additive')>} | |
rule integer { | |
<digit>+ | |
} | |
rule declaration { | |
'number' <id> | |
} | |
rule id { | |
\w+ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[sweeks@sweeks-laptop eria2]$ echo 'number x := 1 + 2 + 3 + 4;' > add.eria | |
[sweeks@sweeks-laptop eria2]$ parrot eria.pbc --target=parse add.eria | |
"parse" => PMC 'Regex;Match' => "number x := 1 + 2 + 3 + 4;\n" @ 0 { | |
<statementlist> => PMC 'Regex;Match' => "number x := 1 + 2 + 3 + 4;\n" @ 0 { | |
<affectation> => ResizablePMCArray (size:1) [ | |
PMC 'Regex;Match' => "number x := 1 + 2 + 3 + 4;\n" @ 0 { | |
<declaration> => PMC 'Regex;Match' => "number x " @ 0 { | |
<id> => PMC 'Regex;Match' => "x " @ 7 | |
} | |
<EXPR> => PMC 'Regex;Match' => "+" @ 22 { | |
<OPER> => PMC 'Regex;Match' => "+" @ 22 { | |
<sym> => PMC 'Regex;Match' => "+" @ 22 | |
<O> => Hash { | |
"assoc" => "left", | |
"prec" => "u" | |
} | |
} | |
<infix> => \parse[0] | |
[0] => PMC 'Regex;Match' => "+" @ 18 { | |
<OPER> => PMC 'Regex;Match' => "+" @ 18 { | |
<sym> => PMC 'Regex;Match' => "+" @ 18 | |
<O> => \parse[0] | |
} | |
<infix> => \parse[0] | |
[0] => PMC 'Regex;Match' => "+" @ 14 { | |
<OPER> => PMC 'Regex;Match' => "+" @ 14 { | |
<sym> => PMC 'Regex;Match' => "+" @ 14 | |
<O> => \parse[0] | |
} | |
<infix> => \parse[0] | |
[0] => PMC 'Regex;Match' => "1 " @ 12 { | |
<integer> => PMC 'Regex;Match' => "1 " @ 12 { | |
<digit> => ResizablePMCArray (size:1) [ | |
PMC 'Regex;Match' => "1" @ 12 | |
] | |
} | |
} | |
[1] => PMC 'Regex;Match' => "2 " @ 16 { | |
<integer> => PMC 'Regex;Match' => "2 " @ 16 { | |
<digit> => ResizablePMCArray (size:1) [ | |
PMC 'Regex;Match' => "2" @ 16 | |
] | |
} | |
} | |
} | |
[1] => PMC 'Regex;Match' => "3 " @ 20 { | |
<integer> => PMC 'Regex;Match' => "3 " @ 20 { | |
<digit> => ResizablePMCArray (size:1) [ | |
PMC 'Regex;Match' => "3" @ 20 | |
] | |
} | |
} | |
} | |
[1] => PMC 'Regex;Match' => "4" @ 24 { | |
<integer> => PMC 'Regex;Match' => "4" @ 24 { | |
<digit> => ResizablePMCArray (size:1) [ | |
PMC 'Regex;Match' => "4" @ 24 | |
] | |
} | |
} | |
} | |
} | |
] | |
} | |
} | |
[sweeks@sweeks-laptop eria2]$ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment