Page MenuHomePhorge
Diviner Arcanist Tech Docs PhutilPHPFragmentLexer

final class PhutilPHPFragmentLexer
Arcanist Technical Documentation ()

PHP lexer which can handle fragments of source code, e.g. for syntax highlighting of inline snippets. This is largely based on Pygments, but alters some rules to better annotate symbols from source fragments.

This lexer is not suitable for parser construction; it always lexes any input stream, even if the input is not PHP.

Tasks

Lexer Implementation

Lexer Rules

  • protected function getRules() — Process, normalize, and validate the raw lexer rules.

Lexer Tokens

  • public function getTokens($input, $initial_state) — Lex an input string into tokens.

Other Methods

  • public function __get($name)
  • public function __set($name, $value)
  • public function current()
  • public function key()
  • public function next()
  • public function rewind()
  • public function valid()
  • private function throwOnAttemptedIteration()
  • public function getPhobjectClassConstant($key, $byte_limit) — Read the value of a class constant.
  • public function mergeTokens($tokens) — Merge adjacent tokens of the same type. For example, if a comment is tokenized as <"//", "comment">, this method will merge the two tokens into a single combined token.
  • public function getLexerState()

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

protected function getRawRules()

PhutilLexer

Return a set of rules for this lexer. See description in PhutilLexer.

PhutilPHPFragmentLexer
This method is not documented.
Return
dictLexer rules.

protected function getRules()
Inherited

PhutilLexer

Process, normalize, and validate the raw lexer rules.

Return
wild

public function getTokens($input, $initial_state)
Inherited

PhutilLexer

Lex an input string into tokens.

Parameters
string$inputInput string.
string$initial_stateInitial lexer state.
Return
listList of lexer tokens.

public function mergeTokens($tokens)
Inherited

PhutilLexer

Merge adjacent tokens of the same type. For example, if a comment is tokenized as <"//", "comment">, this method will merge the two tokens into a single combined token.

Parameters
array$tokens
Return
wild

public function getLexerState()
Inherited

This method is not documented.
Return
wild