Mercurial > hg > xslscript
annotate xslscript.pl @ 7:9a283d72ddc3
XSLScript: --dump option.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 24 Feb 2014 03:47:17 +0400 |
parents | d3340fdeadf6 |
children | 86721b270ebb |
rev | line source |
---|---|
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Convert from XSLScript to XSLT. |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 # |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 # Originally XSLScript was written by Paul Tchistopolskii. It is believed |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 # to be mostly identical to XSLT, but uses shorter syntax. Original |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 # implementation has major Java dependency, no longer supported and hard |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 # to find. |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 # |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 # This code doesn't pretend to be a full replacement, but rather an attempt |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 # to provide functionality needed for nginx documentation. |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 ############################################################################### |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use warnings; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use strict; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 use Parse::RecDescent; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 use Getopt::Long; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 use Data::Dumper qw/Dumper/; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 ############################################################################### |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 |
7 | 26 my $dump = 0; |
27 | |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 GetOptions( |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 "trace!" => \$::RD_TRACE, |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 "hint!" => \$::RD_HINT, |
7 | 31 "dump!" => \$dump, |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 ) |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 or die "oops\n"; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 ############################################################################### |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 my $grammar = <<'EOF'; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 # XSLTScript grammar, reconstructed |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 startrule : item(s) eofile |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
42 { $return = $item[1]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
43 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
44 item : "<!--" <commit> comment |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
45 | "!!" <commit> exclam_double |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
46 | "!{" <commit> exclam_xpath |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
47 | "!" name <commit> params |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
48 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
49 "X:call-template", "name", $item{name}, [], |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
50 $item{params} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
51 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
52 | "<%" <commit> instruction "%>" |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
53 { $return = $item{instruction}; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
54 | "<" name attrs ">" <commit> item(s?) "</" name ">" |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
55 { $return = [ "tag", $item{name}, $item{attrs}, $item[6] ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
56 | "<" <commit> name attrs "/" ">" |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
57 { $return = [ "tag", $item{name}, $item{attrs} ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
58 | "X:variable" <commit> xvariable |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
59 | "X:var" <commit> xvariable |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
60 | "X:template" <commit> xtemplate |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
61 | "X:if" <commit> xif |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
62 | "X:param" <commit> xparam |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
63 | "X:for-each" <commit> xforeach |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
64 | "X:sort" <commit> xsort |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
65 | "X:when" <commit> xwhen |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
66 | "X:attribute" <commit> xattribute |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
67 | "X:output" <commit> xoutput |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
68 | "X:copy-of" <commit> xcopyof |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
69 | instruction <commit> attrs body |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
70 { $return = [ $item{instruction}, $item{attrs}, $item{body} ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
71 | text |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
72 | <error> |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
74 # list of simple instructions |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
76 instruction : "X:stylesheet" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
77 | "X:transform" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
78 | "X:attribute-set" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
79 | "X:element" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
80 | "X:apply-templates" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
81 | "X:choose" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
82 | "X:otherwise" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
83 | "X:value-of" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
84 | "X:apply-imports" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
85 | "X:number" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
86 | "X:include" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
87 | "X:import" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
88 | "X:strip-space" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
89 | "X:preserve-space" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
90 | "X:copy" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
91 | "X:text" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
92 | "X:comment" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
93 | "X:processing-instruction" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
94 | "X:decimal-format" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
95 | "X:namespace-alias" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
96 | "X:key" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
97 | "X:fallback" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
98 | "X:message" |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 # comments, <!-- ... --> |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 # not sure if it's something to be interpreted specially |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 # likely an artifact of our dump process |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
104 comment : /((?!-->).)*/ms "-->" |
5 | 105 { $return = ""; 1 } |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 # special chars: ', ", {, }, \ |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 # if used in text, they needs to be escaped with backslash |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
110 text : quoted | unreserved | "'" | "\"" | "{" |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 quoted : "\\" special |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
112 { $return = $item{special}; 1; } |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 special : "'" | "\"" | "\\" | "{" | "}" |
5 | 114 unreserved : /[^'"\\{}<\s]+\s*/ |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 # shortcuts: |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 # |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
118 # !! for X:apply-templates |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 # !{xpath-expression} for X:value-of select="xpath-expression"; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 # !foo() for X:call-template name="foo" |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
122 # !root (path = { !{ substring($DIRNAME, 2) } }) |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
123 # !root (path = "substring-after($path, '/')") |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
124 |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
125 exclam_double : value(?) params(?) attrs ";" |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
126 { $return = [ |
5 | 127 "X:apply-templates", "select", $item[1][0], $item{attrs}, |
128 $item[2][0] | |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
129 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
130 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
131 exclam_xpath : xpath "}" |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
132 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
133 "X:value-of", "select", $item{xpath}, [] |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
134 ]; 1 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
135 xpath : /("[^"]*"|'[^']*'|[^}'"])*/ms |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
136 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
137 # instruction attributes |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
138 # name="value" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
139 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
140 attrs : attr(s?) |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
141 attr : name "=" value |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
142 { $return = $item{name} . "=" . $item{value}; } |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 name : /[a-z0-9_:-]+/i |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
144 value : /"[^"]*"/ |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
146 # template parameters |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
147 # ( bar="init", baz={markup} ) |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
148 |
5 | 149 params : "(" param(s? /,/) ")" |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
150 { $return = $item[2]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
151 param : name "=" value |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
152 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
153 "X:with-param", |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
154 "select", $item{value}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
155 "name", $item{name}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
156 [] |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
157 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
158 | name "=" <commit> "{" item(s) "}" |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
159 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
160 "X:with-param", "name", $item{name}, [], |
5 | 161 $item[5] |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
162 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
163 | name |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
164 { $return = [ |
5 | 165 "X:param", "name", $item{name}, [] |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
166 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
167 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
168 # instruction body |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
169 # ";" for empty body, "{ ... }" otherwise |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 body : ";" |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
172 { $return = ""; } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
173 | "{" <commit> item(s?) "}" |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
174 { $return = $item[3]; 1 } |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
176 # special handling of some instructions |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
177 # X:if attribute is test= |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
179 xif : value body "else" <commit> body |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
180 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
181 "X:choose", [], [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
182 [ "X:when", "test", $item[1], [], $item[2] ], |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
183 [ "X:otherwise", [], $item[5] ] |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
184 ] |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
185 ]; 1 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
186 | value attrs body |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
187 { $return = [ |
5 | 188 "X:if", "test", $item{value}, $item{attrs}, $item{body}, |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
189 ]; 1 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
190 | attrs body |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
191 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
192 "X:if", $item{attrs}, $item{body}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
193 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
194 | <error> |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 # X:template name(params) = "match" { |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
197 # X:template name( bar="init", baz={markup} ) = "match" mode="some" { |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
198 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
199 xtemplate : name(?) params(?) ( "=" value )(?) attrs body |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
200 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
201 "X:template", "name", $item[1][0], "match", $item[3][0], |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
202 $item{attrs}, |
5 | 203 [ ($item[2][0] ? @{$item[2][0]} : ()), @{$item{body}} ] |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
204 ]; 1 } |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
205 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
206 # X:var LINK = "/article/@link"; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
207 # X:var year = { ... } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
208 # semicolon is optional |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
210 xvariable : name "=" value attrs body |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
211 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
212 "X:variable", |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
213 "select", $item{value}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
214 "name", $item{name}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
215 $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
216 ]; 1 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
217 | name "=" attrs body |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
218 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
219 "X:variable", |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
220 "name", $item{name}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
221 $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
222 ]; 1 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
223 | name "=" value |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
224 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
225 "X:variable", |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
226 "select", $item{value}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
227 "name", $item{name}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
228 [] |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
229 ]; 1 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
230 | name "=" |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
231 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
232 "X:variable", |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
233 "name", $item{name}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
234 [] |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
235 ]; 1 } |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
236 | <error> |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
237 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
238 # X:param XML = "'../xml'"; |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
239 # X:param YEAR; |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
240 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
241 xparam : name "=" value attrs body |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
242 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
243 "X:param", |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
244 "select", $item{value}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
245 "name", $item{name}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
246 $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
247 ]; 1 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
248 | name attrs body |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
249 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
250 "X:param", "name", $item{name}, |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
251 $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
252 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
253 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
254 # X:for-each "section[@id and @name]" { ... } |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
255 # X:for-each "link", X:sort "@id" { |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
257 xforeach : value attrs body |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
258 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
259 "X:for-each", "select", $item{value}, $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
260 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
261 | value attrs "," "X:sort" <commit> value attrs body |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
262 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
263 "X:for-each", "select", $item[1], $item[2], [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
264 [ "X:sort", "select", $item[6], $item[7] ], |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
265 @{$item{body}} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
266 ] |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
267 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
268 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
269 # X:sort select |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
270 # X:sort "@id" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
271 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
272 xsort : value attrs body |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
273 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
274 "X:sort", "select", $item{value}, $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
275 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
276 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
277 # X:when "position() = 1" { ... } |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
279 xwhen : value attrs body |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
280 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
281 "X:when", "test", $item{value}, $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
282 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
283 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
284 # X:attribute "href" { ... } |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
285 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
286 xattribute : value attrs body |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
287 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
288 "X:attribute", "name", $item{value}, $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
289 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
290 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
291 # X:output |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
292 # semicolon is optional |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
293 |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
294 xoutput : attrs body(?) |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
295 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
296 "X:output", undef, undef, $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
297 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
298 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
299 # "X:copy-of" |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
300 # semicolon is optional |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
301 |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
302 xcopyof : value attrs body(?) |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
303 { $return = [ |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
304 "X:copy-of", "select", $item{value}, $item{attrs}, $item{body} |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
305 ]; 1 } |
2
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
306 |
bcd96c403898
XSLScript: rewritten grammar, matches all xsls.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1
diff
changeset
|
307 # eof |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
308 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
309 eofile : /^\Z/ |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
310 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
311 EOF |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
312 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
313 ############################################################################### |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
314 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
315 sub format_tree { |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
316 my ($tree, $indent) = @_; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
317 my $s = ''; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
318 |
5 | 319 if (!defined $indent) { |
320 $indent = 0; | |
321 $s .= '<?xml version="1.0" encoding="utf-8"?>' . "\n"; | |
322 } | |
323 | |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
324 my $space = " " x $indent; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
325 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
326 foreach my $el (@{$tree}) { |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
327 if (!defined $el) { |
5 | 328 warn "Undefined element in output.\n"; |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
329 $s .= $space . "(undef)" . "\n"; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
330 next; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
331 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
332 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
333 if (not ref($el) && defined $el) { |
5 | 334 #$s .= $space . $el . "\n"; |
335 $s .= $el; | |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
336 next; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
337 } |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
338 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
339 die if ref($el) ne 'ARRAY'; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
340 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
341 my $tag = $el->[0]; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
342 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
343 if ($tag eq 'tag') { |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
344 my (undef, $name, $attrs, $body) = @{$el}; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
345 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
346 $s .= $space . "<" . join(" ", $name, @{$attrs}); |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
347 if ($body) { |
5 | 348 my $t = format_tree($body, $indent + 1); |
349 if ($t =~ /\n/) { | |
350 $s .= ">\n" . $t | |
351 . $space . "</$name>\n"; | |
352 } else { | |
353 $s .= ">$t</$name>\n"; | |
354 } | |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
355 } else { |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
356 $s .= "/>\n"; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
357 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
358 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
359 next; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
360 } |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
361 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
362 if ($tag =~ m/^X:(.*)/) { |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
363 my $name = "xsl:" . $1; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
364 my (undef, @a) = @{$el}; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
365 my @attrs; |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
366 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
367 while (@a) { |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
368 last if ref($a[0]) eq 'ARRAY'; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
369 my $name = shift @a; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
370 my $value = shift @a; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
371 next unless defined $value; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
372 $value = '"' . $value . '"' |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
373 unless $value =~ /^"/; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
374 push @attrs, "$name=$value"; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
375 } |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
376 |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
377 if ($name eq "xsl:stylesheet") { |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
378 push @attrs, 'xmlns:xsl="http://www.w3.org/1999/XSL/Transform"'; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
379 push @attrs, 'version="1.0"'; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
380 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
381 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
382 my ($attrs, $body) = @a; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
383 $attrs = [ @{$attrs}, @attrs ]; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
384 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
385 $s .= $space . "<" . join(" ", $name, @{$attrs}); |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
386 |
5 | 387 if ($body && scalar @{$body} > 0) { |
388 my $t = format_tree($body, $indent + 1); | |
389 if ($t =~ /\n/) { | |
390 $s .= ">\n" . $t | |
391 . $space . "</$name>\n"; | |
392 } else { | |
393 $s .= ">$t</$name>\n"; | |
394 } | |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
395 } else { |
5 | 396 $s .= "/>\n"; |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
397 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
398 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
399 next; |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
400 } |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
401 |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
402 $s .= format_tree($el, $indent + 1); |
3
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
403 } |
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
404 |
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
405 return $s; |
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
406 } |
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
407 |
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
408 ############################################################################### |
0fa786e03744
XSLScript: some preliminary work on conversion.
Maxim Dounin <mdounin@mdounin.ru>
parents:
2
diff
changeset
|
409 |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
410 my $parser = Parse::RecDescent->new($grammar) |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
411 or die "Failed to create parser.\n"; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
412 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
413 my $lines; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
414 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
415 { |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
416 local $/; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
417 $lines = <>; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
418 } |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
419 |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
420 my $tree = $parser->startrule($lines) |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
421 or die "Failed to parse $ARGV.\n"; |
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
422 |
7 | 423 if ($dump) { |
424 print Dumper($tree); | |
425 exit(0); | |
426 } | |
427 | |
4
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
428 print format_tree($tree); |
eb959dce273b
XSLScript: tree construction and printing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3
diff
changeset
|
429 |
1
f082f8c2ebb0
XSLScript: some preliminary grammar, incomplete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
430 ############################################################################### |