Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Query/Parser.pm |
Statements | Executed 248 statements in 11.7ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 5.63ms | 5.76ms | BEGIN@58 | Foswiki::Query::Parser::
1 | 1 | 1 | 2.84ms | 10.8ms | BEGIN@21 | Foswiki::Query::Parser::
3 | 3 | 3 | 1.85ms | 6.84ms | new | Foswiki::Query::Parser::
1 | 1 | 1 | 870µs | 1.41ms | BEGIN@51 | Foswiki::Query::Parser::
1 | 1 | 1 | 745µs | 819µs | BEGIN@54 | Foswiki::Query::Parser::
1 | 1 | 1 | 550µs | 628µs | BEGIN@38 | Foswiki::Query::Parser::
1 | 1 | 1 | 479µs | 558µs | BEGIN@27 | Foswiki::Query::Parser::
1 | 1 | 1 | 470µs | 547µs | BEGIN@52 | Foswiki::Query::Parser::
1 | 1 | 1 | 460µs | 575µs | BEGIN@45 | Foswiki::Query::Parser::
1 | 1 | 1 | 454µs | 527µs | BEGIN@39 | Foswiki::Query::Parser::
1 | 1 | 1 | 447µs | 522µs | BEGIN@29 | Foswiki::Query::Parser::
1 | 1 | 1 | 443µs | 519µs | BEGIN@41 | Foswiki::Query::Parser::
1 | 1 | 1 | 442µs | 523µs | BEGIN@61 | Foswiki::Query::Parser::
1 | 1 | 1 | 437µs | 512µs | BEGIN@60 | Foswiki::Query::Parser::
1 | 1 | 1 | 424µs | 509µs | BEGIN@43 | Foswiki::Query::Parser::
1 | 1 | 1 | 397µs | 471µs | BEGIN@59 | Foswiki::Query::Parser::
1 | 1 | 1 | 392µs | 469µs | BEGIN@37 | Foswiki::Query::Parser::
1 | 1 | 1 | 378µs | 452µs | BEGIN@49 | Foswiki::Query::Parser::
1 | 1 | 1 | 373µs | 448µs | BEGIN@56 | Foswiki::Query::Parser::
1 | 1 | 1 | 364µs | 439µs | BEGIN@36 | Foswiki::Query::Parser::
1 | 1 | 1 | 362µs | 439µs | BEGIN@48 | Foswiki::Query::Parser::
1 | 1 | 1 | 362µs | 435µs | BEGIN@46 | Foswiki::Query::Parser::
1 | 1 | 1 | 360µs | 437µs | BEGIN@40 | Foswiki::Query::Parser::
1 | 1 | 1 | 356µs | 432µs | BEGIN@42 | Foswiki::Query::Parser::
1 | 1 | 1 | 355µs | 435µs | BEGIN@57 | Foswiki::Query::Parser::
1 | 1 | 1 | 352µs | 1.19ms | BEGIN@35 | Foswiki::Query::Parser::
1 | 1 | 1 | 348µs | 825µs | BEGIN@31 | Foswiki::Query::Parser::
1 | 1 | 1 | 313µs | 387µs | BEGIN@63 | Foswiki::Query::Parser::
1 | 1 | 1 | 27µs | 34µs | BEGIN@17 | Foswiki::Query::Parser::
1 | 1 | 1 | 20µs | 37µs | BEGIN@18 | Foswiki::Query::Parser::
1 | 1 | 1 | 19µs | 131µs | BEGIN@93 | Foswiki::Query::Parser::
1 | 1 | 1 | 16µs | 56µs | BEGIN@19 | Foswiki::Query::Parser::
3 | 1 | 1 | 15µs | 15µs | CORE:qr (opcode) | Foswiki::Query::Parser::
1 | 1 | 1 | 11µs | 11µs | BEGIN@33 | Foswiki::Query::Parser::
1 | 1 | 1 | 10µs | 10µs | BEGIN@24 | 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 | 45µs | 2 | 41µs | # spent 34µs (27+7) within Foswiki::Query::Parser::BEGIN@17 which was called:
# once (27µs+7µs) by Foswiki::If::Parser::BEGIN@16 at line 17 # spent 34µs making 1 call to Foswiki::Query::Parser::BEGIN@17
# spent 7µs making 1 call to strict::import |
18 | 2 | 44µs | 2 | 54µs | # spent 37µs (20+17) within Foswiki::Query::Parser::BEGIN@18 which was called:
# once (20µs+17µs) by Foswiki::If::Parser::BEGIN@16 at line 18 # spent 37µs making 1 call to Foswiki::Query::Parser::BEGIN@18
# spent 17µs making 1 call to warnings::import |
19 | 2 | 44µs | 2 | 96µs | # spent 56µs (16+40) within Foswiki::Query::Parser::BEGIN@19 which was called:
# once (16µs+40µs) by Foswiki::If::Parser::BEGIN@16 at line 19 # spent 56µs making 1 call to Foswiki::Query::Parser::BEGIN@19
# spent 40µs making 1 call to Assert::import |
20 | |||||
21 | 2 | 182µs | 1 | 10.8ms | # spent 10.8ms (2.84+7.98) within Foswiki::Query::Parser::BEGIN@21 which was called:
# once (2.84ms+7.98ms) by Foswiki::If::Parser::BEGIN@16 at line 21 # spent 10.8ms making 1 call to Foswiki::Query::Parser::BEGIN@21 |
22 | 1 | 12µs | our @ISA = ('Foswiki::Infix::Parser'); | ||
23 | |||||
24 | 2 | 43µs | 1 | 10µs | # spent 10µs within Foswiki::Query::Parser::BEGIN@24 which was called:
# once (10µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 24 # spent 10µs making 1 call to Foswiki::Query::Parser::BEGIN@24 |
25 | |||||
26 | # operator name precedence | ||||
27 | 2 | 148µs | 1 | 558µs | # spent 558µs (479+79) within Foswiki::Query::Parser::BEGIN@27 which was called:
# once (479µs+79µs) by Foswiki::If::Parser::BEGIN@16 at line 27 # spent 558µs making 1 call to Foswiki::Query::Parser::BEGIN@27 |
28 | |||||
29 | 2 | 141µs | 1 | 522µs | # spent 522µs (447+75) within Foswiki::Query::Parser::BEGIN@29 which was called:
# once (447µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 29 # spent 522µs making 1 call to Foswiki::Query::Parser::BEGIN@29 |
30 | |||||
31 | 2 | 142µs | 1 | 825µs | # spent 825µs (348+477) within Foswiki::Query::Parser::BEGIN@31 which was called:
# once (348µs+477µs) by Foswiki::If::Parser::BEGIN@16 at line 31 # spent 825µs making 1 call to Foswiki::Query::Parser::BEGIN@31 |
32 | |||||
33 | 2 | 39µs | 1 | 11µs | # spent 11µs within Foswiki::Query::Parser::BEGIN@33 which was called:
# once (11µs+0s) by Foswiki::If::Parser::BEGIN@16 at line 33 # spent 11µs making 1 call to Foswiki::Query::Parser::BEGIN@33 |
34 | |||||
35 | 2 | 137µs | 1 | 1.19ms | # spent 1.19ms (352µs+837µs) within Foswiki::Query::Parser::BEGIN@35 which was called:
# once (352µs+837µs) by Foswiki::If::Parser::BEGIN@16 at line 35 # spent 1.19ms making 1 call to Foswiki::Query::Parser::BEGIN@35 |
36 | 2 | 131µs | 1 | 439µs | # spent 439µs (364+75) within Foswiki::Query::Parser::BEGIN@36 which was called:
# once (364µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 36 # spent 439µs making 1 call to Foswiki::Query::Parser::BEGIN@36 |
37 | 2 | 172µs | 1 | 469µs | # spent 469µs (392+77) within Foswiki::Query::Parser::BEGIN@37 which was called:
# once (392µs+77µs) by Foswiki::If::Parser::BEGIN@16 at line 37 # spent 469µs making 1 call to Foswiki::Query::Parser::BEGIN@37 |
38 | 2 | 330µs | 1 | 628µs | # spent 628µs (550+78) within Foswiki::Query::Parser::BEGIN@38 which was called:
# once (550µs+78µs) by Foswiki::If::Parser::BEGIN@16 at line 38 # spent 628µs making 1 call to Foswiki::Query::Parser::BEGIN@38 |
39 | 2 | 142µs | 1 | 527µs | # spent 527µs (454+74) within Foswiki::Query::Parser::BEGIN@39 which was called:
# once (454µs+74µs) by Foswiki::If::Parser::BEGIN@16 at line 39 # spent 527µs making 1 call to Foswiki::Query::Parser::BEGIN@39 |
40 | 2 | 141µs | 1 | 437µs | # spent 437µs (360+78) within Foswiki::Query::Parser::BEGIN@40 which was called:
# once (360µs+78µs) by Foswiki::If::Parser::BEGIN@16 at line 40 # spent 437µs making 1 call to Foswiki::Query::Parser::BEGIN@40 |
41 | 2 | 142µs | 1 | 519µs | # spent 519µs (443+76) within Foswiki::Query::Parser::BEGIN@41 which was called:
# once (443µs+76µs) by Foswiki::If::Parser::BEGIN@16 at line 41 # spent 519µs making 1 call to Foswiki::Query::Parser::BEGIN@41 |
42 | 2 | 141µs | 1 | 432µs | # spent 432µs (356+75) within Foswiki::Query::Parser::BEGIN@42 which was called:
# once (356µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 42 # spent 432µs making 1 call to Foswiki::Query::Parser::BEGIN@42 |
43 | 2 | 155µs | 1 | 509µs | # spent 509µs (424+85) within Foswiki::Query::Parser::BEGIN@43 which was called:
# once (424µs+85µs) by Foswiki::If::Parser::BEGIN@16 at line 43 # spent 509µs making 1 call to Foswiki::Query::Parser::BEGIN@43 |
44 | |||||
45 | 2 | 150µs | 1 | 575µs | # spent 575µs (460+115) within Foswiki::Query::Parser::BEGIN@45 which was called:
# once (460µs+115µs) by Foswiki::If::Parser::BEGIN@16 at line 45 # spent 575µs making 1 call to Foswiki::Query::Parser::BEGIN@45 |
46 | 2 | 142µs | 1 | 435µs | # spent 435µs (362+73) within Foswiki::Query::Parser::BEGIN@46 which was called:
# once (362µs+73µs) by Foswiki::If::Parser::BEGIN@16 at line 46 # spent 435µs making 1 call to Foswiki::Query::Parser::BEGIN@46 |
47 | |||||
48 | 2 | 144µs | 1 | 439µs | # spent 439µs (362+77) within Foswiki::Query::Parser::BEGIN@48 which was called:
# once (362µs+77µs) by Foswiki::If::Parser::BEGIN@16 at line 48 # spent 439µs making 1 call to Foswiki::Query::Parser::BEGIN@48 |
49 | 2 | 142µs | 1 | 452µs | # spent 452µs (378+75) within Foswiki::Query::Parser::BEGIN@49 which was called:
# once (378µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 49 # spent 452µs making 1 call to Foswiki::Query::Parser::BEGIN@49 |
50 | |||||
51 | 2 | 150µs | 1 | 1.41ms | # spent 1.41ms (870µs+538µs) within Foswiki::Query::Parser::BEGIN@51 which was called:
# once (870µs+538µs) by Foswiki::If::Parser::BEGIN@16 at line 51 # spent 1.41ms making 1 call to Foswiki::Query::Parser::BEGIN@51 |
52 | 2 | 163µs | 1 | 547µs | # spent 547µs (470+77) within Foswiki::Query::Parser::BEGIN@52 which was called:
# once (470µs+77µs) by Foswiki::If::Parser::BEGIN@16 at line 52 # spent 547µs making 1 call to Foswiki::Query::Parser::BEGIN@52 |
53 | |||||
54 | 2 | 144µs | 1 | 819µs | # spent 819µs (745+74) within Foswiki::Query::Parser::BEGIN@54 which was called:
# once (745µs+74µs) by Foswiki::If::Parser::BEGIN@16 at line 54 # spent 819µs making 1 call to Foswiki::Query::Parser::BEGIN@54 |
55 | |||||
56 | 2 | 137µs | 1 | 448µs | # spent 448µs (373+75) within Foswiki::Query::Parser::BEGIN@56 which was called:
# once (373µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 56 # spent 448µs making 1 call to Foswiki::Query::Parser::BEGIN@56 |
57 | 2 | 142µs | 1 | 435µs | # spent 435µs (355+80) within Foswiki::Query::Parser::BEGIN@57 which was called:
# once (355µs+80µs) by Foswiki::If::Parser::BEGIN@16 at line 57 # spent 435µs making 1 call to Foswiki::Query::Parser::BEGIN@57 |
58 | 2 | 5.33ms | 1 | 5.76ms | # spent 5.76ms (5.63+126µs) within Foswiki::Query::Parser::BEGIN@58 which was called:
# once (5.63ms+126µs) by Foswiki::If::Parser::BEGIN@16 at line 58 # spent 5.76ms making 1 call to Foswiki::Query::Parser::BEGIN@58 |
59 | 2 | 145µs | 1 | 471µs | # spent 471µs (397+74) within Foswiki::Query::Parser::BEGIN@59 which was called:
# once (397µs+74µs) by Foswiki::If::Parser::BEGIN@16 at line 59 # spent 471µs making 1 call to Foswiki::Query::Parser::BEGIN@59 |
60 | 2 | 138µs | 1 | 512µs | # spent 512µs (437+75) within Foswiki::Query::Parser::BEGIN@60 which was called:
# once (437µs+75µs) by Foswiki::If::Parser::BEGIN@16 at line 60 # spent 512µs making 1 call to Foswiki::Query::Parser::BEGIN@60 |
61 | 2 | 158µs | 1 | 523µs | # spent 523µs (442+81) within Foswiki::Query::Parser::BEGIN@61 which was called:
# once (442µs+81µs) by Foswiki::If::Parser::BEGIN@16 at line 61 # spent 523µs making 1 call to Foswiki::Query::Parser::BEGIN@61 |
62 | |||||
63 | 2 | 180µs | 1 | 387µs | # spent 387µs (313+74) within Foswiki::Query::Parser::BEGIN@63 which was called:
# once (313µs+74µs) by Foswiki::If::Parser::BEGIN@16 at line 63 # spent 387µs making 1 call to Foswiki::Query::Parser::BEGIN@63 |
64 | |||||
65 | =begin TML | ||||
66 | Query Language BNF | ||||
67 | <verbatim> | ||||
68 | expr ::= and_expr 'or' expr | and_expr; | ||||
69 | and_expr ::= not_expr 'and' and_expr | not_expr; | ||||
70 | not_expr ::= 'not' comma_expr | comma_expr; | ||||
71 | comma_expr ::= cmp_expr ',' comma_expr | cmp_expr; | ||||
72 | cmp_expr ::= add_expr cmp_op cm_expr | add_expr; | ||||
73 | cmp_op ::= '<=' | '>=' | '<' | '>' | '=' | '=~' | '~' | '!=' | 'in'; | ||||
74 | add_expr ::= mul_expr add_op add_expr | mul_expr; | ||||
75 | mul_expr ::= ref_expr mul_op mul_expr | ref_expr; | ||||
76 | mul_op ::= '*' | 'div'; | ||||
77 | ref_expr ::= u_expr ref_op ref_expr | u_expr; | ||||
78 | ref_op ::= '/' | '.'; | ||||
79 | u_expr ::= value uop u_expr | value; | ||||
80 | uop ::= 'lc' | 'uc' | 'd2n' | 'length' | '-' | 'int' | '@'; | ||||
81 | value ::= <name> | <string> | <number>; | ||||
82 | </verbatim> | ||||
83 | String and Numbers are as defined in Foswiki::Infix::Parser. Names default | ||||
84 | to =/([A-Z:][A-Z0-9_:]*|({[A-Z][A-Z0-9_]*})+)/i=. | ||||
85 | |||||
86 | See %SYSTEMWEB%.QuerySearch for details of the query language. | ||||
87 | |||||
88 | =cut | ||||
89 | |||||
90 | # Each operator is implemented by a class in Foswiki::Query. Note that | ||||
91 | # OP_empty is *not* included here; it is a pseudo-operator and does | ||||
92 | # not participate in parsing. | ||||
93 | 1 | 112µs | # spent 131µs (19+112) within Foswiki::Query::Parser::BEGIN@93 which was called:
# once (19µs+112µs) by Foswiki::If::Parser::BEGIN@16 at line 95 # spent 112µs making 1 call to constant::import | ||
94 | uc dot gt like ne or where comma plus minus | ||||
95 | 2 | 286µs | 1 | 131µs | neg times div in int ); # spent 131µs making 1 call to Foswiki::Query::Parser::BEGIN@93 |
96 | |||||
97 | # spent 6.84ms (1.85+4.99) within Foswiki::Query::Parser::new which was called 3 times, avg 2.28ms/call:
# once (662µs+2.12ms) by Foswiki::If::Parser::new at line 39 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/Parser.pm
# once (611µs+1.49ms) by Foswiki::Search::parseSearch at line 123 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Search.pm
# once (581µs+1.37ms) by Foswiki::QUERY at line 48 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/QUERY.pm | ||||
98 | 18 | 210µs | my ( $class, $options ) = @_; | ||
99 | |||||
100 | 3 | 15µs | $options->{words} ||= qr/([A-Z:][A-Z0-9_:]*|({[A-Z][A-Z0-9_]*})+)/i; # spent 15µs making 3 calls to Foswiki::Query::Parser::CORE:qr, avg 5µs/call | ||
101 | $options->{nodeClass} ||= 'Foswiki::Query::Node'; | ||||
102 | 3 | 165µs | my $this = $class->SUPER::new($options); # spent 165µs making 3 calls to Foswiki::Infix::Parser::new, avg 55µs/call | ||
103 | 3 | 42µs | foreach my $op ( OPS() ) { # spent 42µs making 3 calls to constant::__ANON__[constant.pm:140], avg 14µs/call | ||
104 | 162 | 1.61ms | my $on = 'Foswiki::Query::OP_' . $op; | ||
105 | 162 | 4.77ms | $this->addOperator( $on->new() ); # spent 909µs making 81 calls to Foswiki::Infix::Parser::addOperator, avg 11µs/call
# spent 253µs making 3 calls to Foswiki::Query::OP_match::new, avg 84µs/call
# spent 222µs making 3 calls to Foswiki::Query::OP_lc::new, avg 74µs/call
# spent 161µs making 3 calls to Foswiki::Query::OP_not::new, avg 54µs/call
# spent 159µs making 3 calls to Foswiki::Query::OP_d2n::new, avg 53µs/call
# spent 159µs making 3 calls to Foswiki::Query::OP_lte::new, avg 53µs/call
# spent 156µs making 3 calls to Foswiki::Query::OP_ne::new, avg 52µs/call
# spent 156µs making 3 calls to Foswiki::Query::OP_eq::new, avg 52µs/call
# spent 156µs making 3 calls to Foswiki::Query::OP_lt::new, avg 52µs/call
# spent 155µs making 3 calls to Foswiki::Query::OP_gte::new, avg 52µs/call
# spent 154µs making 3 calls to Foswiki::Query::OP_in::new, avg 51µs/call
# spent 152µs making 3 calls to Foswiki::Query::OP_uc::new, avg 51µs/call
# spent 148µs making 3 calls to Foswiki::Query::OP_gt::new, avg 49µs/call
# spent 148µs making 3 calls to Foswiki::Query::OP_neg::new, avg 49µs/call
# spent 147µs making 3 calls to Foswiki::Query::OP_or::new, avg 49µs/call
# spent 147µs making 3 calls to Foswiki::Query::OP_length::new, avg 49µs/call
# spent 147µs making 3 calls to Foswiki::Query::OP_ob::new, avg 49µs/call
# spent 146µs making 3 calls to Foswiki::Query::OP_like::new, avg 49µs/call
# spent 141µs making 3 calls to Foswiki::Query::OP_int::new, avg 47µs/call
# spent 128µs making 3 calls to Foswiki::Query::OP_and::new, avg 43µs/call
# spent 111µs making 3 calls to Foswiki::Query::OP_div::new, avg 37µs/call
# spent 108µs making 3 calls to Foswiki::Query::OP_plus::new, avg 36µs/call
# spent 108µs making 3 calls to Foswiki::Query::OP_ref::new, avg 36µs/call
# spent 105µs making 3 calls to Foswiki::Query::OP_dot::new, avg 35µs/call
# spent 103µs making 3 calls to Foswiki::Query::OP_where::new, avg 34µs/call
# spent 100µs making 3 calls to Foswiki::Query::OP_comma::new, avg 33µs/call
# spent 98µs making 3 calls to Foswiki::Query::OP_minus::new, avg 33µs/call
# spent 94µs making 3 calls to Foswiki::Query::OP_times::new, avg 31µs/call | ||
106 | } | ||||
107 | return $this; | ||||
108 | } | ||||
109 | |||||
110 | # Ensure there is at least one operand on the opstack when closing | ||||
111 | # a subexpression. | ||||
112 | sub onCloseExpr { | ||||
113 | my ( $this, $opands ) = @_; | ||||
114 | if ( !scalar(@$opands) ) { | ||||
115 | require Foswiki::Query::OP_empty; | ||||
116 | push( @$opands, $this->{node_factory}->emptyExpression() ); | ||||
117 | } | ||||
118 | } | ||||
119 | |||||
120 | 1 | 6µs | 1; | ||
121 | __END__ | ||||
# spent 15µs within Foswiki::Query::Parser::CORE:qr which was called 3 times, avg 5µs/call:
# 3 times (15µs+0s) by Foswiki::Query::Parser::new at line 100, avg 5µs/call |