Class SimpleLexer

Description

Accepts text and breaks it into tokens.

Some optimisation to make the sure the content is only scanned by the PHP regex parser once. Lexer modes must not start with leading underscores.

Located in /parser.php (line 180)


	
			
Direct descendents
Class Description
 class SimpleHtmlLexer Breaks HTML into SAX events.
Variable Summary
 mixed $_case
 mixed $_mode
 mixed $_parser
 mixed $_regexes
Method Summary
 SimpleLexer SimpleLexer ( &$parser, [string $start = "accept"], [boolean $case = false], SimpleSaxParser $parser)
 void addEntryPattern (string $pattern, string $mode, string $new_mode)
 void addExitPattern (string $pattern, string $mode)
 void addPattern (string $pattern, [string $mode = "accept"])
 void addSpecialPattern (string $pattern, string $mode, string $special)
 void mapHandler (string $mode, string $handler)
 boolean parse (string $raw)
Variables
mixed $_case (line 185)
mixed $_mode (line 183)
mixed $_mode_handlers (line 184)
mixed $_parser (line 182)
mixed $_regexes (line 181)
Methods
Constructor SimpleLexer (line 196)

Sets up the lexer in case insensitive matching by default.

  • access: public
SimpleLexer SimpleLexer ( &$parser, [string $start = "accept"], [boolean $case = false], SimpleSaxParser $parser)
  • SimpleSaxParser $parser: Handling strategy by reference.
  • string $start: Starting handler.
  • boolean $case: True for case sensitive.
  • &$parser
addEntryPattern (line 238)

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

  • access: public
void addEntryPattern (string $pattern, string $mode, string $new_mode)
  • 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.
addExitPattern (line 256)

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

  • access: public
void addExitPattern (string $pattern, string $mode)
  • string $pattern: Perl style regex, but ( and ) lose the usual meaning.
  • string $mode: Mode to leave.
addPattern (line 215)

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

  • access: public
void addPattern (string $pattern, [string $mode = "accept"])
  • 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.
addSpecialPattern (line 278)

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.

  • access: public
void addSpecialPattern (string $pattern, string $mode, string $special)
  • 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.
mapHandler (line 294)

Adds a mapping from a mode to another handler.

  • access: public
void mapHandler (string $mode, string $handler)
  • string $mode: Mode to be remapped.
  • string $handler: New target handler.
parse (line 308)

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.

  • return: True on success, else false.
  • access: public
boolean parse (string $raw)
  • string $raw: Raw HTML text.

Documentation generated on Sun, 04 May 2008 09:21:55 -0500 by phpDocumentor 1.3.0