blob: 68a7c902f51025dba48316d14520acf878be88f0 (
plain)
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
47
48
49
50
51
52
53
|
context maxlen
{
#
# Regular Definitions
#
rl rl_ws /[ \t\n\r\v]+/
rl rl_id /[a-zA-Z_][a-zA-Z0-9_]*/
#
# Tokens
#
lex
{
ignore /rl_ws/
token id /rl_id/
}
num: int
allow: int
def item
[id]
{
num = num + 1
toomuch: int = allow+1
if num == toomuch {
reject
}
}
def open
[]
{
num = 0
}
def close []
def restricted_list
[open item*]
def start
[restricted_list id*]
}
cons MaxLen: maxlen[]
MaxLen.allow = 3
parse S: maxlen::start(MaxLen)[stdin]
print_xml( S.tree )
|