tagged release 0.7.1
[parrot.git] / compilers / tge / TGE / Parser.pg
blobc62f5f84ce66f75ff4d2c6b227afdbeef0e42d1b
1 grammar TGE::Parser;
3 token start { ^ <TGE::Parser::statements>* [ $ | <syntax_error> ] }
5 rule statements { 
6      <transrule>
7     | <grammardec>
10 rule grammardec {
11     grammar <type> <inherit>?';'
14 rule inherit {
15     is <type>
18 rule transrule {
19     transform <name> 
20     '(' <type> ')'
21     <parent>?
22     <language>?
23     <action>
25     
26 rule parent {
27     ':applyto' '(' \'(<-[']>*)\' ')'
30 rule language {
31     ':language' '(' \'(\w+)\' ')'
34 token action {
35     '{' (<-[}]>*) '}'
38 token type {
39     [ '::' ]? \w+ [ '::' \w+ ]*
42 token name { \w+ }
44 token ws {
45     [ \s+
46     | \# \N*
47     | <.pod_comment>
48     ]*
52 regex pod_comment {
53     ^^ '=' [ [ cut \h*: | end [\h\N*]? ]
54            | for [ \h\N+: ] \n [ \N+\n ]*:
55            | \w\N*: \n .*? \n '=' [ cut \h*: | end [\h\N*:]? ]
56            ]
57            [\n|$]
60 token syntax_error { <?die: 'Syntax error'> }