66 */
77class Lexer
88{
9+ /** @var array Characters that can start a number (ctor calculated) */
10+ private $ startNumber ;
11+
12+ /** @var array Valid identifier characters (ctor calculated) */
13+ private $ validIdentifier ;
14+
915 /** @var array Characters that can start an identifier */
1016 private $ startIdentifier = [
1117 'A ' => true , 'B ' => true , 'C ' => true , 'D ' => true , 'E ' => true ,
@@ -27,11 +33,13 @@ class Lexer
2733 6 => true , 7 => true , 8 => true , 9 => true ,
2834 ];
2935
30- /** @var array Characters that can start a number (ctor calculated) */
31- private $ startNumber ;
32-
33- /** @var array Valid identifier characters (ctor calculated) */
34- private $ validIdentifier ;
36+ /** @var array Map of whitespace characters */
37+ private $ whitespace = [
38+ ' ' => true ,
39+ "\t" => true ,
40+ "\n" => true ,
41+ "\r" => true
42+ ];
3543
3644 /** @var array Map of simple single character tokens */
3745 private $ simpleTokens = [
@@ -48,16 +56,9 @@ class Lexer
4856 '} ' => 'rbrace ' ,
4957 ];
5058
51- /** @var array Map of whitespace characters */
52- private $ whitespace = [
53- ' ' => 'skip ' ,
54- "\t" => 'skip ' ,
55- "\n" => 'skip ' ,
56- "\r" => 'skip ' ,
57- ];
58-
5959 public function __construct ()
6060 {
61+ // Create aggregate character maps.
6162 $ this ->validIdentifier = $ this ->startIdentifier + $ this ->numbers ;
6263 $ this ->startNumber = $ this ->numbers ;
6364 $ this ->startNumber ['- ' ] = true ;
0 commit comments