APPENDIX B ■ A SIMPLE PARSER
} else {
$this->name = $name;
}
if ( is_array( $options ) ) {
if ( isset( $options[self::GIP_RESPECTSPACE] ) ) {
$this->respectSpace=true;
}
}
}
protected function next( Scanner $scanner ) {
$scanner->nextToken();
if (! $this->respectSpace ) {
$scanner->eatWhiteSpace();
}
}
function spaceSignificant( $bool ) {
$this->respectSpace = $bool;
}
static function setDebug( $bool ) {
self::$debug = $bool;
}
function setHandler( Handler $handler ) {
$this->handler = $handler;
}
final function scan( Scanner $scanner ) {
if ( $scanner->tokenType() == Scanner::SOF ) {
$scanner->nextToken();
}
$ret = $this->doScan( $scanner );
if ( $ret &&! $this->discard && $this->term() ) {
$this->push( $scanner );
}
if ( $ret ) {
$this->invokeHandler( $scanner );
}
if ( $this->term() && $ret ) {
$this->next( $scanner );
}
$this->report("::scan returning $ret");
return $ret;
}
function discard() {
$this->discard = true;
}
abstract function trigger( Scanner $scanner );