Commit Graph

4 Commits

Author SHA1 Message Date
Nikita Popov
a75164c77e Rename YYNLSTATES to numNonLeafStates 2017-11-12 16:09:00 +01:00
Nikita Popov
8f623fb241 Use closures instead of methods for semantic actions
The dispatch using $this->{'reduceRule' . $rule}() is very expensive
because it involves
 * One allocation when converting $rule to a string
 * Another allocation when concatenating the two strings
 * Lowercasing during the method call
 * Various uncached method checks, e.g. visibility.

Using an array of closures for semantic action dispatch is
significantly more efficient.
2017-02-05 11:58:45 +01:00
Nikita Popov
3bbf8d8f7a Use local var for $stackPos
We're accessing $this->stackPos a lot, and property accesses are
much more expensive than local variable acesses. Its cheaper to
use a local var and pass it as an argument to semantic actions.
2017-02-05 11:57:21 +01:00
Nikita Popov
bc21514ecf Move token constants into separate class
As these are shared between Php5 and Php7 parsers they should be
in some common place, otherwise we'd have to always reference either
one or the other.
2015-06-13 18:39:55 +02:00