diff --git a/Grammar.pp b/Grammar.pp index 46a4500..68677b9 100644 --- a/Grammar.pp +++ b/Grammar.pp @@ -67,21 +67,25 @@ %token identifier [^\s\(\)\[\],\.]+ #expression: - logical_operation() + logical_operation_primary() -logical_operation: +logical_operation_primary: + logical_operation_secondary() + ( ( ::or:: #or | ::xor:: #xor ) logical_operation_primary() )? + +logical_operation_secondary: operation() - ( ( ::and:: #and | ::or:: #or | ::xor:: #xor ) logical_operation() )? + ( ::and:: #and logical_operation_secondary() )? operation: - operand() ( logical_operation() #operation )? + operand() ( logical_operation_primary() #operation )? operand: - ::parenthesis_:: logical_operation() ::_parenthesis:: + ::parenthesis_:: logical_operation_primary() ::_parenthesis:: | value() value: - ::not:: logical_operation() #not + ::not:: logical_operation_primary() #not | | | | | | | array_declaration() | chain() @@ -104,5 +108,5 @@ #function_call: ::parenthesis_:: - ( logical_operation() ( ::comma:: logical_operation() )* )? + ( logical_operation_primary() ( ::comma:: logical_operation_primary() )* )? ::_parenthesis:: diff --git a/Test/Unit/Issue.php b/Test/Unit/Issue.php index 0d86b5f..f87a322 100644 --- a/Test/Unit/Issue.php +++ b/Test/Unit/Issue.php @@ -79,4 +79,43 @@ public function case_github_70() ->boolean($result) ->isTrue(); } + + public function case_github_100_1() + { + $this + ->given( + $ruler = new LUT(), + $rule = '(false and true) or true' + ) + ->when($result = $ruler->assert($rule)) + ->then + ->boolean($result) + ->isTrue(); + } + + public function case_github_100_2() + { + $this + ->given( + $ruler = new LUT(), + $rule = 'false and true or true' + ) + ->when($result = $ruler->assert($rule)) + ->then + ->boolean($result) + ->isTrue(); + } + + public function case_github_100_3() + { + $this + ->given( + $ruler = new LUT(), + $rule = 'true or true and false' + ) + ->when($result = $ruler->assert($rule)) + ->then + ->boolean($result) + ->isTrue(); + } }