function parse_factor() { switch ($this->peek()) { case 'leftparen': $this->next(); $a = $this->parse_alternates(); $this->parse_terminal('rightparen'); return $a; case 'token': $t = $this->parse_terminal('token'); $n = new enfa(); $n->recognize($t); return $n; case 'epsilon': $t = $this->parse_terminal('epsilon'); $n = new enfa(); $n->add_epsilon($n->initial, $n->final); return $n; } die('CFG/PG got stuck parsing factors.'); }