summaryrefslogtreecommitdiff
path: root/tests/test_tools/simpletest/parser.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_tools/simpletest/parser.php')
-rw-r--r--tests/test_tools/simpletest/parser.php104
1 files changed, 52 insertions, 52 deletions
diff --git a/tests/test_tools/simpletest/parser.php b/tests/test_tools/simpletest/parser.php
index 26519e49..5ac737cf 100644
--- a/tests/test_tools/simpletest/parser.php
+++ b/tests/test_tools/simpletest/parser.php
@@ -25,7 +25,7 @@
define('LEXER_SPECIAL', 5);
}
/**#@-*/
-
+
/**
* Compounded regular expression. Any of
* the contained patterns could match and
@@ -38,7 +38,7 @@
protected $_labels;
protected $_regex;
protected $_case;
-
+
/**
* Constructor. Starts with no patterns.
* @param boolean $case True for case sensitive, false
@@ -51,7 +51,7 @@
$this->_labels = array();
$this->_regex = null;
}
-
+
/**
* Adds a pattern with an optional label.
* @param string $pattern Perl style regex, but ( and )
@@ -66,7 +66,7 @@
$this->_labels[$count] = $label;
$this->_regex = null;
}
-
+
/**
* Attempts to match all patterns at once against
* a string.
@@ -92,7 +92,7 @@
}
return true;
}
-
+
/**
* Compounds the patterns into a single
* regular expression separated with the
@@ -113,7 +113,7 @@
}
return $this->_regex;
}
-
+
/**
* Accessor for perl regex mode flags to use.
* @return string Perl regex flags.
@@ -123,7 +123,7 @@
return ($this->_case ? "msS" : "msSi");
}
}
-
+
/**
* States for a stack machine.
* @package SimpleTest
@@ -131,7 +131,7 @@
*/
class SimpleStateStack {
protected $_stack;
-
+
/**
* Constructor. Starts in named state.
* @param string $start Starting state name.
@@ -140,7 +140,7 @@
function SimpleStateStack($start) {
$this->_stack = array($start);
}
-
+
/**
* Accessor for current state.
* @return string State.
@@ -149,7 +149,7 @@
function getCurrent() {
return $this->_stack[count($this->_stack) - 1];
}
-
+
/**
* Adds a state to the stack and sets it
* to be the current state.
@@ -159,7 +159,7 @@
function enter($state) {
array_push($this->_stack, $state);
}
-
+
/**
* Leaves the current state and reverts
* to the previous one.
@@ -175,7 +175,7 @@
return true;
}
}
-
+
/**
* Accepts text and breaks it into tokens.
* Some optimisation to make the sure the
@@ -191,7 +191,7 @@
protected $_mode;
protected $_mode_handlers;
protected $_case;
-
+
/**
* Sets up the lexer in case insensitive matching
* by default.
@@ -208,7 +208,7 @@
$this->_mode = new SimpleStateStack($start);
$this->_mode_handlers = array($start => $start);
}
-
+
/**
* Adds a token search pattern for a particular
* parsing mode. The pattern does not change the
@@ -229,7 +229,7 @@
$this->_mode_handlers[$mode] = $mode;
}
}
-
+
/**
* Adds a pattern that will enter a new parsing
* mode. Useful for entering parenthesis, strings,
@@ -252,7 +252,7 @@
$this->_mode_handlers[$new_mode] = $new_mode;
}
}
-
+
/**
* Adds a pattern that will exit the current mode
* and re-enter the previous one.
@@ -270,7 +270,7 @@
$this->_mode_handlers[$mode] = $mode;
}
}
-
+
/**
* Adds a pattern that has a special mode. Acts as an entry
* and exit pattern in one go, effectively calling a special
@@ -292,7 +292,7 @@
$this->_mode_handlers[$special] = $special;
}
}
-
+
/**
* Adds a mapping from a mode to another handler.
* @param string $mode Mode to be remapped.
@@ -302,7 +302,7 @@
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
@@ -336,7 +336,7 @@
}
return $this->_invokeParser($raw, LEXER_UNMATCHED);
}
-
+
/**
* Sends the matched token and any leading unmatched
* text to the parser changing the lexer to a new
@@ -372,7 +372,7 @@
$this->_mode->enter($mode);
return $this->_invokeParser($matched, LEXER_ENTER);
}
-
+
/**
* Tests to see if the new mode is actually to leave
* the current mode and pop an item from the matching
@@ -384,7 +384,7 @@
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
@@ -396,7 +396,7 @@
function _isSpecialMode($mode) {
return (strncmp($mode, "_", 1) == 0);
}
-
+
/**
* Strips the magic underscore marking single token
* modes.
@@ -407,7 +407,7 @@
function _decodeSpecial($mode) {
return substr($mode, 1);
}
-
+
/**
* Calls the parser method named after the current
* mode. Empty content will be ignored. The lexer
@@ -424,7 +424,7 @@
$handler = $this->_mode_handlers[$this->_mode->getCurrent()];
return $this->_parser->$handler($content, $is_match);
}
-
+
/**
* Tries to match a chunk of text and if successful
* removes the recognised chunk and any leading
@@ -449,14 +449,14 @@
return true;
}
}
-
+
/**
* Breas HTML into SAX events.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleHtmlLexer extends SimpleLexer {
-
+
/**
* Sets up the lexer with case insensitive matching
* and adds the HTML handlers.
@@ -473,7 +473,7 @@
}
$this->_addInTagTokens();
}
-
+
/**
* List of parsed tags. Others are ignored.
* @return array List of searched for tags.
@@ -483,7 +483,7 @@
return array('a', 'title', 'form', 'input', 'button', 'textarea', 'select',
'option', 'frameset', 'frame', 'label');
}
-
+
/**
* The lexer has to skip certain sections such
* as server code, client code and styles.
@@ -500,7 +500,7 @@
$this->addEntryPattern('<!--', 'text', 'comment');
$this->addExitPattern('-->', 'comment');
}
-
+
/**
* Pattern matches to start and end a tag.
* @param string $tag Name of tag to scan for.
@@ -510,7 +510,7 @@
$this->addSpecialPattern("</$tag>", 'text', 'acceptEndToken');
$this->addEntryPattern("<$tag", 'text', 'tag');
}
-
+
/**
* Pattern matches to parse the inside of a tag
* including the attributes and their quoting.
@@ -523,7 +523,7 @@
$this->addExitPattern('/>', 'tag');
$this->addExitPattern('>', 'tag');
}
-
+
/**
* Matches attributes that are either single quoted,
* double quoted or unquoted.
@@ -542,7 +542,7 @@
$this->addSpecialPattern('=\s*[^>\s]*', 'tag', 'uq_attribute');
}
}
-
+
/**
* Converts HTML tokens into selected SAX events.
* @package SimpleTest
@@ -554,7 +554,7 @@
protected $_tag;
protected $_attributes;
protected $_current_attribute;
-
+
/**
* Sets the listener.
* @param SimpleSaxListener $listener SAX event handler.
@@ -567,7 +567,7 @@
$this->_attributes = array();
$this->_current_attribute = '';
}
-
+
/**
* Runs the content through the lexer which
* should call back to the acceptors.
@@ -578,7 +578,7 @@
function parse($raw) {
return $this->_lexer->parse($raw);
}
-
+
/**
* Sets up the matching lexer. Starts in 'text' mode.
* @param SimpleSaxParser $parser Event generator, usually $self.
@@ -586,11 +586,11 @@
* @access public
* @static
*/
- function &createLexer($parser) {
+ static function &createLexer($parser) {
$lexer = new SimpleHtmlLexer($parser);
return $lexer;
}
-
+
/**
* Accepts a token from the tag mode. If the
* starting element completes then the element
@@ -621,7 +621,7 @@
}
return true;
}
-
+
/**
* Accepts a token from the end tag mode.
* The element name is converted to lower case.
@@ -636,7 +636,7 @@
}
return $this->_listener->endElement(strtolower($matches[1]));
}
-
+
/**
* Part of the tag data.
* @param string $token Incoming characters.
@@ -655,7 +655,7 @@
}
return true;
}
-
+
/**
* A character entity.
* @param string $token Incoming characters.
@@ -665,7 +665,7 @@
*/
function acceptEntityToken($token, $event) {
}
-
+
/**
* Character data between tags regarded as
* important.
@@ -677,7 +677,7 @@
function acceptTextToken($token, $event) {
return $this->_listener->addContent($token);
}
-
+
/**
* Incoming data to be ignored.
* @param string $token Incoming characters.
@@ -688,7 +688,7 @@
function ignore($token, $event) {
return true;
}
-
+
/**
* Decodes any HTML entities.
* @param string $html Incoming HTML.
@@ -696,14 +696,14 @@
* @access public
* @static
*/
- function decodeHtml($html) {
+ static function decodeHtml($html) {
static $translations;
if (! isset($translations)) {
$translations = array_flip(get_html_translation_table(HTML_ENTITIES));
}
return strtr($html, $translations);
}
-
+
/**
* Turns HTML into text browser visible text. Images
* are converted to their alt text and tags are supressed.
@@ -713,7 +713,7 @@
* @access public
* @static
*/
- function normalise($html) {
+ static function normalise($html) {
$text = preg_replace('|<!--.*?-->|', '', $html);
$text = preg_replace('|<img.*?alt\s*=\s*"(.*?)".*?>|', ' \1 ', $text);
$text = preg_replace('|<img.*?alt\s*=\s*\'(.*?)\'.*?>|', ' \1 ', $text);
@@ -724,7 +724,7 @@
return trim($text);
}
}
-
+
/**
* SAX event handler.
* @package SimpleTest
@@ -732,14 +732,14 @@
* @abstract
*/
class SimpleSaxListener {
-
+
/**
* Sets the document to write to.
* @access public
*/
function SimpleSaxListener() {
}
-
+
/**
* Start of element event.
* @param string $name Element name.
@@ -751,7 +751,7 @@
*/
function startElement($name, $attributes) {
}
-
+
/**
* End of element event.
* @param string $name Element name.
@@ -760,7 +760,7 @@
*/
function endElement($name) {
}
-
+
/**
* Unparsed, but relevant data.
* @param string $text May include unparsed tags.