It really reminds my course "automata" in the university.
How to read the online sample:
-
{var name}: {matching rule} { return ... // you can use var name }
,var name
is an array containing all the matched tokens in the rule - the engine will try to match each expression
This is really-really cool.
You can probably use it to implement something like https://github.com/jquery/esprima with less effort