@@ -53,28 +53,28 @@ |
||
| 53 | 53 | * |
| 54 | 54 | * @var string|null |
| 55 | 55 | */ |
| 56 | - protected $_rule = null; |
|
| 56 | + protected $_rule = null; |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Data. |
| 60 | 60 | * |
| 61 | 61 | * @var mixed |
| 62 | 62 | */ |
| 63 | - protected $_data = null; |
|
| 63 | + protected $_data = null; |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Piece of todo sequence. |
| 67 | 67 | * |
| 68 | 68 | * @var array|null |
| 69 | 69 | */ |
| 70 | - protected $_todo = null; |
|
| 70 | + protected $_todo = null; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * Depth in the trace. |
| 74 | 74 | * |
| 75 | 75 | * @var int |
| 76 | 76 | */ |
| 77 | - protected $_depth = -1; |
|
| 77 | + protected $_depth = -1; |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Whether the rule is transitional or not (i.e. not declared in the grammar |
@@ -55,28 +55,28 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @var array |
| 57 | 57 | */ |
| 58 | - protected $_lexerState = null; |
|
| 58 | + protected $_lexerState = null; |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Text. |
| 62 | 62 | * |
| 63 | 63 | * @var string |
| 64 | 64 | */ |
| 65 | - protected $_text = null; |
|
| 65 | + protected $_text = null; |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * Tokens. |
| 69 | 69 | * |
| 70 | 70 | * @var array |
| 71 | 71 | */ |
| 72 | - protected $_tokens = []; |
|
| 72 | + protected $_tokens = []; |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * Namespace stacks. |
| 76 | 76 | * |
| 77 | 77 | * @var \SplStack |
| 78 | 78 | */ |
| 79 | - protected $_nsStack = null; |
|
| 79 | + protected $_nsStack = null; |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * PCRE options. |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function __construct(array $pragmas = []) |
| 96 | 96 | { |
| 97 | - if (!isset($pragmas['lexer.unicode']) || true === $pragmas['lexer.unicode']) { |
|
| 97 | + if ( ! isset($pragmas['lexer.unicode']) || true === $pragmas['lexer.unicode']) { |
|
| 98 | 98 | $this->_pcreOptions .= 'u'; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | if (null === $nextToken) { |
| 158 | 158 | throw new Compiler\Exception\UnrecognizedToken( |
| 159 | - 'Unrecognized token "%s" at line 1 and column %d:' . |
|
| 160 | - "\n" . '%s' . "\n" . |
|
| 161 | - str_repeat(' ', mb_strlen(substr($text, 0, $offset))) . '↑', |
|
| 159 | + 'Unrecognized token "%s" at line 1 and column %d:'. |
|
| 160 | + "\n".'%s'."\n". |
|
| 161 | + str_repeat(' ', mb_strlen(substr($text, 0, $offset))).'↑', |
|
| 162 | 162 | 0, |
| 163 | 163 | [ |
| 164 | 164 | mb_substr(substr($text, $offset), 0, 1), |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | if ($i > ($c = count($this->_nsStack))) { |
| 228 | 228 | throw new Compiler\Exception\Lexer( |
| 229 | - 'Cannot shift namespace %d-times, from token ' . |
|
| 230 | - '%s in namespace %s, because the stack ' . |
|
| 229 | + 'Cannot shift namespace %d-times, from token '. |
|
| 230 | + '%s in namespace %s, because the stack '. |
|
| 231 | 231 | 'contains only %d namespaces.', |
| 232 | 232 | 1, |
| 233 | 233 | [ |
@@ -247,9 +247,9 @@ discard block |
||
| 247 | 247 | $shift = true; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - if (!isset($this->_tokens[$nextState])) { |
|
| 250 | + if ( ! isset($this->_tokens[$nextState])) { |
|
| 251 | 251 | throw new Compiler\Exception\Lexer( |
| 252 | - 'Namespace %s does not exist, called by token %s ' . |
|
| 252 | + 'Namespace %s does not exist, called by token %s '. |
|
| 253 | 253 | 'in namespace %s.', |
| 254 | 254 | 2, |
| 255 | 255 | [ |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | { |
| 292 | 292 | $_regex = str_replace('#', '\#', $regex); |
| 293 | 293 | $preg = @preg_match( |
| 294 | - '#\G(?|' . $_regex . ')#' . $this->_pcreOptions, |
|
| 294 | + '#\G(?|'.$_regex.')#'.$this->_pcreOptions, |
|
| 295 | 295 | $this->_text, |
| 296 | 296 | $matches, |
| 297 | 297 | 0, |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | if ('' === $matches[0]) { |
| 314 | 314 | throw new Compiler\Exception\Lexer( |
| 315 | - 'A lexeme must not match an empty value, which is the ' . |
|
| 315 | + 'A lexeme must not match an empty value, which is the '. |
|
| 316 | 316 | 'case of "%s" (%s).', |
| 317 | 317 | 3, |
| 318 | 318 | [$lexeme, $regex] |
@@ -53,35 +53,35 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @var string |
| 55 | 55 | */ |
| 56 | - protected $_name = null; |
|
| 56 | + protected $_name = null; |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Rule's children. Can be an array of names or a single name. |
| 60 | 60 | * |
| 61 | 61 | * @var mixed |
| 62 | 62 | */ |
| 63 | - protected $_children = null; |
|
| 63 | + protected $_children = null; |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Node ID. |
| 67 | 67 | * |
| 68 | 68 | * @var string |
| 69 | 69 | */ |
| 70 | - protected $_nodeId = null; |
|
| 70 | + protected $_nodeId = null; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * Node options. |
| 74 | 74 | * |
| 75 | 75 | * @var array |
| 76 | 76 | */ |
| 77 | - protected $_nodeOptions = []; |
|
| 77 | + protected $_nodeOptions = []; |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Default ID. |
| 81 | 81 | * |
| 82 | 82 | * @var string |
| 83 | 83 | */ |
| 84 | - protected $_defaultId = null; |
|
| 84 | + protected $_defaultId = null; |
|
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * Default options. |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @var string |
| 97 | 97 | */ |
| 98 | - protected $_pp = null; |
|
| 98 | + protected $_pp = null; |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Whether the rule is transitional or not (i.e. not declared in the grammar |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @var bool |
| 105 | 105 | */ |
| 106 | - protected $_transitional = true; |
|
| 106 | + protected $_transitional = true; |
|
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @var array |
| 59 | 59 | */ |
| 60 | - protected $_pragmas = null; |
|
| 60 | + protected $_pragmas = null; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * List of skipped tokens. |
| 64 | 64 | * |
| 65 | 65 | * @var array |
| 66 | 66 | */ |
| 67 | - protected $_skip = null; |
|
| 67 | + protected $_skip = null; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Associative array (token name => token regex), to be defined in |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @var array |
| 74 | 74 | */ |
| 75 | - protected $_tokens = null; |
|
| 75 | + protected $_tokens = null; |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * Rules, to be defined as associative array, name => Rule object. |
| 79 | 79 | * |
| 80 | 80 | * @var Rule[] |
| 81 | 81 | */ |
| 82 | - protected $_rules = null; |
|
| 82 | + protected $_rules = null; |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Lexer iterator. |
@@ -93,35 +93,35 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @var array |
| 95 | 95 | */ |
| 96 | - protected $_errorToken = null; |
|
| 96 | + protected $_errorToken = null; |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Trace of activated rules. |
| 100 | 100 | * |
| 101 | 101 | * @var array |
| 102 | 102 | */ |
| 103 | - protected $_trace = []; |
|
| 103 | + protected $_trace = []; |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * Stack of todo list. |
| 107 | 107 | * |
| 108 | 108 | * @var array |
| 109 | 109 | */ |
| 110 | - protected $_todo = null; |
|
| 110 | + protected $_todo = null; |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * AST. |
| 114 | 114 | * |
| 115 | 115 | * @var TreeNode |
| 116 | 116 | */ |
| 117 | - protected $_tree = null; |
|
| 117 | + protected $_tree = null; |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Current depth while building the trace. |
| 121 | 121 | * |
| 122 | 122 | * @var int |
| 123 | 123 | */ |
| 124 | - protected $_depth = -1; |
|
| 124 | + protected $_depth = -1; |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | if (false === $this->backtrack()) { |
| 194 | - $token = $this->_errorToken; |
|
| 194 | + $token = $this->_errorToken; |
|
| 195 | 195 | |
| 196 | 196 | if (null === $this->_errorToken) { |
| 197 | 197 | $token = $this->_tokenSequence->current(); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $line = 1; |
| 202 | 202 | $column = 1; |
| 203 | 203 | |
| 204 | - if (!empty($text)) { |
|
| 204 | + if ( ! empty($text)) { |
|
| 205 | 205 | if (0 === $offset) { |
| 206 | 206 | $leftnl = 0; |
| 207 | 207 | } else { |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | throw new Compiler\Exception\UnexpectedToken( |
| 221 | - 'Unexpected token "%s" (%s) at line %d and column %d:' . |
|
| 222 | - "\n" . '%s' . "\n" . str_repeat(' ', $column - 1) . '↑', |
|
| 221 | + 'Unexpected token "%s" (%s) at line %d and column %d:'. |
|
| 222 | + "\n".'%s'."\n".str_repeat(' ', $column - 1).'↑', |
|
| 223 | 223 | 0, |
| 224 | 224 | [ |
| 225 | 225 | $token['value'], |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | $tree = $this->_buildTree(); |
| 242 | 242 | |
| 243 | - if (!($tree instanceof TreeNode)) { |
|
| 243 | + if ( ! ($tree instanceof TreeNode)) { |
|
| 244 | 244 | throw new Compiler\Exception( |
| 245 | 245 | 'Parsing error: cannot build AST, the trace is corrupted.', |
| 246 | 246 | 1 |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | $this->_depth |
| 424 | 424 | ); |
| 425 | 425 | array_pop($this->_todo); |
| 426 | - $this->_todo[] = new Rule\Ekzit( |
|
| 426 | + $this->_todo[] = new Rule\Ekzit( |
|
| 427 | 427 | $name, |
| 428 | 428 | $min, |
| 429 | 429 | $this->_todo |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | end($children); |
| 632 | 632 | $last = current($children); |
| 633 | 633 | |
| 634 | - if (!is_object($last)) { |
|
| 634 | + if ( ! is_object($last)) { |
|
| 635 | 635 | return false; |
| 636 | 636 | } |
| 637 | 637 | |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | */ |
| 745 | 745 | final public function getRule(string $name): Rule |
| 746 | 746 | { |
| 747 | - if (!isset($this->_rules[$name])) { |
|
| 747 | + if ( ! isset($this->_rules[$name])) { |
|
| 748 | 748 | return null; |
| 749 | 749 | } |
| 750 | 750 | |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | \assert([] !== $this->_rules); |
| 770 | 770 | |
| 771 | 771 | foreach ($this->_rules as $rule => $_) { |
| 772 | - if (!is_int($rule)) { |
|
| 772 | + if ( ! is_int($rule)) { |
|
| 773 | 773 | break; |
| 774 | 774 | } |
| 775 | 775 | } |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @var string |
| 57 | 57 | */ |
| 58 | - protected $_id = ''; |
|
| 58 | + protected $_id = ''; |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Value of the node (non-null for token nodes). |
| 62 | 62 | * |
| 63 | 63 | * @var array|null |
| 64 | 64 | */ |
| 65 | - protected $_value = null; |
|
| 65 | + protected $_value = null; |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * Children. |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @var array |
| 85 | 85 | */ |
| 86 | - protected $_data = []; |
|
| 86 | + protected $_data = []; |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | ) { |
| 102 | 102 | $this->setId($id); |
| 103 | 103 | |
| 104 | - if (!empty($value)) { |
|
| 104 | + if ( ! empty($value)) { |
|
| 105 | 105 | $this->setValue($value); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function isToken(): bool |
| 191 | 191 | { |
| 192 | - return !empty($this->_value); |
|
| 192 | + return ! empty($this->_value); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -63,21 +63,21 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @var string|null |
| 65 | 65 | */ |
| 66 | - protected $_tokenName = null; |
|
| 66 | + protected $_tokenName = null; |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * Namespace. |
| 70 | 70 | * |
| 71 | 71 | * @var string|null |
| 72 | 72 | */ |
| 73 | - protected $_namespace = null; |
|
| 73 | + protected $_namespace = null; |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Token representation. |
| 77 | 77 | * |
| 78 | 78 | * @var string|null |
| 79 | 79 | */ |
| 80 | - protected $_regex = null; |
|
| 80 | + protected $_regex = null; |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * AST of the regex. |
@@ -91,28 +91,28 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @var string|null |
| 93 | 93 | */ |
| 94 | - protected $_value = null; |
|
| 94 | + protected $_value = null; |
|
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * Whether the token is kept or not in the AST. |
| 98 | 98 | * |
| 99 | 99 | * @var bool |
| 100 | 100 | */ |
| 101 | - protected $_kept = false; |
|
| 101 | + protected $_kept = false; |
|
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * Unification index. |
| 105 | 105 | * |
| 106 | 106 | * @var int |
| 107 | 107 | */ |
| 108 | - protected $_unification = -1; |
|
| 108 | + protected $_unification = -1; |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * Token offset. |
| 112 | 112 | * |
| 113 | 113 | * @var int |
| 114 | 114 | */ |
| 115 | - protected $_offset = 0; |
|
| 115 | + protected $_offset = 0; |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * @param string|int $name Name. |