hoaproject/Ruler

Disassembler: parentheses

flip111 opened this issue · 3 comments

Hi, the disassembler does not produce the original rule back in some cases. But adds unnecessary parentheses. Consider the following code:

<?php
$hoaDisassembler = new Hoa\Ruler\Visitor\Disassembly();
$model = Ruler::interprete('2 = 3');
$rule = $hoaDisassembler->visit($model);
echo $rule;

This outputs (2 = 3) where the 2 = 3 without parentheses should be sufficient (as the original rule).

Hello :-),

It's a normal and expected behavior since we do not have this information on the model (the parenthesis are skipped during the parsing).

Why can the Ruler not read from the PP grammar definition that ( ) are not needed?

Because it's a useless information :-).