@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * Function to get start and end date of present calendar quarter |
267 | 267 | * @param int $month |
268 | 268 | * @param DateTime $dateObject |
269 | - * @return date range of present quarter |
|
269 | + * @return string[] range of present quarter |
|
270 | 270 | */ |
271 | 271 | public static function getPresentQuarterRange($month = null, &$dateObject = null) |
272 | 272 | { |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * Function to get start and end date of previous calendar quarter |
300 | 300 | * @param int $month |
301 | 301 | * @param DateTime $dateObject |
302 | - * @return date range of present quarter |
|
302 | + * @return string[] range of present quarter |
|
303 | 303 | */ |
304 | 304 | public static function getPreviousQuarterRange($month = null, &$dateObject = null) |
305 | 305 | { |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * Function to get start and end date of next calendar quarter |
334 | 334 | * @param int $month |
335 | 335 | * @param DateTime $dateObject |
336 | - * @return date range of present quarter |
|
336 | + * @return string[] range of present quarter |
|
337 | 337 | */ |
338 | 338 | public static function getNextQuarterRange($month = null, $dateObject = null) |
339 | 339 | { |
@@ -29,6 +29,9 @@ |
||
29 | 29 | return $ns . '-' . $key; |
30 | 30 | } |
31 | 31 | |
32 | + /** |
|
33 | + * @param string $namespace |
|
34 | + */ |
|
32 | 35 | public function set($namespace, $key, $value) |
33 | 36 | { |
34 | 37 | $this->connection->set($this->cacheKey($namespace, $key), $value); |
@@ -24,8 +24,9 @@ |
||
24 | 24 | |
25 | 25 | protected function cacheKey($ns, $key) |
26 | 26 | { |
27 | - if (is_array($key)) |
|
28 | - $key = implode('-', $key); |
|
27 | + if (is_array($key)) { |
|
28 | + $key = implode('-', $key); |
|
29 | + } |
|
29 | 30 | return $ns . '-' . $key; |
30 | 31 | } |
31 | 32 |
@@ -11,11 +11,17 @@ |
||
11 | 11 | class Vtiger_Cache_Connector_Memory |
12 | 12 | { |
13 | 13 | |
14 | + /** |
|
15 | + * @param string $key |
|
16 | + */ |
|
14 | 17 | public function set($key, $value) |
15 | 18 | { |
16 | 19 | $this->$key = $value; |
17 | 20 | } |
18 | 21 | |
22 | + /** |
|
23 | + * @param string $key |
|
24 | + */ |
|
19 | 25 | public function get($key) |
20 | 26 | { |
21 | 27 | return isset($this->$key) ? $this->$key : false; |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Function to get or set a global variable |
13 | - * @param type $key |
|
13 | + * @param string $key |
|
14 | 14 | * @param type $value |
15 | 15 | * @return value of the given key |
16 | 16 | */ |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
18 | - * @param WebserviceId $id |
|
18 | + * @param string $id |
|
19 | 19 | * @param String $oldPassword |
20 | 20 | * @param String $newPassword |
21 | 21 | * @param String $confirmPassword |
@@ -12,6 +12,8 @@ |
||
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @author MAK |
15 | + * @param string $id |
|
16 | + * @param string $newOwnerId |
|
15 | 17 | */ |
16 | 18 | function vtws_deleteUser($id, $newOwnerId, $user) |
17 | 19 | { |
@@ -38,6 +38,9 @@ discard block |
||
38 | 38 | RecalculateSharingRules(); |
39 | 39 | } |
40 | 40 | |
41 | + /** |
|
42 | + * @param string $location |
|
43 | + */ |
|
41 | 44 | public function initializeDatabase($location, $filesName = array()) |
42 | 45 | { |
43 | 46 | $this->db->query('SET FOREIGN_KEY_CHECKS = 0;'); |
@@ -101,6 +104,9 @@ discard block |
||
101 | 104 | createUserPrivilegesfile(1); |
102 | 105 | } |
103 | 106 | |
107 | + /** |
|
108 | + * @param string $query |
|
109 | + */ |
|
104 | 110 | public function _splitQueries($query) |
105 | 111 | { |
106 | 112 | $buffer = array(); |
@@ -267,8 +267,9 @@ |
||
267 | 267 | if ($rootDirectory && strpos($src, $rootDirectory) === false) { |
268 | 268 | $src = $rootDirectory . $src; |
269 | 269 | } |
270 | - if (!file_exists($src) || !$rootDirectory) |
|
271 | - return; |
|
270 | + if (!file_exists($src) || !$rootDirectory) { |
|
271 | + return; |
|
272 | + } |
|
272 | 273 | @chmod($src, 0777); |
273 | 274 | \App\Log::trace("Exiting VT620_to_YT::testest(" . $src . ") method ..."); |
274 | 275 | if (is_dir($src)) { |
@@ -48,6 +48,7 @@ discard block |
||
48 | 48 | * in a rule will cause an exception and immediate exit from |
49 | 49 | * rule. Rule would recover by resynchronizing to the set of |
50 | 50 | * symbols that can follow rule ref. |
51 | + * @param Set $follow |
|
51 | 52 | */ |
52 | 53 | public function match($input, $ttype, $follow) |
53 | 54 | { |
@@ -490,6 +491,9 @@ discard block |
||
490 | 491 | return $this->combineFollows(true); |
491 | 492 | } |
492 | 493 | |
494 | + /** |
|
495 | + * @param boolean $exact |
|
496 | + */ |
|
493 | 497 | protected function combineFollows($exact) { |
494 | 498 | $top = $this->state->_fsp; |
495 | 499 | $followSet = new Set(array()); |
@@ -832,6 +836,9 @@ discard block |
||
832 | 836 | echo "\n"; |
833 | 837 | } |
834 | 838 | |
839 | + /** |
|
840 | + * @param string $name |
|
841 | + */ |
|
835 | 842 | public function getToken($name){ |
836 | 843 | if(preg_match("/\d+/", $name)){ |
837 | 844 | return (integer)$name; |
@@ -88,9 +88,9 @@ |
||
88 | 88 | if ( $follow->member(TokenConst::$EOR_TOKEN_TYPE) ) { |
89 | 89 | $viableTokensFollowingThisRule = $this->computeContextSensitiveRuleFOLLOW(); |
90 | 90 | $follow = $follow->union($viableTokensFollowingThisRule); |
91 | - if ( $this->state->_fsp>=0 ) { // remove EOR if we're not the start symbol |
|
92 | - $follow->remove(TokenConst::$EOR_TOKEN_TYPE); |
|
93 | - } |
|
91 | + if ( $this->state->_fsp>=0 ) { // remove EOR if we're not the start symbol |
|
92 | + $follow->remove(TokenConst::$EOR_TOKEN_TYPE); |
|
93 | + } |
|
94 | 94 | } |
95 | 95 | // if current token is consistent with what could come after set |
96 | 96 | // then we know we're missing a token; error recovery is free to |
@@ -119,8 +119,7 @@ discard block |
||
119 | 119 | { |
120 | 120 | if ( $this->mismatchIsUnwantedToken($input, $ttype) ) { |
121 | 121 | throw new UnwantedTokenException($ttype, $input); |
122 | - } |
|
123 | - else if ( $this->mismatchIsMissingToken($input, $follow) ) { |
|
122 | + } else if ( $this->mismatchIsMissingToken($input, $follow) ) { |
|
124 | 123 | throw new MissingTokenException($ttype, $input, null); |
125 | 124 | } |
126 | 125 | throw new MismatchedTokenException($ttype, $input); |
@@ -190,72 +189,60 @@ discard block |
||
190 | 189 | $tokenName="<unknown>"; |
191 | 190 | if ( $ute->expecting== TokenConst::$EOF ) { |
192 | 191 | $tokenName = "EOF"; |
193 | - } |
|
194 | - else { |
|
192 | + } else { |
|
195 | 193 | $tokenName = $tokenNames[$ute->expecting]; |
196 | 194 | } |
197 | 195 | $msg = "extraneous input ".$this->getTokenErrorDisplay($ute->getUnexpectedToken()). |
198 | 196 | " expecting ".$tokenName; |
199 | - } |
|
200 | - else if ( $e instanceof MissingTokenException ) { |
|
197 | + } else if ( $e instanceof MissingTokenException ) { |
|
201 | 198 | $mte = $e; |
202 | 199 | $tokenName="<unknown>"; |
203 | 200 | if ( $mte->expecting== TokenConst::$EOF ) { |
204 | 201 | $tokenName = "EOF"; |
205 | - } |
|
206 | - else { |
|
202 | + } else { |
|
207 | 203 | $tokenName = $tokenNames[$mte->expecting]; |
208 | 204 | } |
209 | 205 | $msg = "missing ".$tokenName." at ".$this->getTokenErrorDisplay($e->token); |
210 | - } |
|
211 | - else if ( $e instanceof MismatchedTokenException ) { |
|
206 | + } else if ( $e instanceof MismatchedTokenException ) { |
|
212 | 207 | $mte = $e; |
213 | 208 | $tokenName="<unknown>"; |
214 | 209 | if ( $mte->expecting== TokenConst::$EOF ) { |
215 | 210 | $tokenName = "EOF"; |
216 | - } |
|
217 | - else { |
|
211 | + } else { |
|
218 | 212 | $tokenName = $tokenNames[$mte->expecting]; |
219 | 213 | } |
220 | 214 | $msg = "mismatched input ".$this->getTokenErrorDisplay($e->token). |
221 | 215 | " expecting ".$tokenName; |
222 | - } |
|
223 | - else if ( $e instanceof MismatchedTreeNodeException ) { |
|
216 | + } else if ( $e instanceof MismatchedTreeNodeException ) { |
|
224 | 217 | $mtne = $e; |
225 | 218 | $tokenName="<unknown>"; |
226 | 219 | if ( $mtne->expecting==TokenConst::$EOF ) { |
227 | 220 | $tokenName = "EOF"; |
228 | - } |
|
229 | - else { |
|
221 | + } else { |
|
230 | 222 | $tokenName = $tokenNames[$mtne->expecting]; |
231 | 223 | } |
232 | 224 | $msg = "mismatched tree node: ".$mtne->node. |
233 | 225 | " expecting ".$tokenName; |
234 | - } |
|
235 | - else if ( $e instanceof NoViableAltException ) { |
|
226 | + } else if ( $e instanceof NoViableAltException ) { |
|
236 | 227 | $nvae = $e; |
237 | 228 | // for development, can add "decision=<<"+nvae.grammarDecisionDescription+">>" |
238 | 229 | // and "(decision="+nvae.decisionNumber+") and |
239 | 230 | // "state "+nvae.stateNumber |
240 | 231 | $msg = "no viable alternative at input ".$this->getTokenErrorDisplay($e->token); |
241 | - } |
|
242 | - else if ( $e instanceof EarlyExitException ) { |
|
232 | + } else if ( $e instanceof EarlyExitException ) { |
|
243 | 233 | $eee = $e; |
244 | 234 | // for development, can add "(decision="+eee.decisionNumber+")" |
245 | 235 | $msg = "required (...)+ loop did not match anything at input ". |
246 | 236 | getTokenErrorDisplay($e->token); |
247 | - } |
|
248 | - else if ( $e instanceof MismatchedSetException ) { |
|
237 | + } else if ( $e instanceof MismatchedSetException ) { |
|
249 | 238 | $mse = $e; |
250 | 239 | $msg = "mismatched input ".$this->getTokenErrorDisplay($e->token). |
251 | 240 | " expecting set ".$mse->expecting; |
252 | - } |
|
253 | - else if ( $e instanceof MismatchedNotSetException ) { |
|
241 | + } else if ( $e instanceof MismatchedNotSetException ) { |
|
254 | 242 | $mse = $e; |
255 | 243 | $msg = "mismatched input ".$this->getTokenErrorDisplay($e->token). |
256 | 244 | " expecting set ".$mse->expecting; |
257 | - } |
|
258 | - else if ( $e instanceof FailedPredicateException ) { |
|
245 | + } else if ( $e instanceof FailedPredicateException ) { |
|
259 | 246 | $fpe = $e; |
260 | 247 | $msg = "rule ".$fpe->ruleName." failed predicate: {". |
261 | 248 | $fpe->predicateText."}?"; |
@@ -293,8 +280,7 @@ discard block |
||
293 | 280 | if ( $s==null ) { |
294 | 281 | if ( $t->getType()==TokenConst::$EOF ) { |
295 | 282 | $s = "<EOF>"; |
296 | - } |
|
297 | - else { |
|
283 | + } else { |
|
298 | 284 | $s = "<".$t->getType().">"; |
299 | 285 | } |
300 | 286 | } |
@@ -508,8 +494,7 @@ discard block |
||
508 | 494 | if ( $i>0 ) { |
509 | 495 | $followSet->remove(TokenConst::$EOR_TOKEN_TYPE); |
510 | 496 | } |
511 | - } |
|
512 | - else { // can't see end of rule, quit |
|
497 | + } else { // can't see end of rule, quit |
|
513 | 498 | break; |
514 | 499 | } |
515 | 500 | } |
@@ -725,7 +710,9 @@ discard block |
||
725 | 710 | * Convert a List<Token> to List<String> |
726 | 711 | */ |
727 | 712 | public function toStrings($tokens) { |
728 | - if ( $tokens==null ) return null; |
|
713 | + if ( $tokens==null ) { |
|
714 | + return null; |
|
715 | + } |
|
729 | 716 | $strings = array(); |
730 | 717 | for ($i=0; $i<$tokens->size(); $i++) { |
731 | 718 | $strings[] = $tokens[$i]->getText(); |
@@ -772,8 +759,7 @@ discard block |
||
772 | 759 | if ( $stopIndex==self::$MEMO_RULE_FAILED ) { |
773 | 760 | //System.out.println("rule "+ruleIndex+" will never succeed"); |
774 | 761 | $this->state->failed=true; |
775 | - } |
|
776 | - else { |
|
762 | + } else { |
|
777 | 763 | //System.out.println("seen rule "+ruleIndex+" before; skipping ahead to @"+(stopIndex+1)+" failed="+state.failed); |
778 | 764 | $input->seek($stopIndex+1); // jump to one past stop token |
779 | 765 | } |
@@ -835,7 +821,7 @@ discard block |
||
835 | 821 | public function getToken($name){ |
836 | 822 | if(preg_match("/\d+/", $name)){ |
837 | 823 | return (integer)$name; |
838 | - }else{ |
|
824 | + } else{ |
|
839 | 825 | return $this->$name; |
840 | 826 | } |
841 | 827 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -abstract class BaseRecognizer{ |
|
3 | +abstract class BaseRecognizer { |
|
4 | 4 | |
5 | 5 | public static $MEMO_RULE_FAILED = -2; |
6 | 6 | public static $MEMO_RULE_UNKNOWN = -1; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | public static $NEXT_TOKEN_RULE_NAME = "nextToken"; |
14 | 14 | |
15 | 15 | public function __construct($state = null) { |
16 | - if ( $state==null ) { |
|
16 | + if ($state == null) { |
|
17 | 17 | $state = new RecognizerSharedState(); |
18 | 18 | } |
19 | 19 | $this->state = $state; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** reset the parser's state; subclasses must rewinds the input stream */ |
23 | 23 | public function reset() { |
24 | 24 | // wack everything related to error recovery |
25 | - if ( $this->state==null ) { |
|
25 | + if ($this->state == null) { |
|
26 | 26 | return; // no shared state work to do |
27 | 27 | } |
28 | 28 | $this->state->_fsp = -1; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $this->state->syntaxErrors = 0; |
33 | 33 | // wack everything related to backtracking and memoization |
34 | 34 | $this->state->backtracking = 0; |
35 | - for ($i = 0; $this->state->ruleMemo!=null && $i < $this->state->ruleMemo->length; $i++) { // wipe cache |
|
35 | + for ($i = 0; $this->state->ruleMemo != null && $i < $this->state->ruleMemo->length; $i++) { // wipe cache |
|
36 | 36 | $this->state->ruleMemo[$i] = null; |
37 | 37 | } |
38 | 38 | } |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | { |
54 | 54 | //System.out.println("match "+((TokenStream)input).LT(1)); |
55 | 55 | $matchedSymbol = $this->getCurrentInputSymbol($input); |
56 | - if ( $input->LA(1)==$ttype ) { |
|
56 | + if ($input->LA(1) == $ttype) { |
|
57 | 57 | $input->consume(); |
58 | 58 | $this->state->errorRecovery = false; |
59 | 59 | $this->state->failed = false; |
60 | 60 | return $matchedSymbol; |
61 | 61 | } |
62 | - if ( $this->state->backtracking>0 ) { |
|
62 | + if ($this->state->backtracking > 0) { |
|
63 | 63 | $this->state->failed = true; |
64 | 64 | return $matchedSymbol; |
65 | 65 | } |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public function mismatchIsUnwantedToken($input, $ttype) { |
78 | - return $input->LA(2)==$ttype; |
|
78 | + return $input->LA(2) == $ttype; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function mismatchIsMissingToken($input, $follow) { |
82 | - if ( $follow==null ) { |
|
82 | + if ($follow == null) { |
|
83 | 83 | // we have no information about the follow; we can only consume |
84 | 84 | // a single token and hope for the best |
85 | 85 | return $false; |
86 | 86 | } |
87 | 87 | // compute what can follow this grammar element reference |
88 | - if ( $follow->member(TokenConst::$EOR_TOKEN_TYPE) ) { |
|
88 | + if ($follow->member(TokenConst::$EOR_TOKEN_TYPE)) { |
|
89 | 89 | $viableTokensFollowingThisRule = $this->computeContextSensitiveRuleFOLLOW(); |
90 | 90 | $follow = $follow->union($viableTokensFollowingThisRule); |
91 | - if ( $this->state->_fsp>=0 ) { // remove EOR if we're not the start symbol |
|
91 | + if ($this->state->_fsp >= 0) { // remove EOR if we're not the start symbol |
|
92 | 92 | $follow->remove(TokenConst::$EOR_TOKEN_TYPE); |
93 | 93 | } |
94 | 94 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | // BitSet cannot handle negative numbers like -1 (EOF) so I leave EOR |
103 | 103 | // in follow set to indicate that the fall of the start symbol is |
104 | 104 | // in the set (EOF can follow). |
105 | - if ( $follow->member($input->LA(1)) || $follow->member(TokenConst::$EOR_TOKEN_TYPE) ) { |
|
105 | + if ($follow->member($input->LA(1)) || $follow->member(TokenConst::$EOR_TOKEN_TYPE)) { |
|
106 | 106 | //System.out.println("LT(1)=="+((TokenStream)input).LT(1)+" is consistent with what follows; inserting..."); |
107 | 107 | return true; |
108 | 108 | } |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function mismatch($input, $ttype, $follow) |
119 | 119 | { |
120 | - if ( $this->mismatchIsUnwantedToken($input, $ttype) ) { |
|
120 | + if ($this->mismatchIsUnwantedToken($input, $ttype)) { |
|
121 | 121 | throw new UnwantedTokenException($ttype, $input); |
122 | 122 | } |
123 | - else if ( $this->mismatchIsMissingToken($input, $follow) ) { |
|
123 | + else if ($this->mismatchIsMissingToken($input, $follow)) { |
|
124 | 124 | throw new MissingTokenException($ttype, $input, null); |
125 | 125 | } |
126 | 126 | throw new MismatchedTokenException($ttype, $input); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public function reportError($e) { |
145 | 145 | // if we've already reported an error and have not matched a token |
146 | 146 | // yet successfully, don't report any errors. |
147 | - if ( $this->state->errorRecovery ) { |
|
147 | + if ($this->state->errorRecovery) { |
|
148 | 148 | //System.err.print("[SPURIOUS] "); |
149 | 149 | return; |
150 | 150 | } |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | |
158 | - public function displayRecognitionError($tokenNames, $e){ |
|
158 | + public function displayRecognitionError($tokenNames, $e) { |
|
159 | 159 | $hdr = $this->getErrorHeader($e); |
160 | 160 | $msg = $this->getErrorMessage($e, $tokenNames); |
161 | - $this->emitErrorMessage($hdr." ".$msg); |
|
161 | + $this->emitErrorMessage($hdr . " " . $msg); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** What error message should be generated for the various |
@@ -185,80 +185,80 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function getErrorMessage($e, $tokenNames) { |
187 | 187 | $msg = $e->getMessage(); |
188 | - if ( $e instanceof UnwantedTokenException ) { |
|
188 | + if ($e instanceof UnwantedTokenException) { |
|
189 | 189 | $ute = $e; |
190 | - $tokenName="<unknown>"; |
|
191 | - if ( $ute->expecting== TokenConst::$EOF ) { |
|
190 | + $tokenName = "<unknown>"; |
|
191 | + if ($ute->expecting == TokenConst::$EOF) { |
|
192 | 192 | $tokenName = "EOF"; |
193 | 193 | } |
194 | 194 | else { |
195 | 195 | $tokenName = $tokenNames[$ute->expecting]; |
196 | 196 | } |
197 | - $msg = "extraneous input ".$this->getTokenErrorDisplay($ute->getUnexpectedToken()). |
|
198 | - " expecting ".$tokenName; |
|
197 | + $msg = "extraneous input " . $this->getTokenErrorDisplay($ute->getUnexpectedToken()) . |
|
198 | + " expecting " . $tokenName; |
|
199 | 199 | } |
200 | - else if ( $e instanceof MissingTokenException ) { |
|
200 | + else if ($e instanceof MissingTokenException) { |
|
201 | 201 | $mte = $e; |
202 | - $tokenName="<unknown>"; |
|
203 | - if ( $mte->expecting== TokenConst::$EOF ) { |
|
202 | + $tokenName = "<unknown>"; |
|
203 | + if ($mte->expecting == TokenConst::$EOF) { |
|
204 | 204 | $tokenName = "EOF"; |
205 | 205 | } |
206 | 206 | else { |
207 | 207 | $tokenName = $tokenNames[$mte->expecting]; |
208 | 208 | } |
209 | - $msg = "missing ".$tokenName." at ".$this->getTokenErrorDisplay($e->token); |
|
209 | + $msg = "missing " . $tokenName . " at " . $this->getTokenErrorDisplay($e->token); |
|
210 | 210 | } |
211 | - else if ( $e instanceof MismatchedTokenException ) { |
|
211 | + else if ($e instanceof MismatchedTokenException) { |
|
212 | 212 | $mte = $e; |
213 | - $tokenName="<unknown>"; |
|
214 | - if ( $mte->expecting== TokenConst::$EOF ) { |
|
213 | + $tokenName = "<unknown>"; |
|
214 | + if ($mte->expecting == TokenConst::$EOF) { |
|
215 | 215 | $tokenName = "EOF"; |
216 | 216 | } |
217 | 217 | else { |
218 | 218 | $tokenName = $tokenNames[$mte->expecting]; |
219 | 219 | } |
220 | - $msg = "mismatched input ".$this->getTokenErrorDisplay($e->token). |
|
221 | - " expecting ".$tokenName; |
|
220 | + $msg = "mismatched input " . $this->getTokenErrorDisplay($e->token) . |
|
221 | + " expecting " . $tokenName; |
|
222 | 222 | } |
223 | - else if ( $e instanceof MismatchedTreeNodeException ) { |
|
223 | + else if ($e instanceof MismatchedTreeNodeException) { |
|
224 | 224 | $mtne = $e; |
225 | - $tokenName="<unknown>"; |
|
226 | - if ( $mtne->expecting==TokenConst::$EOF ) { |
|
225 | + $tokenName = "<unknown>"; |
|
226 | + if ($mtne->expecting == TokenConst::$EOF) { |
|
227 | 227 | $tokenName = "EOF"; |
228 | 228 | } |
229 | 229 | else { |
230 | 230 | $tokenName = $tokenNames[$mtne->expecting]; |
231 | 231 | } |
232 | - $msg = "mismatched tree node: ".$mtne->node. |
|
233 | - " expecting ".$tokenName; |
|
232 | + $msg = "mismatched tree node: " . $mtne->node . |
|
233 | + " expecting " . $tokenName; |
|
234 | 234 | } |
235 | - else if ( $e instanceof NoViableAltException ) { |
|
235 | + else if ($e instanceof NoViableAltException) { |
|
236 | 236 | $nvae = $e; |
237 | 237 | // for development, can add "decision=<<"+nvae.grammarDecisionDescription+">>" |
238 | 238 | // and "(decision="+nvae.decisionNumber+") and |
239 | 239 | // "state "+nvae.stateNumber |
240 | - $msg = "no viable alternative at input ".$this->getTokenErrorDisplay($e->token); |
|
240 | + $msg = "no viable alternative at input " . $this->getTokenErrorDisplay($e->token); |
|
241 | 241 | } |
242 | - else if ( $e instanceof EarlyExitException ) { |
|
242 | + else if ($e instanceof EarlyExitException) { |
|
243 | 243 | $eee = $e; |
244 | 244 | // for development, can add "(decision="+eee.decisionNumber+")" |
245 | - $msg = "required (...)+ loop did not match anything at input ". |
|
245 | + $msg = "required (...)+ loop did not match anything at input " . |
|
246 | 246 | getTokenErrorDisplay($e->token); |
247 | 247 | } |
248 | - else if ( $e instanceof MismatchedSetException ) { |
|
248 | + else if ($e instanceof MismatchedSetException) { |
|
249 | 249 | $mse = $e; |
250 | - $msg = "mismatched input ".$this->getTokenErrorDisplay($e->token). |
|
251 | - " expecting set ".$mse->expecting; |
|
250 | + $msg = "mismatched input " . $this->getTokenErrorDisplay($e->token) . |
|
251 | + " expecting set " . $mse->expecting; |
|
252 | 252 | } |
253 | - else if ( $e instanceof MismatchedNotSetException ) { |
|
253 | + else if ($e instanceof MismatchedNotSetException) { |
|
254 | 254 | $mse = $e; |
255 | - $msg = "mismatched input ".$this->getTokenErrorDisplay($e->token). |
|
256 | - " expecting set ".$mse->expecting; |
|
255 | + $msg = "mismatched input " . $this->getTokenErrorDisplay($e->token) . |
|
256 | + " expecting set " . $mse->expecting; |
|
257 | 257 | } |
258 | - else if ( $e instanceof FailedPredicateException ) { |
|
258 | + else if ($e instanceof FailedPredicateException) { |
|
259 | 259 | $fpe = $e; |
260 | - $msg = "rule ".$fpe->ruleName." failed predicate: {". |
|
261 | - $fpe->predicateText."}?"; |
|
260 | + $msg = "rule " . $fpe->ruleName . " failed predicate: {" . |
|
261 | + $fpe->predicateText . "}?"; |
|
262 | 262 | } |
263 | 263 | return $msg; |
264 | 264 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | /** What is the error header, normally line/character position information? */ |
278 | 278 | public function getErrorHeader($e) { |
279 | - return "line ".$e->line.":".$e->charPositionInLine; |
|
279 | + return "line " . $e->line . ":" . $e->charPositionInLine; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | */ |
291 | 291 | public function getTokenErrorDisplay($t) { |
292 | 292 | $s = $t->getText(); |
293 | - if ( $s==null ) { |
|
294 | - if ( $t->getType()==TokenConst::$EOF ) { |
|
293 | + if ($s == null) { |
|
294 | + if ($t->getType() == TokenConst::$EOF) { |
|
295 | 295 | $s = "<EOF>"; |
296 | 296 | } |
297 | 297 | else { |
298 | - $s = "<".$t->getType().">"; |
|
298 | + $s = "<" . $t->getType() . ">"; |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | $s = str_replace("\n", '\n', $s); |
302 | - $s = str_replace("\r",'\r', $s); |
|
303 | - $s = str_replace("\t",'\t', $s); |
|
304 | - return "'".$s."'"; |
|
302 | + $s = str_replace("\r", '\r', $s); |
|
303 | + $s = str_replace("\t", '\t', $s); |
|
304 | + return "'" . $s . "'"; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** Override this method to change where error messages go */ |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * token that the match() routine could not recover from. |
317 | 317 | */ |
318 | 318 | public function recover($input, $re = null) { |
319 | - if ( $this->state->lastErrorIndex==$input->index() ) { |
|
319 | + if ($this->state->lastErrorIndex == $input->index()) { |
|
320 | 320 | // uh oh, another error at same token index; must be a case |
321 | 321 | // where LT(1) is in the recovery token set so nothing is |
322 | 322 | // consumed; consume a single token so at least to prevent |
@@ -493,19 +493,19 @@ discard block |
||
493 | 493 | protected function combineFollows($exact) { |
494 | 494 | $top = $this->state->_fsp; |
495 | 495 | $followSet = new Set(array()); |
496 | - for ($i=$top; $i>=0; $i--) { |
|
496 | + for ($i = $top; $i >= 0; $i--) { |
|
497 | 497 | $localFollowSet = $this->state->following[$i]; |
498 | 498 | /* |
499 | 499 | System.out.println("local follow depth "+i+"="+ |
500 | 500 | localFollowSet.toString(getTokenNames())+")"); |
501 | 501 | */ |
502 | 502 | $followSet->unionInPlace($localFollowSet); |
503 | - if ( $this->exact ) { |
|
503 | + if ($this->exact) { |
|
504 | 504 | // can we see end of rule? |
505 | - if ( $localFollowSet->member(TokenConst::$EOR_TOKEN_TYPE) ) { |
|
505 | + if ($localFollowSet->member(TokenConst::$EOR_TOKEN_TYPE)) { |
|
506 | 506 | // Only leave EOR in set if at top (start rule); this lets |
507 | 507 | // us know if have to include follow(start rule); i.e., EOF |
508 | - if ( $i>0 ) { |
|
508 | + if ($i > 0) { |
|
509 | 509 | $followSet->remove(TokenConst::$EOR_TOKEN_TYPE); |
510 | 510 | } |
511 | 511 | } |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | $e = null; |
552 | 552 | // if next token is what we are looking for then "delete" this token |
553 | 553 | |
554 | - if ( $this->mismatchIsUnwantedToken($input, $ttype) ) { |
|
554 | + if ($this->mismatchIsUnwantedToken($input, $ttype)) { |
|
555 | 555 | $e = new UnwantedTokenException($ttype, $input); |
556 | 556 | /* |
557 | 557 | System.err.println("recoverFromMismatchedToken deleting "+ |
@@ -561,17 +561,17 @@ discard block |
||
561 | 561 | $this->beginResync(); |
562 | 562 | $input->consume(); // simply delete extra token |
563 | 563 | $this->endResync(); |
564 | - $this->reportError($e); // report after consuming so AW sees the token in the exception |
|
564 | + $this->reportError($e); // report after consuming so AW sees the token in the exception |
|
565 | 565 | // we want to return the token we're actually matching |
566 | 566 | $matchedSymbol = $this->getCurrentInputSymbol($input); |
567 | 567 | $input->consume(); // move past ttype token as if all were ok |
568 | 568 | return $matchedSymbol; |
569 | 569 | } |
570 | 570 | // can't recover with single token deletion, try insertion |
571 | - if ( $this->mismatchIsMissingToken($input, $follow) ) { |
|
571 | + if ($this->mismatchIsMissingToken($input, $follow)) { |
|
572 | 572 | $inserted = $this->getMissingSymbol($input, $e, $ttype, $follow); |
573 | 573 | $e = new MissingTokenException($ttype, $input, $inserted); |
574 | - $this->reportError($e); // report after inserting so AW sees the token in the exception |
|
574 | + $this->reportError($e); // report after inserting so AW sees the token in the exception |
|
575 | 575 | return $inserted; |
576 | 576 | } |
577 | 577 | // even that didn't work; must throw the exception |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | |
582 | 582 | /** Not currently used */ |
583 | 583 | public function recoverFromMismatchedSet($input, $e, $follow) { |
584 | - if ( $this->mismatchIsMissingToken($input, $follow) ) { |
|
584 | + if ($this->mismatchIsMissingToken($input, $follow)) { |
|
585 | 585 | // System.out.println("missing token"); |
586 | 586 | reportError($e); |
587 | 587 | // we don't know how to conjure up a token for sets yet |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | public function consumeUntilInSet($input, $set) { |
638 | 638 | //System.out.println("consumeUntil("+set.toString(getTokenNames())+")"); |
639 | 639 | $ttype = $input->LA(1); |
640 | - while ($ttype != TokenConst::$EOF && !$set->member($ttype) ) { |
|
640 | + while ($ttype != TokenConst::$EOF && !$set->member($ttype)) { |
|
641 | 641 | //System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]); |
642 | 642 | $input->consume(); |
643 | 643 | $ttype = $input->LA(1); |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | $this->state->following[++$this->state->_fsp] = $fset; |
655 | 655 | } |
656 | 656 | |
657 | - public static function getRuleInvocationStack($e=null, |
|
658 | - $recognizerClassName=null) |
|
657 | + public static function getRuleInvocationStack($e = null, |
|
658 | + $recognizerClassName = null) |
|
659 | 659 | { |
660 | - if($e==null){ |
|
660 | + if ($e == null) { |
|
661 | 661 | $e = new Exception(); |
662 | 662 | } |
663 | - if($recognizerClassName==null){ |
|
663 | + if ($recognizerClassName == null) { |
|
664 | 664 | $recognizerClassName = get_class($this); |
665 | 665 | } |
666 | 666 | throw new Exception("Not implemented yet"); |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | * Convert a List<Token> to List<String> |
709 | 709 | */ |
710 | 710 | public function toStrings($tokens) { |
711 | - if ( $tokens==null ) return null; |
|
711 | + if ($tokens == null) return null; |
|
712 | 712 | $strings = array(); |
713 | - for ($i=0; $i<$tokens->size(); $i++) { |
|
713 | + for ($i = 0; $i < $tokens->size(); $i++) { |
|
714 | 714 | $strings[] = $tokens[$i]->getText(); |
715 | 715 | } |
716 | 716 | return $strings; |
@@ -727,12 +727,12 @@ discard block |
||
727 | 727 | * tosses out data after we commit past input position i. |
728 | 728 | */ |
729 | 729 | public function getRuleMemoization($ruleIndex, $ruleStartIndex) { |
730 | - if ( $this->state->ruleMemo[$ruleIndex]==null ) { |
|
730 | + if ($this->state->ruleMemo[$ruleIndex] == null) { |
|
731 | 731 | $this->state->ruleMemo[$ruleIndex] = array(); |
732 | 732 | } |
733 | 733 | $stopIndexI = |
734 | 734 | $this->state->ruleMemo[$ruleIndex][$ruleStartIndex]; |
735 | - if ( $stopIndexI==null ) { |
|
735 | + if ($stopIndexI == null) { |
|
736 | 736 | return self::$MEMO_RULE_UNKNOWN; |
737 | 737 | } |
738 | 738 | return $stopIndexI; |
@@ -749,16 +749,16 @@ discard block |
||
749 | 749 | */ |
750 | 750 | public function alreadyParsedRule($input, $ruleIndex) { |
751 | 751 | $stopIndex = $this->getRuleMemoization($ruleIndex, $input->index()); |
752 | - if ( $stopIndex==self::$MEMO_RULE_UNKNOWN ) { |
|
752 | + if ($stopIndex == self::$MEMO_RULE_UNKNOWN) { |
|
753 | 753 | return false; |
754 | 754 | } |
755 | - if ( $stopIndex==self::$MEMO_RULE_FAILED ) { |
|
755 | + if ($stopIndex == self::$MEMO_RULE_FAILED) { |
|
756 | 756 | //System.out.println("rule "+ruleIndex+" will never succeed"); |
757 | - $this->state->failed=true; |
|
757 | + $this->state->failed = true; |
|
758 | 758 | } |
759 | 759 | else { |
760 | 760 | //System.out.println("seen rule "+ruleIndex+" before; skipping ahead to @"+(stopIndex+1)+" failed="+state.failed); |
761 | - $input->seek($stopIndex+1); // jump to one past stop token |
|
761 | + $input->seek($stopIndex + 1); // jump to one past stop token |
|
762 | 762 | } |
763 | 763 | return true; |
764 | 764 | } |
@@ -766,61 +766,61 @@ discard block |
||
766 | 766 | /** Record whether or not this rule parsed the input at this position |
767 | 767 | * successfully. Use a standard java hashtable for now. |
768 | 768 | */ |
769 | - public function memoize($input, $ruleIndex, $ruleStartIndex){ |
|
770 | - $stopTokenIndex = $this->state->failed?self::$MEMO_RULE_FAILED:$input->index()-1; |
|
771 | - if ( $this->state->ruleMemo==null ) { |
|
772 | - echo("!!!!!!!!! memo array is null for ". getGrammarFileName()); |
|
769 | + public function memoize($input, $ruleIndex, $ruleStartIndex) { |
|
770 | + $stopTokenIndex = $this->state->failed ? self::$MEMO_RULE_FAILED : $input->index() - 1; |
|
771 | + if ($this->state->ruleMemo == null) { |
|
772 | + echo("!!!!!!!!! memo array is null for " . getGrammarFileName()); |
|
773 | 773 | } |
774 | - if ( $ruleIndex >= sizeof($this->state->ruleMemo) ) { |
|
775 | - echo("!!!!!!!!! memo size is ".sizeof($this->state->ruleMemo).", but rule index is ".$ruleIndex); |
|
774 | + if ($ruleIndex >= sizeof($this->state->ruleMemo)) { |
|
775 | + echo("!!!!!!!!! memo size is " . sizeof($this->state->ruleMemo) . ", but rule index is " . $ruleIndex); |
|
776 | 776 | } |
777 | - if ( $this->state->ruleMemo[$ruleIndex]!=null ) { |
|
777 | + if ($this->state->ruleMemo[$ruleIndex] != null) { |
|
778 | 778 | $this->state->ruleMemo[$ruleIndex][$ruleStartIndex] = $stopTokenIndex; |
779 | 779 | } |
780 | 780 | } |
781 | 781 | |
782 | 782 | public function getRuleMemoizationCacheSize() { |
783 | 783 | $n = 0; |
784 | - for ($i = 0; $this->state->ruleMemo!=null && $i < sizeof($this->state->ruleMemo); $i++) { |
|
784 | + for ($i = 0; $this->state->ruleMemo != null && $i < sizeof($this->state->ruleMemo); $i++) { |
|
785 | 785 | $ruleMap = $this->state->ruleMemo[$i]; |
786 | - if ( $ruleMap!=null ) { |
|
786 | + if ($ruleMap != null) { |
|
787 | 787 | $n += sizeof($ruleMap); // how many input indexes are recorded? |
788 | 788 | } |
789 | 789 | } |
790 | 790 | return $n; |
791 | 791 | } |
792 | 792 | |
793 | - public function traceIn($ruleName, $ruleIndex, $inputSymbol) { |
|
794 | - echo("enter ".$ruleName." ".$inputSymbol); |
|
795 | - if ( $this->state->failed ) { |
|
796 | - echo(" failed=".$this->state->failed); |
|
793 | + public function traceIn($ruleName, $ruleIndex, $inputSymbol) { |
|
794 | + echo("enter " . $ruleName . " " . $inputSymbol); |
|
795 | + if ($this->state->failed) { |
|
796 | + echo(" failed=" . $this->state->failed); |
|
797 | 797 | } |
798 | - if ( $this->state->backtracking>0 ) { |
|
799 | - echo(" backtracking=".$this->state->backtracking); |
|
798 | + if ($this->state->backtracking > 0) { |
|
799 | + echo(" backtracking=" . $this->state->backtracking); |
|
800 | 800 | } |
801 | 801 | echo "\n"; |
802 | 802 | } |
803 | 803 | |
804 | 804 | public function traceOut($ruleName, $ruleIndex, $inputSymbol) { |
805 | - echo("exit ".$ruleName." ".$inputSymbol); |
|
806 | - if ( $this->state->failed ) { |
|
807 | - echo(" failed=".$this->state->failed); |
|
805 | + echo("exit " . $ruleName . " " . $inputSymbol); |
|
806 | + if ($this->state->failed) { |
|
807 | + echo(" failed=" . $this->state->failed); |
|
808 | 808 | } |
809 | - if ( $this->state->backtracking>0 ) { |
|
809 | + if ($this->state->backtracking > 0) { |
|
810 | 810 | echo(" backtracking="+$this->state->backtracking); |
811 | 811 | } |
812 | 812 | echo "\n"; |
813 | 813 | } |
814 | 814 | |
815 | - public function getToken($name){ |
|
816 | - if(preg_match("/\d+/", $name)){ |
|
817 | - return (integer)$name; |
|
818 | - }else{ |
|
815 | + public function getToken($name) { |
|
816 | + if (preg_match("/\d+/", $name)) { |
|
817 | + return (integer) $name; |
|
818 | + } else { |
|
819 | 819 | return $this->$name; |
820 | 820 | } |
821 | 821 | } |
822 | 822 | |
823 | - public function getTokenName($tokenId){ |
|
823 | + public function getTokenName($tokenId) { |
|
824 | 824 | |
825 | 825 | } |
826 | 826 |
@@ -39,6 +39,7 @@ discard block |
||
39 | 39 | /** For infinite streams, you don't need this; primarily I'm providing |
40 | 40 | * a useful interface for action code. Just make sure actions don't |
41 | 41 | * use this on streams that don't support it. |
42 | + * @return string |
|
42 | 43 | */ |
43 | 44 | public function substring($start, $stop); |
44 | 45 | |
@@ -55,6 +56,9 @@ discard block |
||
55 | 56 | /** Because this stream can rewind, we need to be able to reset the line */ |
56 | 57 | public function setLine($line); |
57 | 58 | |
59 | + /** |
|
60 | + * @return void |
|
61 | + */ |
|
58 | 62 | public function setCharPositionInLine($pos); |
59 | 63 | |
60 | 64 | /** The index of the character relative to the beginning of the line 0..n-1 */ |
@@ -28,7 +28,7 @@ |
||
28 | 28 | */ |
29 | 29 | |
30 | 30 | |
31 | -class CharStreamConst{ |
|
31 | +class CharStreamConst { |
|
32 | 32 | public static $EOF = -1; |
33 | 33 | } |
34 | 34 | $CharStream_EOF = -1; |