Moodle  2.2.1
http://www.collinsharper.com
SimpleLexer Class Reference
Inheritance diagram for SimpleLexer:

Public Member Functions

 SimpleLexer (&$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)
 _isModeEnd ($mode)
 _isSpecialMode ($mode)
 _decodeSpecial ($mode)
 _invokeParser ($content, $is_match)
 _reduce ($raw)

Data Fields

 $_regexes
 $_parser
 $_mode
 $_mode_handlers
 $_case

Detailed Description

Definition at line 180 of file parser.php.


Member Function Documentation

_decodeSpecial ( mode)

Strips the magic underscore marking single token modes.

Parameters:
string$modeMode to decode.
Returns:
string Underlying mode name. private

Definition at line 399 of file parser.php.

Here is the caller graph for this function:

_dispatchTokens ( unmatched,
matched,
mode = false 
)

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$unmatchedUnmatched leading portion.
string$matchedActual token match.
string$modeMode after match. A boolean false mode causes no change.
Returns:
boolean False if there was any error from the parser. private

Definition at line 344 of file parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

_invokeParser ( content,
is_match 
)

Calls the parser method named after the current mode. Empty content will be ignored. The lexer has a parser handler for each mode in the lexer.

Parameters:
string$contentText parsed.
boolean$is_matchToken is recognised rather than unparsed data. private

Definition at line 412 of file parser.php.

Here is the caller graph for this function:

_isModeEnd ( mode)

Tests to see if the new mode is actually to leave the current mode and pop an item from the matching mode stack.

Parameters:
string$modeMode to test.
Returns:
boolean True if this is the exit mode. private

Definition at line 376 of file parser.php.

Here is the caller graph for this function:

_isSpecialMode ( mode)

Test to see if the mode is one where this mode is entered for this token only and automatically leaves immediately afterwoods.

Parameters:
string$modeMode to test.
Returns:
boolean True if this is the exit mode. private

Definition at line 388 of file parser.php.

Here is the caller graph for this function:

_reduce ( raw)

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$rawThe subject to parse. This is the content that will be eaten.
Returns:
array/boolean 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 434 of file parser.php.

Here is the caller graph for this function:

addEntryPattern ( pattern,
mode,
new_mode 
)

Adds a pattern that will enter a new parsing mode. Useful for entering parenthesis, strings, tags, etc.

Parameters:
string$patternPerl style regex, but ( and ) lose the usual meaning.
string$modeShould only apply this pattern when dealing with this type of input.
string$new_modeChange parsing to this new nested mode. public

Definition at line 238 of file parser.php.

Here is the caller graph for this function:

addExitPattern ( pattern,
mode 
)

Adds a pattern that will exit the current mode and re-enter the previous one.

Parameters:
string$patternPerl style regex, but ( and ) lose the usual meaning.
string$modeMode to leave. public

Definition at line 256 of file parser.php.

Here is the caller graph for this function:

addPattern ( pattern,
mode = "accept" 
)

Adds a token search pattern for a particular parsing mode. The pattern does not change the current mode.

Parameters:
string$patternPerl style regex, but ( and ) lose the usual meaning.
string$modeShould only apply this pattern when dealing with this type of input. public

Definition at line 215 of file parser.php.

Here is the caller graph for this function:

addSpecialPattern ( pattern,
mode,
special 
)

Adds a pattern that has a special mode. Acts as an entry and exit pattern in one go, effectively calling a special parser handler for this token only.

Parameters:
string$patternPerl style regex, but ( and ) lose the usual meaning.
string$modeShould only apply this pattern when dealing with this type of input.
string$specialUse this mode for this one token. public

Definition at line 278 of file parser.php.

Here is the caller graph for this function:

mapHandler ( mode,
handler 
)

Adds a mapping from a mode to another handler.

Parameters:
string$modeMode to be remapped.
string$handlerNew target handler. public

Definition at line 294 of file parser.php.

Here is the caller graph for this function:

parse ( raw)

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:
string$rawRaw HTML text.
Returns:
boolean True on success, else false. public

Definition at line 308 of file parser.php.

Here is the call graph for this function:

SimpleLexer ( &$  parser,
start = "accept",
case = false 
)

Sets up the lexer in case insensitive matching by default.

Parameters:
SimpleSaxParser$parserHandling strategy by reference.
string$startStarting handler.
boolean$caseTrue for case sensitive. public

Definition at line 196 of file parser.php.

Here is the caller graph for this function:


Field Documentation

$_case

Definition at line 185 of file parser.php.

$_mode

Definition at line 183 of file parser.php.

$_mode_handlers

Definition at line 184 of file parser.php.

$_parser

Definition at line 182 of file parser.php.

$_regexes

Definition at line 181 of file parser.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations