File code/Lexer.php
class Tlf\Lexer
Used to process a string into an Asymmetrical Syntax Tree (AST)
Constants
Properties
-
public float $version = \Tlf\Lexer\Versions_old;
-
public bool $debug = false;
set true to show debug messages -
public int $loop_count = 0;
The loop we're on. 0 means not started. 1 means we're executing the first loop. 2 means 2nd loop, etc. -
public bool $useCache = true;
Whether to load from & save to the cache or not. -
public $token = null;
The token currently being processed -
protected $grammarListForCache = null;
array of grammar class names & their file's last mtime -
public $stop_loop = -1;
the loop to stop processing on. Used for debugging, when writing a grammar. -
public string $signal = null;
A string that can be set & checked by handlers, to determine what operations should be completed.
Methods
-
public function abort()
stop lexing -
public function haltAll()
-
public function continueAll()
-
public function haltInstructions()
-
public function continueInstructions()
-
public function previous($key)
-
public function setPrevious($key, $value)
-
public function appendToPrevious($key, $value)
-
public function unsetPrevious($key)
-
public function clearBuffer()
-
public function getToken()
-
public function addGrammar(object $grammar, string $namespace=null, $executeOnAddtrue)
-
public function getGrammar(string $namespace)
-
public function setHead($ast)
Append an ast to top of stack. -
public function popHead(): \Tlf\Lexer\Ast
Get top-level ast and remove it from the stack. If only one ast, then return it and leave at bottom of stack. -
public function getHead(): \Tlf\Lexer\Ast
Get top-level AST from stack.
See Internals::$head
-
public function rootAst(): \Tlf\Lexer\Ast
Get bottom-level AST from stack.
See Internals::$head
-
public function lexFile($file): \Tlf\Lexer\Ast
Create a 'file' ast & call 'lexAst'. Asts generated by this function are cached. Chache is invalidated when the source of the active grammars or the file being processed changes.