blob: b1e6b2d9ac9d385b5c475396baa8041ef3f380a0 (
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
|
#
# Tokens
#
# Any single character can be a literal
lex start
{
# Ignore whitespace.
ignore /[ \t\n\r\v]+/
# Open and close id
token id /[a-zA-Z_][a-zA-Z0-9_]*/
token open_paren /'('/
{
input.push_ignore( parse_stop nested_comment( stdin ) )
}
}
#
# Token translation
#
lex nc_scan
{
literal '(', ')'
token nc_data /[^()]+/
}
def nc_item
[nc_data]
| [nested_comment]
def nested_comment
['(' nc_item* ')']
def nested [id*]
P: nested = parse nested( stdin )
print( P )
print_xml( P )
print_xml_ac( P )
print( P '\n' )
|