-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.p6
68 lines (65 loc) · 1.56 KB
/
index.p6
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use Grammar::Tracer;
BEGIN $*LANG.refine_slang: 'MAIN',
role P6X {
#grammar XML {
token p6x-word {
\w+
}
token p6x-attr {
<p6x-word> '=' [
| '"' ~ '"' $<p6x-value>=.*?
| "'" ~ "'" $<p6x-value>=.*?
| $<p6x-value=.p6x-word>
]
}
rule p6x-inner-tag {
$<p6x-name>=<.p6x-word>
<p6x-attr>* %% <.ws>
}
rule p6x-closing-tag($name) {
'</' ~ '>' $name
}
rule p6x-opening-tag {
'<' ~ '>' <p6x-inner-tag>
}
rule p6x-unique-tag {
'<' ~ '/>' <p6x-inner-tag>
}
rule p6x-open-close-tag {
:my $name;
[<p6x-opening-tag> {$name = $<p6x-opening-tag><p6x-inner-tag><p6x-name>}] ~ <p6x-closing-tag($name)>
$<p6x-inner> = [
|| <p6x-xml>+ $<p6x-post-data>=.*?
|| $<p6x-pre-data>=.+? <p6x-xml>+ $<p6x-post-data>=.*?
|| .*?
]
}
rule p6x-tag {
|| <p6x-unique-tag>
|| <p6x-open-close-tag>
}
rule p6x-xml {
<p6x-tag>
}
token statement_control:sym<p6x> {
<p6x-xml>
}
#rule TOP { <p6x-xml> }
},
role P6XActions {
method statement_control:sym<p6x> (Mu $/) {
say $/;
nextsame
}
}
#say XML.parse: Q:to/END/;
#<head>
# <body>
# bla
# <form>
# bla
# </form>
# </body>
#</head>
#END
<br />