Public Member Functions |
| | Lexer (&$parser, $start="accept", $case=false) |
| | addPattern ($pattern, $mode="accept") |
| | addEntryPattern ($pattern, $mode, $new_mode) |
| | addExitPattern ($pattern, $mode) |
| | addSpecialPattern ($pattern, $mode, $special) |
| | mapHandler ($mode, $handler) |
| | parse ($raw) |
| | _dispatchTokens ($unmatched, $matched, $mode=false) |
| | _invokeParser ($content, $is_match) |
| | _reduce (&$raw) |
Data Fields |
| | $_regexes |
| | $_parser |
| | $_mode |
| | $_mode_handlers |
| | $_case |
Detailed Description
Definition at line 190 of file lexer.php.
Member Function Documentation
Sends the matched token and any leading unmatched text to the parser changing the lexer to a new mode if one is listed.
- Parameters:
-
| string | $unmatched | Unmatched leading portion. |
| string | $matched | Actual token match. |
| string | $mode | Mode after match. The "_exit" mode causes a stack pop. An false mode causes no change. |
- Returns:
- bool False if there was any error from the parser. private
Definition at line 339 of file lexer.php.
Calls the parser method named after the current mode. Empty content will be ignored.
- Parameters:
-
| string | $content | Text parsed. |
| string | $is_match | Token is recognised rather than unparsed data. private |
Definition at line 372 of file lexer.php.
Tries to match a chunk of text and if successful removes the recognised chunk and any leading unparsed data. Empty strings will not be matched.
- Parameters:
-
| string | $raw | The subject to parse. This is the content that will be eaten. |
- Returns:
- bool|array Three item list of unparsed content followed by the recognised token and finally the action the parser is to take. True if no match, false if there is a parsing error. private
Definition at line 397 of file lexer.php.
Adds a pattern that will enter a new parsing mode. Useful for entering parenthesis, strings, tags, etc.
- Parameters:
-
| string | $pattern | Perl style regex, but ( and ) lose the usual meaning. |
| string | $mode | Should only apply this pattern when dealing with this type of input. |
| string | $new_mode | Change parsing to this new nested mode. public |
Definition at line 245 of file lexer.php.
Adds a pattern that will exit the current mode and re-enter the previous one.
- Parameters:
-
| string | $pattern | Perl style regex, but ( and ) lose the usual meaning. |
| string | $mode | Mode to leave. public |
Definition at line 260 of file lexer.php.
Adds a token search pattern for a particular parsing mode. The pattern does not change the current mode.
- Parameters:
-
| string | $pattern | Perl style regex, but ( and ) lose the usual meaning. |
| string | $mode | Should only apply this pattern when dealing with this type of input. public |
Definition at line 225 of file lexer.php.
Adds a pattern that has a special mode. Acts as an entry and exit pattern in one go.
- Parameters:
-
| string | $pattern | Perl style regex, but ( and ) lose the usual meaning. |
| string | $mode | Should only apply this pattern when dealing with this type of input. |
| string | $special | Use this mode for this one token. public |
Definition at line 278 of file lexer.php.
| Lexer |
( |
&$ |
parser, |
|
|
$ |
start = "accept", |
|
|
$ |
case = false |
|
) |
| |
Sets up the lexer in case insensitive matching by default.
- Parameters:
-
| object | $parser | Handling strategy by reference. |
| string | $start | Starting handler. |
| bool | $case | True for case sensitive. public |
Definition at line 206 of file lexer.php.
Adds a mapping from a mode to another handler.
- Parameters:
-
| string | $mode | Mode to be remapped. |
| string | $handler | New target handler. public |
Definition at line 291 of file lexer.php.
Splits the page text into tokens. Will fail if the handlers report an error or if no content is consumed. If successful then each unparsed and parsed token invokes a call to the held listener.
- Parameters:
-
- Returns:
- bool True on success, else false. public
Definition at line 305 of file lexer.php.
Field Documentation
The documentation for this class was generated from the following file: