::quote:: GRAMMAR; $this ->given( $grammar = new File\ReadWrite('hoa://Test/Vfs/WithoutUnification.pp?type=file'), $grammar->writeAll($_grammar), $compiler = LUT\Llk::load($grammar) ) ->when($result = $compiler->parse('"foo"', null, false)) ->then ->boolean($result) ->isTrue() ->when($result = $compiler->parse('\'foo"', null, false)) ->then ->boolean($result) ->isTrue() ->when($result = $compiler->parse('"foo\'', null, false)) ->then ->boolean($result) ->isTrue() ->when($result = $compiler->parse('\'foo\'', null, false)) ->then ->boolean($result) ->isTrue(); } public function case_unification() { $_grammar = << ::quote[0]:: GRAMMAR; $this ->given( $grammar = new File\ReadWrite('hoa://Test/Vfs/Unification.pp?type=file'), $grammar->writeAll($_grammar), $compiler = LUT\Llk::load($grammar) ) ->when($result = $compiler->parse('"foo"', null, false)) ->then ->boolean($result) ->isTrue() ->when($result = $compiler->parse('\'foo\'', null, false)) ->then ->boolean($result) ->isTrue() ->exception(function () use (&$compiler) { $compiler->parse('\'foo"', null, false); }) ->isInstanceOf(LUT\Exception\UnexpectedToken::class) ->exception(function () use (&$compiler) { $compiler->parse('"foo\'', null, false); }) ->isInstanceOf(LUT\Exception\UnexpectedToken::class); } public function case_unification_palindrome() { $_grammar = <<given( $grammar = new File\ReadWrite('hoa://Test/Vfs/Palindrome.pp?type=file'), $grammar->writeAll($_grammar), $compiler = LUT\Llk::load($grammar) ) ->when($result = $compiler->parse('aa', null, false)) ->then ->boolean($result) ->isTrue() ->when($result = $compiler->parse('abba', null, false)) ->then ->boolean($result) ->isTrue() ->when($result = $compiler->parse('abccba', null, false)) ->then ->boolean($result) ->isTrue() ->when($result = $compiler->parse('abcddcba', null, false)) ->then ->boolean($result) ->isTrue() ->exception(function () use (&$compiler) { $compiler->parse('abcdcba', null, false); }) ->isInstanceOf(LUT\Exception\UnexpectedToken::class); } }