File Coverage

blib/lib/MarpaX/xPathLike/DSL.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package MarpaX::xPathLike::DSL;
2 1     1   7 use strict;
  1         2  
  1         43  
3 1     1   6 use warnings FATAL => 'all';
  1         2  
  1         301  
4              
5             our $VERSION = '0.201';
6              
7             our $xpath = <<'END_OF_SOURCE';
8              
9             :default ::= action => ::array
10             :start ::= Start
11              
12             Start ::=
13             (WS) OperExp (WS) action => ::first
14              
15             OperExp ::=
16             PathExpr action => _do_path
17             |Function action => ::first
18              
19             Function ::=
20             NumericFunction action => ::first
21             | StringFunction action => ::first
22             | ListFunction action => ::first
23              
24             PathExpr ::=
25             absolutePath action => _do_absolutePath
26             | relativePath action => _do_relativePath
27             | PathExpr '|' PathExpr action => _do_pushArgs2array
28              
29             PredPathExpr ::=
30             absolutePath action => _do_absolutePath
31             | stepPathNoDigitStart action => _do_relativePath
32             | './' stepPath action => _do_relativePath2
33             | PredPathExpr '|' PredPathExpr action => _do_pushArgs2array
34              
35             relativePath ::=
36             stepPath action => ::first
37              
38             absolutePath ::=
39             subPath action => ::first
40              
41             subPath ::=
42             ('/') stepPath action => ::first
43             | '//' stepPath action => _do_vlen
44              
45             stepPath ::=
46             step Filter subPath action => _do_stepFilterSubpath
47             | step Filter action => _do_stepFilter
48             | step subPath action => _do_stepSubpath
49             | step action => ::first
50              
51              
52             step ::=
53             keyOrAxis action => ::first
54             |index action => ::first
55              
56             index ::=
57             UINT action => _do_array_hash_index
58              
59             stepPathNoDigitStart ::=
60             keyOrAxis Filter subPath action => _do_stepFilterSubpath
61             | keyOrAxis Filter action => _do_stepFilter
62             | keyOrAxis subPath action => _do_stepSubpath
63             | keyOrAxis action => ::first
64              
65              
66             keyOrAxis ::=
67             keyname action => _do_keyname
68             | '[' UINT ']' action => _do_array_index
69             | '.' action => _do_self
70             | '[.]' action => _do_selfArray
71             | '{.}' action => _do_selfHash
72             | 'self::*' action => _do_self
73             | 'self::[*]' action => _do_selfArray
74             | 'self::{*}' action => _do_selfHash
75             | 'self::' keyname action => _do_selfNamed
76             | 'self::' UINT action => _do_selfIndexedOrNamed
77             | 'self::[' UINT ']' action => _do_selfIndexed
78             | '*' action => _do_child
79             | '[*]' action => _do_childArray
80             | '{*}' action => _do_childHash
81             | 'child::*' action => _do_child
82             | 'child::[*]' action => _do_childArray
83             | 'child::{*}' action => _do_childHash
84             | 'child::' keyname action => _do_childNamed
85             | 'child::' UINT action => _do_childIndexedOrNamed
86             | 'child::[' UINT ']' action => _do_childIndexed
87             | '..' action => _do_parent
88             | '[..]' action => _do_parentArray
89             | '{..}' action => _do_parentHash
90             | 'parent::*' action => _do_parent
91             | 'parent::[*]' action => _do_parentArray
92             | 'parent::{*}' action => _do_parentHash
93             | 'parent::' keyname action => _do_parentNamed
94             | 'parent::' UINT action => _do_parentIndexedOrNamed
95             | 'parent::[' UINT ']' action => _do_parentIndexed
96             | 'ancestor::*' action => _do_ancestor
97             | 'ancestor::[*]' action => _do_ancestorArray
98             | 'ancestor::{*}' action => _do_ancestorHash
99             | 'ancestor::' keyname action => _do_ancestorNamed
100             | 'ancestor::' UINT action => _do_ancestorIndexedOrNamed
101             | 'ancestor::[' UINT ']' action => _do_ancestorIndexed
102             | 'ancestor-or-self::*' action => _do_ancestorOrSelf
103             | 'ancestor-or-self::[*]' action => _do_ancestorOrSelfArray
104             | 'ancestor-or-self::{*}' action => _do_ancestorOrSelfHash
105             | 'ancestor-or-self::' keyname action => _do_ancestorOrSelfNamed
106             | 'ancestor-or-self::' UINT action => _do_ancestorOrSelfIndexedOrNamed
107             | 'ancestor-or-self::[' UINT ']' action => _do_ancestorOrSelfIndexed
108             | 'descendant::*' action => _do_descendant
109             | 'descendant::[*]' action => _do_descendantArray
110             | 'descendant::{*}' action => _do_descendantHash
111             | 'descendant::' keyname action => _do_descendantNamed
112             | 'descendant::' UINT action => _do_descendantIndexedOrNamed
113             | 'descendant::[' UINT ']' action => _do_descendantIndexed
114             | 'descendant-or-self::*' action => _do_descendantOrSelf
115             | 'descendant-or-self::[*]' action => _do_descendantOrSelfArray
116             | 'descendant-or-self::{*}' action => _do_descendantOrSelfHash
117             | 'descendant-or-self::' keyname action => _do_descendantOrSelfNamed
118             | 'descendant-or-self::' UINT action => _do_descendantOrSelfIndexedOrNamed
119             | 'descendant-or-self::[' UINT ']' action => _do_descendantOrSelfIndexed
120             | 'preceding-sibling::*' action => _do_precedingSibling
121             | 'preceding-sibling::[*]' action => _do_precedingSiblingArray
122             | 'preceding-sibling::{*}' action => _do_precedingSiblingHash
123             | 'preceding-sibling::' keyname action => _do_precedingSiblingNamed
124             | 'preceding-sibling::' UINT action => _do_precedingSiblingIndexedOrNamed
125             | 'preceding-sibling::[' UINT ']' action => _do_precedingSiblingIndexed
126             | 'following-sibling::*' action => _do_followingSibling
127             | 'following-sibling::[*]' action => _do_followingSiblingArray
128             | 'following-sibling::{*}' action => _do_followingSiblingHash
129             | 'following-sibling::' keyname action => _do_followingSiblingNamed
130             | 'following-sibling::' UINT action => _do_followingSiblingIndexedOrNamed
131             | 'following-sibling::[' UINT ']' action => _do_followingSiblingIndexed
132              
133             IndexExprs ::= IndexExpr+ separator =>
134              
135             IndexExpr ::=
136             IntExpr action => _do_index_single
137             | rangeExpr action => ::first
138              
139             rangeExpr ::=
140             IntExpr '..' IntExpr action => _do_index_range
141             |IntExpr '..' action => _do_startRange
142             | '..' IntExpr action => _do_endRange
143              
144             Filter ::=
145             IndexFilter
146             | LogicalFilter
147             | Filter Filter action => _do_mergeFilters
148              
149             LogicalFilter ::=
150             '[' LogicalExpr ']' action => _do_boolean_filter
151              
152             IndexFilter ::=
153             '[' IndexExprs ']' action => _do_index_filter
154              
155              
156             IntExpr ::=
157             (WS) ArithmeticIntExpr (WS) action => ::first
158              
159             ArithmeticIntExpr ::=
160             INT action => ::first
161             | IntegerFunction action => ::first
162             | '(' IntExpr ')' action => _do_group
163             || '-' ArithmeticIntExpr action => _do_unaryOperator
164             | '+' ArithmeticIntExpr action => _do_unaryOperator
165             || IntExpr '*' IntExpr action => _do_binaryOperation
166             | IntExpr 'div' IntExpr action => _do_binaryOperation
167             # | IntExpr ' /' IntExpr action => _do_binaryOperation
168             # | IntExpr '/ ' IntExpr action => _do_binaryOperation
169             | IntExpr '%' IntExpr action => _do_binaryOperation
170             || IntExpr '+' IntExpr action => _do_binaryOperation
171             | IntExpr '-' IntExpr action => _do_binaryOperation
172              
173              
174             NumericExpr ::=
175             (WS) ArithmeticExpr (WS) action => ::first
176              
177             ArithmeticExpr ::=
178             NUMBER action => ::first
179             || PredPathExpr action => _do_getValueOperator
180             | NumericFunction action => ::first
181             | '(' NumericExpr ')' action => _do_group
182             || '-' ArithmeticExpr action => _do_unaryOperator
183             | '+' ArithmeticExpr action => _do_unaryOperator
184             || NumericExpr '*' NumericExpr action => _do_binaryOperation
185             | NumericExpr 'div' NumericExpr action => _do_binaryOperation
186             # | NumericExpr ' /' NumericExpr action => _do_binaryOperation
187             # | NumericExpr '/ ' NumericExpr action => _do_binaryOperation
188             | NumericExpr 'mod' NumericExpr action => _do_binaryOperation
189             | NumericExpr '%' NumericExpr action => _do_binaryOperation
190             || NumericExpr '+' NumericExpr action => _do_binaryOperation
191             | NumericExpr '-' NumericExpr action => _do_binaryOperation
192              
193             LogicalExpr ::=
194             (WS) LogicalFunction (WS) action => ::first
195             || (WS) compareExpr (WS) action => ::first
196              
197             compareExpr ::=
198             PredPathExpr action => _do_exists
199             || AnyTypeExpr '<' AnyTypeExpr action => _do_binaryOperation
200             | AnyTypeExpr '<=' AnyTypeExpr action => _do_binaryOperation
201             | AnyTypeExpr '>' AnyTypeExpr action => _do_binaryOperation
202             | AnyTypeExpr '>=' AnyTypeExpr action => _do_binaryOperation
203             | StringExpr 'lt' StringExpr action => _do_binaryOperation
204             | StringExpr 'le' StringExpr action => _do_binaryOperation
205             | StringExpr 'gt' StringExpr action => _do_binaryOperation
206             | StringExpr 'ge' StringExpr action => _do_binaryOperation
207             | StringExpr '~' RegularExpr action => _do_binaryOperation
208             | StringExpr '!~' RegularExpr action => _do_binaryOperation
209             | NumericExpr '===' NumericExpr action => _do_binaryOperation
210             | NumericExpr '!==' NumericExpr action => _do_binaryOperation
211             | AnyTypeExpr '==' AnyTypeExpr action => _do_binaryOperation
212             | AnyTypeExpr '=' AnyTypeExpr action => _do_binaryOperation #to be xpath compatible
213             | AnyTypeExpr '!=' AnyTypeExpr action => _do_binaryOperation
214             | StringExpr 'eq' StringExpr action => _do_binaryOperation
215             | StringExpr 'ne' StringExpr action => _do_binaryOperation
216             || LogicalExpr 'and' LogicalExpr action => _do_binaryOperation
217             || LogicalExpr 'or' LogicalExpr action => _do_binaryOperation
218              
219              
220             AnyTypeExpr ::=
221             (WS) allTypeExp (WS) action => ::first
222              
223             allTypeExp ::=
224             NumericExpr action => ::first
225             |StringExpr action => ::first
226             || PredPathExpr action => _do_getValueOperator
227              
228              
229             StringExpr ::=
230             (WS) allStringsExp (WS) action => ::first
231              
232             allStringsExp ::=
233             STRING action => ::first
234             | StringFunction action => ::first
235             | PredPathExpr action => _do_getValueOperator
236             || StringExpr '||' StringExpr action => _do_binaryOperation
237              
238              
239             RegularExpr ::=
240             WS STRING WS action => _do_re
241              
242             LogicalFunction ::=
243             'not' '(' LogicalExpr ')' action => _do_func
244             | 'isRef' '(' OptionalPathArgs ')' action => _do_func
245             | 'isScalar' '(' OptionalPathArgs ')' action => _do_func
246             | 'isArray' '(' OptionalPathArgs ')' action => _do_func
247             | 'isHash' '(' OptionalPathArgs ')' action => _do_func
248             | 'isCode' '(' OptionalPathArgs ')' action => _do_func
249              
250             StringFunction ::=
251             NameFunction action => ::first
252             | ValueFunction action => ::first
253              
254             NameFunction ::=
255             'name' '(' OptionalPathArgs ')' action => _do_func
256              
257             OptionalPathArgs ::=
258             RequiredPathArgs action => ::first
259             | EMPTY action => ::first
260              
261             RequiredPathArgs ::=
262             (WS) PathExpr (WS) action => ::first
263              
264             EMPTY ::=
265              
266             ValueFunction ::=
267             'value' '(' OptionalPathArgs ')' action => _do_func
268              
269             CountFunction ::=
270             'count' '(' RequiredPathArgs ')' action => _do_func
271              
272             LastFunction ::=
273             'last' '(' OptionalPathArgs ')' action => _do_func
274              
275             PositionFunction ::=
276             'position' '(' OptionalPathArgs ')' action => _do_func
277              
278             SumFunction ::=
279             'sum' '(' RequiredPathArgs ')' action => _do_func
280              
281             SumProductFunction ::=
282             'sumproduct' '(' RequiredPathArgs ',' RequiredPathArgs ')' action => _do_funcw2args
283              
284             NumericFunction ::=
285             IntegerFunction action => ::first
286             |ValueFunction action => ::first
287             |SumFunction action => ::first
288             |SumProductFunction action => ::first
289              
290             IntegerFunction ::=
291             CountFunction action => ::first
292             |LastFunction action => ::first
293             |PositionFunction action => ::first
294              
295             ListFunction ::=
296             'names' '(' OptionalPathArgs ')' action => _do_func
297             | 'values' '(' OptionalPathArgs ')' action => _do_func
298             | 'lasts' '(' OptionalPathArgs ')' action => _do_func
299             | 'positions' '(' OptionalPathArgs ')' action => _do_func
300              
301              
302             NUMBER ::=
303             unumber action => ::first
304             | '-' unumber action => _do_join
305             | '+' unumber action => _do_join
306              
307             unumber
308             ~ uint
309             | uint frac
310             | uint exp
311             | uint frac exp
312             | frac
313             | frac exp
314            
315             uint
316             ~ digits
317              
318             digits
319             ~ [\d]+
320            
321             frac
322             ~ '.' digits
323            
324             exp
325             ~ e digits
326            
327             e
328             ~ 'e'
329             | 'e+'
330             | 'e-'
331             | 'E'
332             | 'E+'
333             | 'E-'
334              
335             INT ::=
336             UINT action => ::first
337             | '+' UINT action => _do_join #avoid ambiguity
338             | '-' UINT action => _do_join #avoid ambiguity
339              
340             UINT
341             ~digits
342              
343             STRING ::=
344             double_quoted action => _do_double_quoted
345             | single_quoted action => _do_single_quoted
346              
347             single_quoted
348             ~ ['] single_quoted_chars [']
349              
350             single_quoted_chars
351             ~ single_quoted_char*
352            
353             single_quoted_char
354             ~ [^'\\]
355             | '\' [']
356             | '\' '\'
357              
358             double_quoted
359             ~ ["] double_quoted_chars ["]
360              
361             double_quoted_chars
362             ~ double_quoted_char*
363            
364             double_quoted_char
365             ~ [^"\\]
366             | '\' '"'
367             | '\' '\'
368              
369             keyname ::=
370             keyword action => ::first
371             | ('{') keyword ('}') action => ::first
372             | ('{') UINT ('}') action => ::first
373             | ('{') STRING ('}') action => ::first
374             # | STRING action => ::first
375             # | curly_delimited_string action => _do_curly_delimited_string
376              
377             # curly_delimited_string
378             # ~ '{' keyword '}'
379             # | '{' double_quoted '}'
380             # | '{' single_quoted '}'
381              
382             # curly_delimited_chars
383             # ~ curly_delimited_char*
384              
385             # curly_delimited_char
386             # ~ [^}{]
387             # | '\' '{'
388             # | '\' '}'
389              
390             keyword ::=
391             token action => _do_token
392              
393             token
394             ~ ID
395              
396             ID #must have at least one non digit
397             ~ notreserved
398             | ID digits
399             | ID digits ID
400             | digits ID
401             | digits ID digits
402              
403             notreserved
404             ~ [^\d:./*,'"|\s\]\[\(\)\{\}\\+-<>=!]+
405              
406              
407             # :discard
408             # ~ WS
409              
410             WS ::=
411             whitespace
412             |EMPTY
413              
414             whitespace
415             ~ [\s\n\r]+
416              
417             comma
418             ~ ','
419              
420             END_OF_SOURCE
421              
422             1;
423             __END__