blob: 4291bc177ab188bd8bd0f0d6c7062d5ce76c57d8 (
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
|
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/
end
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 )
|