cenotelie/hime

Test mode does not work

Closed this issue · 1 comments

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.

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