Components
Now let's move on to the components themselves and a description of what they are responsible for.
Source
As the name implies, the component is responsible for minimal abstraction over the source code. The minimum capabilities of the source interface is to read data and obtain auxiliary information, such as the name of the file from which the source was created and the identification hash of the source code.
To install the component, use the command composer require phplrt/source
.
Position
The position component provides the ability to process information about the position in the source code: offset in bytes, line and column. And also work with intervals: Start and end positions in the source.
To install the component, use the command composer require phplrt/position
.
Exception
The exception component provides advanced error and error message manipulation capabilities, allowing their internal information containing PHP data to be delegated to an external language.
To install the component, use the command composer require phplrt/exception
.
Lexer
The lexer component provides the ability to group a sequence of characters according to some criteria, forming so-called tokens (or lexemes) from the source code.
To install the component, use the command composer require phplrt/lexer
.
Buffer
The buffer component provides a set of classes with the ability to convert a list of tokens from a lexer to an iterator with the ability to loop back to a specific token.
Each driver from the package contains its own features and can both store the entire data set in memory, as well as a certain segment.
To install the component, use the command composer require phplrt/buffer
.
Parser
The parser component allows you to parse grammar rules and check user data for compliance with these rules.
As it is parsed, the parser can also build an abstract syntax tree for later use by the user.
To install the component, use the command composer require phplrt/parser
.
Visitor
The visitor component allows you to traverse each node of the abstract syntax tree by applying a set of rules generated by the user to it, such as replacing nodes, changing values, copying, and so on.
To install the component, use the command composer require phplrt/visitor
.