Exemple #1
0
 function it_returns_all_the_reachable_symbols_once_except_Epsilon(Symbol $symbol1, Symbol $symbol2)
 {
     $symbol1->matches($symbol1)->willReturn(true);
     $symbol1->matches($symbol2)->willReturn(false);
     $symbol2->matches($symbol1)->willReturn(false);
     $symbol2->matches($symbol2)->willReturn(true);
     $this->on(EpsilonSymbol::create());
     $this->on($symbol1);
     $this->on($symbol2);
     $this->on($symbol1);
     $this->getReachableSymbols()->shouldReturn([$symbol1, $symbol2]);
 }
Exemple #2
0
 /**
  * @return Symbol[]
  */
 public function getReachableSymbols()
 {
     $symbols = [EpsilonSymbol::create()];
     foreach ($this->transitions as $transition) {
         foreach ($symbols as $symbol) {
             if ($symbol->matches($transition->getSymbol())) {
                 continue 2;
             }
         }
         $symbols[] = $transition->getSymbol();
     }
     return array_slice($symbols, 1);
 }
Exemple #3
0
 private function addReachableStatesByEpsilonSymbol()
 {
     for ($i = 0; $i < count($this->states); $i++) {
         $this->addStates($this->states[$i]->getReachableStatesBySymbol(EpsilonSymbol::create()));
     }
 }
Exemple #4
0
 /**
  * @Given there is an epsilon jump from the state :fromState to the state :toState
  *
  * @param string $fromState
  * @param string $toState
  */
 public function thereIsAnEpsilonJumpFromTheStateToTheState($fromState, $toState)
 {
     $this->states[$fromState]->on(EpsilonSymbol::create())->visit($this->states[$toState]);
 }