Lexer
MMO\doc\js · 1 symbol · generated 30 Sep 2026
Lexer
Lexer.php:21A small, tolerant javascript lexer -- just enough to let Parser walk a source file without ever mistaking a brace, a quote or a slash inside a string/comment/regular expression for real code.
- Namespace
MMO\doc\js
Index
| OPERATORS | ||
| REGEX_KEYWORDS | ||
| T_COMMENT | ||
| T_DOC | ||
| T_NAME | ||
| T_NUMBER | ||
| T_PUNCT | ||
| T_REGEX | ||
| T_STRING | ||
| T_TEMPLATE | ||
| RegexAllowed($previous) static | Whether a / appearing right after $previous opens a regular expression. | |
| SkipQuoted($source, $i, $quote) static | ||
| SkipRegex($source, $i) static | Skip a regular expression literal's body and flags. | |
| SkipTemplate($source, $i) static | Skip a template literal's body, including any `${ ... | |
| Tokenize($source) static | Split a javascript source into tokens. |
Constants10
OPERATORS
REGEX_KEYWORDS
T_COMMENT
T_DOC
T_NAME
T_NUMBER
T_PUNCT
T_REGEX
T_STRING
T_TEMPLATE
Methods5
RegexAllowed($previous)
staticLexer.php:160Whether a / appearing right after $previous opens a regular expression. Everything that can *end* an expression (a name, a number, a string, a closing )/]) means the / divides it; anything else means a new expression is starting, so the / opens a literal.
SkipQuoted($source, $i, $quote)
staticLexer.php:172SkipRegex($source, $i)
staticLexer.php:219Skip a regular expression literal's body and flags. A / inside a [...] character class does not close it -- which is exactly what makes a regex-unaware scanner desynchronise on real code.
SkipTemplate($source, $i)
staticLexer.php:188Skip a template literal's body, including any ${ ... } substitution -- which can itself contain strings, braces and further template literals, so the braces are counted and nested literals recursed into.
Tokenize($source)
staticLexer.php:56Split a javascript source into tokens.