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