diff options
author | Andreas Gohr <andi@splitbrain.org> | 2006-02-17 23:20:40 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2006-02-17 23:20:40 +0100 |
commit | 98c868589ee0757f176239cf289cbd007bb74852 (patch) | |
tree | eb48a172b0f1a423b93ffff35f8adf8d579383c1 /inc/parser/lexer.php | |
parent | 1c73890c5027011d808d38c583561abc309e8086 (diff) | |
download | rpg-98c868589ee0757f176239cf289cbd007bb74852.tar.gz rpg-98c868589ee0757f176239cf289cbd007bb74852.tar.bz2 |
file cleanups
This patch cleans up the source code to satisfy the coding guidelines (see
http://wiki.splitbrain.org/wiki:development#coding_style)
It converts files to UNIX lineendings and removes tabs and trailing
whitespace. Not all files were cleaned yet.
darcs-hash:20060217222040-7ad00-bba3d2bee3b5aa7cbb5184258abd50805cd071bf.gz
Diffstat (limited to 'inc/parser/lexer.php')
-rw-r--r-- | inc/parser/lexer.php | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php index e096fd045..e764fa236 100644 --- a/inc/parser/lexer.php +++ b/inc/parser/lexer.php @@ -37,7 +37,7 @@ class Doku_LexerParallelRegex { var $_labels; var $_regex; var $_case; - + /** * Constructor. Starts with no patterns. * @param boolean $case True for case sensitive, false @@ -50,7 +50,7 @@ class Doku_LexerParallelRegex { $this->_labels = array(); $this->_regex = null; } - + /** * Adds a pattern with an optional label. * @param mixed $pattern Perl style regex. Must be UTF-8 @@ -68,7 +68,7 @@ class Doku_LexerParallelRegex { $this->_labels[$count] = $label; $this->_regex = null; } - + /** * Attempts to match all patterns at once against * a string. @@ -86,7 +86,7 @@ class Doku_LexerParallelRegex { $match = ""; return false; } - + $match = $matches[0]; $size = count($matches); for ($i = 1; $i < $size; $i++) { @@ -96,7 +96,7 @@ class Doku_LexerParallelRegex { } return true; } - + /** * Attempts to split the string against all patterns at once * @@ -111,20 +111,20 @@ class Doku_LexerParallelRegex { if (count($this->_patterns) == 0) { return false; } - + if (! preg_match($this->_getCompoundedRegex(), $subject, $matches)) { $split = array($subject, "", ""); return false; } - + $idx = count($matches)-2; list($pre, $post) = preg_split($this->_patterns[$idx].$this->_getPerlMatchingFlags(), $subject, 2); - + $split = array($pre, $matches[0], $post); return isset($this->_labels[$idx]) ? $this->_labels[$idx] : true; } - + /** * Compounds the patterns into a single * regular expression separated with the @@ -137,7 +137,7 @@ class Doku_LexerParallelRegex { if ($this->_regex == null) { $cnt = count($this->_patterns); for ($i = 0; $i < $cnt; $i++) { - + // Replace lookaheads / lookbehinds with marker $m = "\1\1"; $pattern = preg_replace( @@ -167,7 +167,7 @@ class Doku_LexerParallelRegex { array('\/', '\(', '\)'), $pattern ); - + // Restore lookaheads / lookbehinds $pattern = preg_replace( array ( @@ -190,14 +190,14 @@ class Doku_LexerParallelRegex { ), $pattern ); - + $this->_patterns[$i] = '('.$pattern.')'; } $this->_regex = "/" . implode("|", $this->_patterns) . "/" . $this->_getPerlMatchingFlags(); } return $this->_regex; } - + /** * Accessor for perl regex mode flags to use. * @return string Perl regex flags. @@ -215,7 +215,7 @@ class Doku_LexerParallelRegex { */ class Doku_LexerStateStack { var $_stack; - + /** * Constructor. Starts in named state. * @param string $start Starting state name. @@ -224,7 +224,7 @@ class Doku_LexerStateStack { function Doku_LexerStateStack($start) { $this->_stack = array($start); } - + /** * Accessor for current state. * @return string State. @@ -233,7 +233,7 @@ class Doku_LexerStateStack { function getCurrent() { return $this->_stack[count($this->_stack) - 1]; } - + /** * Adds a state to the stack and sets it * to be the current state. @@ -243,7 +243,7 @@ class Doku_LexerStateStack { function enter($state) { array_push($this->_stack, $state); } - + /** * Leaves the current state and reverts * to the previous one. @@ -275,7 +275,7 @@ class Doku_Lexer { var $_mode; var $_mode_handlers; var $_case; - + /** * Sets up the lexer in case insensitive matching * by default. @@ -292,7 +292,7 @@ class Doku_Lexer { $this->_mode = &new Doku_LexerStateStack($start); $this->_mode_handlers = array(); } - + /** * Adds a token search pattern for a particular * parsing mode. The pattern does not change the @@ -310,7 +310,7 @@ class Doku_Lexer { } $this->_regexes[$mode]->addPattern($pattern); } - + /** * Adds a pattern that will enter a new parsing * mode. Useful for entering parenthesis, strings, @@ -330,7 +330,7 @@ class Doku_Lexer { } $this->_regexes[$mode]->addPattern($pattern, $new_mode); } - + /** * Adds a pattern that will exit the current mode * and re-enter the previous one. @@ -345,7 +345,7 @@ class Doku_Lexer { } $this->_regexes[$mode]->addPattern($pattern, "__exit"); } - + /** * Adds a pattern that has a special mode. Acts as an entry * and exit pattern in one go, effectively calling a special @@ -364,7 +364,7 @@ class Doku_Lexer { } $this->_regexes[$mode]->addPattern($pattern, "_$special"); } - + /** * Adds a mapping from a mode to another handler. * @param string $mode Mode to be remapped. @@ -374,7 +374,7 @@ class Doku_Lexer { function mapHandler($mode, $handler) { $this->_mode_handlers[$mode] = $handler; } - + /** * Splits the page text into tokens. Will fail * if the handlers report an error or if no @@ -410,7 +410,7 @@ class Doku_Lexer { } return $this->_invokeParser($raw, DOKU_LEXER_UNMATCHED, $pos); } - + /** * Sends the matched token and any leading unmatched * text to the parser changing the lexer to a new @@ -448,7 +448,7 @@ class Doku_Lexer { } return $this->_invokeParser($matched, DOKU_LEXER_MATCHED, $matchPos); } - + /** * Tests to see if the new mode is actually to leave * the current mode and pop an item from the matching @@ -460,7 +460,7 @@ class Doku_Lexer { function _isModeEnd($mode) { return ($mode === "__exit"); } - + /** * Test to see if the mode is one where this mode * is entered for this token only and automatically @@ -472,7 +472,7 @@ class Doku_Lexer { function _isSpecialMode($mode) { return (strncmp($mode, "_", 1) == 0); } - + /** * Strips the magic underscore marking single token * modes. @@ -483,7 +483,7 @@ class Doku_Lexer { function _decodeSpecial($mode) { return substr($mode, 1); } - + /** * Calls the parser method named after the current * mode. Empty content will be ignored. The lexer @@ -512,7 +512,7 @@ class Doku_Lexer { return $this->_parser->$handler($content, $is_match, $pos); } - + /** * Tries to match a chunk of text and if successful * removes the recognised chunk and any leading @@ -567,7 +567,7 @@ function Doku_Lexer_Escape($str) { '/\|/', '/\:/' ); - + $escaped = array( '\.', '\\\\\\\\', |