Grako's ordered match

44 Views Asked by At
@@grammar::tester
@@comments :: /\(\*((?:.|\n)*?)\*\)/
@@eol_comments :: /(#([^\n]*?)$|\/\/([^\n]*?)$)/

start = pattern $;
pattern =
    | number
    | anything
    ;
anything = ?'\S*';
number = ?"-?(0|[1-9]*[0-9]*)(\.[0-9]+)?([Ee][+-]?[0-9]+)?";

This does parse an input files of

xxx

This gives error

grako.exceptions.FailedParse: learn.txt(1:1) Expecting end of text. :

xxx

To my understanding, the pattern rule would try to match 'number', which it cann't. Then it should proceed to try to match anything and successful.

Why doesn't this parse?

0

There are 0 best solutions below