Filename | /var/www/foswikidev/core/lib/Foswiki/Query/Parser.pm |
Statements | Executed 249 statements in 3.32ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.69ms | 5.81ms | BEGIN@28 | Foswiki::Query::Parser::
3 | 3 | 3 | 676µs | 2.71ms | new | Foswiki::Query::Parser::
1 | 1 | 1 | 648µs | 694µs | BEGIN@61 | Foswiki::Query::Parser::
1 | 1 | 1 | 510µs | 698µs | BEGIN@58 | Foswiki::Query::Parser::
1 | 1 | 1 | 303µs | 349µs | BEGIN@46 | Foswiki::Query::Parser::
1 | 1 | 1 | 292µs | 339µs | BEGIN@34 | Foswiki::Query::Parser::
1 | 1 | 1 | 279µs | 325µs | BEGIN@36 | Foswiki::Query::Parser::
1 | 1 | 1 | 272µs | 318µs | BEGIN@68 | Foswiki::Query::Parser::
1 | 1 | 1 | 264µs | 313µs | BEGIN@56 | Foswiki::Query::Parser::
1 | 1 | 1 | 261µs | 306µs | BEGIN@48 | Foswiki::Query::Parser::
1 | 1 | 1 | 260µs | 303µs | BEGIN@59 | Foswiki::Query::Parser::
1 | 1 | 1 | 259µs | 305µs | BEGIN@63 | Foswiki::Query::Parser::
1 | 1 | 1 | 259µs | 300µs | BEGIN@52 | Foswiki::Query::Parser::
1 | 1 | 1 | 259µs | 302µs | BEGIN@50 | Foswiki::Query::Parser::
1 | 1 | 1 | 254µs | 300µs | BEGIN@64 | Foswiki::Query::Parser::
1 | 1 | 1 | 244µs | 284µs | BEGIN@67 | Foswiki::Query::Parser::
1 | 1 | 1 | 239µs | 279µs | BEGIN@66 | Foswiki::Query::Parser::
1 | 1 | 1 | 234µs | 281µs | BEGIN@65 | Foswiki::Query::Parser::
1 | 1 | 1 | 222µs | 267µs | BEGIN@44 | Foswiki::Query::Parser::
1 | 1 | 1 | 222µs | 708µs | BEGIN@42 | Foswiki::Query::Parser::
1 | 1 | 1 | 218µs | 259µs | BEGIN@45 | Foswiki::Query::Parser::
1 | 1 | 1 | 217µs | 265µs | BEGIN@47 | Foswiki::Query::Parser::
1 | 1 | 1 | 216µs | 258µs | BEGIN@49 | Foswiki::Query::Parser::
1 | 1 | 1 | 216µs | 256µs | BEGIN@53 | Foswiki::Query::Parser::
1 | 1 | 1 | 214µs | 256µs | BEGIN@43 | Foswiki::Query::Parser::
1 | 1 | 1 | 213µs | 260µs | BEGIN@55 | Foswiki::Query::Parser::
1 | 1 | 1 | 207µs | 530µs | BEGIN@38 | Foswiki::Query::Parser::
1 | 1 | 1 | 198µs | 239µs | BEGIN@70 | Foswiki::Query::Parser::
1 | 1 | 1 | 15µs | 27µs | BEGIN@17 | Foswiki::Query::Parser::
1 | 1 | 1 | 11µs | 43µs | BEGIN@100 | Foswiki::Query::Parser::
1 | 1 | 1 | 10µs | 34µs | BEGIN@19 | Foswiki::Query::Parser::
1 | 1 | 1 | 9µs | 13µs | BEGIN@18 | Foswiki::Query::Parser::
1 | 1 | 1 | 6µs | 6µs | BEGIN@31 | Foswiki::Query::Parser::
1 | 1 | 1 | 4µs | 4µs | BEGIN@40 | Foswiki::Query::Parser::
1 | 1 | 1 | 4µs | 4µs | BEGIN@21 | Foswiki::Query::Parser::
0 | 0 | 0 | 0s | 0s | onCloseExpr | Foswiki::Query::Parser::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | =begin TML | ||||
4 | |||||
5 | ---+ package Foswiki::Query::Parser | ||||
6 | |||||
7 | Parser for queries, using the Foswiki::Infix::Parser. | ||||
8 | |||||
9 | The default node type in the generated parse tree is Foswiki::Query::Node, | ||||
10 | though you can pass your own alternative class as an option (it must implement | ||||
11 | Foswiki::Infix::Node) | ||||
12 | |||||
13 | =cut | ||||
14 | |||||
15 | package Foswiki::Query::Parser; | ||||
16 | |||||
17 | 2 | 26µs | 2 | 38µs | # spent 27µs (15+12) within Foswiki::Query::Parser::BEGIN@17 which was called:
# once (15µs+12µs) by Foswiki::If::Parser::BEGIN@16 at line 17 # spent 27µs making 1 call to Foswiki::Query::Parser::BEGIN@17
# spent 12µs making 1 call to strict::import |
18 | 2 | 23µs | 2 | 17µs | # spent 13µs (9+4) within Foswiki::Query::Parser::BEGIN@18 which was called:
# once (9µs+4µs) by Foswiki::If::Parser::BEGIN@16 at line 18 # spent 13µs making 1 call to Foswiki::Query::Parser::BEGIN@18
# spent 4µs making 1 call to warnings::import |
19 | 2 | 45µs | 2 | 58µs | # spent 34µs (10+24) within Foswiki::Query::Parser::BEGIN@19 which was called:
# once (10µs+24µs) by Foswiki::If::Parser::BEGIN@16 at line 19 # spent 34µs making 1 call to Foswiki::Query::Parser::BEGIN@19
# spent 24µs making 1 call to Exporter::import |
20 | |||||
21 | # spent 4µs within Foswiki::Query::Parser::BEGIN@21 which was called:
# once (4µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 26 | ||||
22 | 1 | 4µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
23 | require locale; | ||||
24 | import locale(); | ||||
25 | } | ||||
26 | 1 | 19µs | 1 | 4µs | } # spent 4µs making 1 call to Foswiki::Query::Parser::BEGIN@21 |
27 | |||||
28 | 2 | 115µs | 1 | 5.81ms | # spent 5.81ms (1.69+4.11) within Foswiki::Query::Parser::BEGIN@28 which was called:
# once (1.69ms+4.11ms) by Foswiki::If::Parser::BEGIN@16 at line 28 # spent 5.81ms making 1 call to Foswiki::Query::Parser::BEGIN@28 |
29 | 1 | 7µs | our @ISA = ('Foswiki::Infix::Parser'); | ||
30 | |||||
31 | 2 | 23µs | 1 | 6µs | # spent 6µs within Foswiki::Query::Parser::BEGIN@31 which was called:
# once (6µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 31 # spent 6µs making 1 call to Foswiki::Query::Parser::BEGIN@31 |
32 | |||||
33 | # operator name precedence | ||||
34 | 2 | 98µs | 1 | 339µs | # spent 339µs (292+47) within Foswiki::Query::Parser::BEGIN@34 which was called:
# once (292µs+47µs) by Foswiki::If::Parser::BEGIN@16 at line 34 # spent 339µs making 1 call to Foswiki::Query::Parser::BEGIN@34 |
35 | |||||
36 | 2 | 96µs | 1 | 325µs | # spent 325µs (279+46) within Foswiki::Query::Parser::BEGIN@36 which was called:
# once (279µs+46µs) by Foswiki::If::Parser::BEGIN@16 at line 36 # spent 325µs making 1 call to Foswiki::Query::Parser::BEGIN@36 |
37 | |||||
38 | 2 | 87µs | 1 | 530µs | # spent 530µs (207+323) within Foswiki::Query::Parser::BEGIN@38 which was called:
# once (207µs+323µs) by Foswiki::If::Parser::BEGIN@16 at line 38 # spent 530µs making 1 call to Foswiki::Query::Parser::BEGIN@38 |
39 | |||||
40 | 2 | 20µs | 1 | 4µs | # spent 4µs within Foswiki::Query::Parser::BEGIN@40 which was called:
# once (4µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 40 # spent 4µs making 1 call to Foswiki::Query::Parser::BEGIN@40 |
41 | |||||
42 | 2 | 86µs | 1 | 708µs | # spent 708µs (222+487) within Foswiki::Query::Parser::BEGIN@42 which was called:
# once (222µs+487µs) by Foswiki::If::Parser::BEGIN@16 at line 42 # spent 708µs making 1 call to Foswiki::Query::Parser::BEGIN@42 |
43 | 2 | 88µs | 1 | 256µs | # spent 256µs (214+42) within Foswiki::Query::Parser::BEGIN@43 which was called:
# once (214µs+42µs) by Foswiki::If::Parser::BEGIN@16 at line 43 # spent 256µs making 1 call to Foswiki::Query::Parser::BEGIN@43 |
44 | 2 | 93µs | 1 | 267µs | # spent 267µs (222+45) within Foswiki::Query::Parser::BEGIN@44 which was called:
# once (222µs+45µs) by Foswiki::If::Parser::BEGIN@16 at line 44 # spent 267µs making 1 call to Foswiki::Query::Parser::BEGIN@44 |
45 | 2 | 86µs | 1 | 259µs | # spent 259µs (218+41) within Foswiki::Query::Parser::BEGIN@45 which was called:
# once (218µs+41µs) by Foswiki::If::Parser::BEGIN@16 at line 45 # spent 259µs making 1 call to Foswiki::Query::Parser::BEGIN@45 |
46 | 2 | 85µs | 1 | 349µs | # spent 349µs (303+46) within Foswiki::Query::Parser::BEGIN@46 which was called:
# once (303µs+46µs) by Foswiki::If::Parser::BEGIN@16 at line 46 # spent 349µs making 1 call to Foswiki::Query::Parser::BEGIN@46 |
47 | 2 | 85µs | 1 | 265µs | # spent 265µs (217+47) within Foswiki::Query::Parser::BEGIN@47 which was called:
# once (217µs+47µs) by Foswiki::If::Parser::BEGIN@16 at line 47 # spent 265µs making 1 call to Foswiki::Query::Parser::BEGIN@47 |
48 | 2 | 86µs | 1 | 306µs | # spent 306µs (261+45) within Foswiki::Query::Parser::BEGIN@48 which was called:
# once (261µs+45µs) by Foswiki::If::Parser::BEGIN@16 at line 48 # spent 306µs making 1 call to Foswiki::Query::Parser::BEGIN@48 |
49 | 2 | 85µs | 1 | 258µs | # spent 258µs (216+43) within Foswiki::Query::Parser::BEGIN@49 which was called:
# once (216µs+43µs) by Foswiki::If::Parser::BEGIN@16 at line 49 # spent 258µs making 1 call to Foswiki::Query::Parser::BEGIN@49 |
50 | 2 | 84µs | 1 | 302µs | # spent 302µs (259+43) within Foswiki::Query::Parser::BEGIN@50 which was called:
# once (259µs+43µs) by Foswiki::If::Parser::BEGIN@16 at line 50 # spent 302µs making 1 call to Foswiki::Query::Parser::BEGIN@50 |
51 | |||||
52 | 2 | 80µs | 1 | 300µs | # spent 300µs (259+40) within Foswiki::Query::Parser::BEGIN@52 which was called:
# once (259µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 52 # spent 300µs making 1 call to Foswiki::Query::Parser::BEGIN@52 |
53 | 2 | 92µs | 1 | 256µs | # spent 256µs (216+40) within Foswiki::Query::Parser::BEGIN@53 which was called:
# once (216µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 53 # spent 256µs making 1 call to Foswiki::Query::Parser::BEGIN@53 |
54 | |||||
55 | 2 | 83µs | 1 | 260µs | # spent 260µs (213+47) within Foswiki::Query::Parser::BEGIN@55 which was called:
# once (213µs+47µs) by Foswiki::If::Parser::BEGIN@16 at line 55 # spent 260µs making 1 call to Foswiki::Query::Parser::BEGIN@55 |
56 | 2 | 101µs | 1 | 313µs | # spent 313µs (264+49) within Foswiki::Query::Parser::BEGIN@56 which was called:
# once (264µs+49µs) by Foswiki::If::Parser::BEGIN@16 at line 56 # spent 313µs making 1 call to Foswiki::Query::Parser::BEGIN@56 |
57 | |||||
58 | 2 | 87µs | 1 | 698µs | # spent 698µs (510+188) within Foswiki::Query::Parser::BEGIN@58 which was called:
# once (510µs+188µs) by Foswiki::If::Parser::BEGIN@16 at line 58 # spent 698µs making 1 call to Foswiki::Query::Parser::BEGIN@58 |
59 | 2 | 91µs | 1 | 303µs | # spent 303µs (260+43) within Foswiki::Query::Parser::BEGIN@59 which was called:
# once (260µs+43µs) by Foswiki::If::Parser::BEGIN@16 at line 59 # spent 303µs making 1 call to Foswiki::Query::Parser::BEGIN@59 |
60 | |||||
61 | 2 | 94µs | 1 | 694µs | # spent 694µs (648+45) within Foswiki::Query::Parser::BEGIN@61 which was called:
# once (648µs+45µs) by Foswiki::If::Parser::BEGIN@16 at line 61 # spent 694µs making 1 call to Foswiki::Query::Parser::BEGIN@61 |
62 | |||||
63 | 2 | 85µs | 1 | 305µs | # spent 305µs (259+46) within Foswiki::Query::Parser::BEGIN@63 which was called:
# once (259µs+46µs) by Foswiki::If::Parser::BEGIN@16 at line 63 # spent 305µs making 1 call to Foswiki::Query::Parser::BEGIN@63 |
64 | 2 | 84µs | 1 | 300µs | # spent 300µs (254+45) within Foswiki::Query::Parser::BEGIN@64 which was called:
# once (254µs+45µs) by Foswiki::If::Parser::BEGIN@16 at line 64 # spent 300µs making 1 call to Foswiki::Query::Parser::BEGIN@64 |
65 | 2 | 86µs | 1 | 281µs | # spent 281µs (234+47) within Foswiki::Query::Parser::BEGIN@65 which was called:
# once (234µs+47µs) by Foswiki::If::Parser::BEGIN@16 at line 65 # spent 281µs making 1 call to Foswiki::Query::Parser::BEGIN@65 |
66 | 2 | 83µs | 1 | 279µs | # spent 279µs (239+40) within Foswiki::Query::Parser::BEGIN@66 which was called:
# once (239µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 66 # spent 279µs making 1 call to Foswiki::Query::Parser::BEGIN@66 |
67 | 2 | 85µs | 1 | 284µs | # spent 284µs (244+40) within Foswiki::Query::Parser::BEGIN@67 which was called:
# once (244µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 67 # spent 284µs making 1 call to Foswiki::Query::Parser::BEGIN@67 |
68 | 2 | 86µs | 1 | 318µs | # spent 318µs (272+46) within Foswiki::Query::Parser::BEGIN@68 which was called:
# once (272µs+46µs) by Foswiki::If::Parser::BEGIN@16 at line 68 # spent 318µs making 1 call to Foswiki::Query::Parser::BEGIN@68 |
69 | |||||
70 | 2 | 114µs | 1 | 239µs | # spent 239µs (198+41) within Foswiki::Query::Parser::BEGIN@70 which was called:
# once (198µs+41µs) by Foswiki::If::Parser::BEGIN@16 at line 70 # spent 239µs making 1 call to Foswiki::Query::Parser::BEGIN@70 |
71 | |||||
72 | =begin TML | ||||
73 | Query Language BNF | ||||
74 | <verbatim> | ||||
75 | expr ::= and_expr 'or' expr | and_expr; | ||||
76 | and_expr ::= not_expr 'and' and_expr | not_expr; | ||||
77 | not_expr ::= 'not' comma_expr | comma_expr; | ||||
78 | comma_expr ::= cmp_expr ',' comma_expr | cmp_expr; | ||||
79 | cmp_expr ::= add_expr cmp_op cm_expr | add_expr; | ||||
80 | cmp_op ::= '<=' | '>=' | '<' | '>' | '=' | '=~' | '~' | '!=' | 'in'; | ||||
81 | add_expr ::= mul_expr add_op add_expr | mul_expr; | ||||
82 | mul_expr ::= ref_expr mul_op mul_expr | ref_expr; | ||||
83 | mul_op ::= '*' | 'div'; | ||||
84 | ref_expr ::= u_expr ref_op ref_expr | u_expr; | ||||
85 | ref_op ::= '/' | '.'; | ||||
86 | u_expr ::= value uop u_expr | value; | ||||
87 | uop ::= 'lc' | 'uc' | 'd2n' | 'length' | '-' | 'int' | '@'; | ||||
88 | value ::= <name> | <string> | <number>; | ||||
89 | </verbatim> | ||||
90 | String and Numbers are as defined in Foswiki::Infix::Parser. Names default | ||||
91 | to =/([A-Z:][A-Z0-9_:]*|({[A-Z][A-Z0-9_]*})+)/i=. | ||||
92 | |||||
93 | See %SYSTEMWEB%.QuerySearch for details of the query language. | ||||
94 | |||||
95 | =cut | ||||
96 | |||||
97 | # Each operator is implemented by a class in Foswiki::Query. Note that | ||||
98 | # OP_empty is *not* included here; it is a pseudo-operator and does | ||||
99 | # not participate in parsing. | ||||
100 | 1 | 7µs | 1 | 32µs | # spent 43µs (11+32) within Foswiki::Query::Parser::BEGIN@100 which was called:
# once (11µs+32µs) by Foswiki::If::Parser::BEGIN@16 at line 102 # spent 32µs making 1 call to constant::import |
101 | uc dot gt like ne or where comma plus minus | ||||
102 | 1 | 157µs | 1 | 43µs | neg times div in int ); # spent 43µs making 1 call to Foswiki::Query::Parser::BEGIN@100 |
103 | |||||
104 | # spent 2.71ms (676µs+2.04) within Foswiki::Query::Parser::new which was called 3 times, avg 904µs/call:
# once (216µs+856µs) by Foswiki::If::Parser::new at line 46 of /var/www/foswikidev/core/lib/Foswiki/If/Parser.pm
# once (221µs+612µs) by Foswiki::Search::parseSearch at line 120 of /var/www/foswikidev/core/lib/Foswiki/Search.pm
# once (238µs+569µs) by Foswiki::QUERY at line 60 of /var/www/foswikidev/core/lib/Foswiki/Macros/QUERY.pm | ||||
105 | 3 | 3µs | my ( $class, $options ) = @_; | ||
106 | |||||
107 | 3 | 11µs | $options->{words} ||= qr/([A-Z:][A-Z0-9_:]*|({[A-Z][A-Z0-9_]*})+)/i; | ||
108 | 3 | 3µs | $options->{nodeClass} ||= 'Foswiki::Query::Node'; | ||
109 | 3 | 30µs | 3 | 50µs | my $this = $class->SUPER::new($options); # spent 50µs making 3 calls to Foswiki::Infix::Parser::new, avg 17µs/call |
110 | 3 | 14µs | 3 | 16µs | foreach my $op ( OPS() ) { # spent 16µs making 3 calls to constant::__ANON__[constant.pm:144], avg 5µs/call |
111 | 81 | 33µs | my $on = 'Foswiki::Query::OP_' . $op; | ||
112 | 81 | 459µs | 162 | 1.97ms | $this->addOperator( $on->new() ); # spent 165µs making 81 calls to Foswiki::Infix::Parser::addOperator, avg 2µs/call
# spent 112µs making 3 calls to Foswiki::Query::OP_match::new, avg 37µs/call
# spent 96µs making 3 calls to Foswiki::Query::OP_lc::new, avg 32µs/call
# spent 85µs making 3 calls to Foswiki::Query::OP_gt::new, avg 28µs/call
# spent 81µs making 3 calls to Foswiki::Query::OP_int::new, avg 27µs/call
# spent 79µs making 3 calls to Foswiki::Query::OP_ne::new, avg 26µs/call
# spent 76µs making 3 calls to Foswiki::Query::OP_like::new, avg 25µs/call
# spent 75µs making 3 calls to Foswiki::Query::OP_neg::new, avg 25µs/call
# spent 73µs making 3 calls to Foswiki::Query::OP_lt::new, avg 24µs/call
# spent 72µs making 3 calls to Foswiki::Query::OP_eq::new, avg 24µs/call
# spent 72µs making 3 calls to Foswiki::Query::OP_ob::new, avg 24µs/call
# spent 72µs making 3 calls to Foswiki::Query::OP_uc::new, avg 24µs/call
# spent 72µs making 3 calls to Foswiki::Query::OP_not::new, avg 24µs/call
# spent 71µs making 3 calls to Foswiki::Query::OP_d2n::new, avg 24µs/call
# spent 70µs making 3 calls to Foswiki::Query::OP_lte::new, avg 23µs/call
# spent 70µs making 3 calls to Foswiki::Query::OP_in::new, avg 23µs/call
# spent 69µs making 3 calls to Foswiki::Query::OP_length::new, avg 23µs/call
# spent 68µs making 3 calls to Foswiki::Query::OP_gte::new, avg 23µs/call
# spent 54µs making 3 calls to Foswiki::Query::OP_minus::new, avg 18µs/call
# spent 52µs making 3 calls to Foswiki::Query::OP_dot::new, avg 17µs/call
# spent 52µs making 3 calls to Foswiki::Query::OP_plus::new, avg 17µs/call
# spent 51µs making 3 calls to Foswiki::Query::OP_div::new, avg 17µs/call
# spent 50µs making 3 calls to Foswiki::Query::OP_and::new, avg 17µs/call
# spent 49µs making 3 calls to Foswiki::Query::OP_times::new, avg 16µs/call
# spent 49µs making 3 calls to Foswiki::Query::OP_ref::new, avg 16µs/call
# spent 48µs making 3 calls to Foswiki::Query::OP_or::new, avg 16µs/call
# spent 48µs making 3 calls to Foswiki::Query::OP_where::new, avg 16µs/call
# spent 42µs making 3 calls to Foswiki::Query::OP_comma::new, avg 14µs/call |
113 | } | ||||
114 | 3 | 14µs | return $this; | ||
115 | } | ||||
116 | |||||
117 | # Ensure there is at least one operand on the opstack when closing | ||||
118 | # a subexpression. | ||||
119 | sub onCloseExpr { | ||||
120 | my ( $this, $opands ) = @_; | ||||
121 | if ( !scalar(@$opands) ) { | ||||
122 | require Foswiki::Query::OP_empty; | ||||
123 | push( @$opands, $this->{node_factory}->emptyExpression() ); | ||||
124 | } | ||||
125 | } | ||||
126 | |||||
127 | 1 | 3µs | 1; | ||
128 | __END__ |