cenotelie / hime

Apache License 2.0
27 stars 4 forks source link

Test mode does not work #104

Closed nitroxis closed 1 month ago

nitroxis commented 9 months ago

Hi, I think the --test mode of himecc doesn't work properly. Using this trivial grammar file:

grammar Test
{
    options
    {
        Axiom = "expression";
    }
    terminals
    {
        A -> 'a'+;
    }
    rules
    {
        expression -> A ;
    }
}

Running echo "aaa" | himecc --test Test.gram yields

{"errors":[{"type":"UnexpectedToken","position":{"line":1,"column":1},"length":3,"value":"aaa","terminal":{"id":3,"name":"A"},"expected":[]}],"root":null}

But running it with e.g. the .NET runtime works as expected, yielding one A = aaa ASTNode.

woutersl commented 1 month ago

Thank you for reporting this. This is now fixed on master. Note that to make the command work, -n should be passed to echo so that no trailing line ending is used. Otherwise this fails because the input will be aaa\n:

echo -n "aaa" | himecc --test Test.gram