-
Notifications
You must be signed in to change notification settings - Fork 1
/
grammar.pg
47 lines (34 loc) · 832 Bytes
/
grammar.pg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# $Id$
=begin overview
This is the grammar for kea written as a sequence of Perl 6 rules.
=end overview
grammar kea::Grammar is PCT::Grammar;
rule TOP {
<statement>*
[ $ || <panic: 'Syntax error'> ]
{*}
}
## this <ws> rule treats # as "comment to eol"
## you may want to replace it with something appropriate
token ws {
<!ww>
[ '#' \N* \n? | \s+ ]*
}
rule statement {
'dup' <expression> [ ',' <expression> ]* ';'
{*}
}
rule value {
| <integer> {*} #= integer
| <quote> {*} #= quote
}
token integer { \d+ {*} }
token quote {
[ \' <string_literal: '\'' > \' | \" <string_literal: '"' > \" ]
{*}
}
## terms
token term {
| <value> {*} #= value
}
rule expression is optable { ... }