{ return $this->internals[$this->S]->nullable === true; } // S is the first public function firstSet() { return array($this->internals[$this->S]); } } // if executing this file directly, run unit tests if (__FILE__ !== $_SERVER["SCRIPT_FILENAME"]) { return; } print "1A\n"; $parser = new StringParser("needle"); var_dump($parser->match("asdfneedle", 4) === array("j" => 10, "value" => "needle")); try { $parser->match("asdfneedle", 0); var_dump(false); } catch (ParseFailureException $e) { var_dump(true); } print "2\n"; # improper anchoring try { $parser = new RegexParser("#boo#"); var_dump(false); } catch (GrammarException $e) { var_dump(true); } print "3A\n";