Say i have some rules and actions, like so
, { do something; }
\. { do_something; }
\( { do_someting; }
\) { do_something); }
: { do_something; }
...
Whenever i match the a rule on the left, the action on the right gets called.
But what if i want to match everything else ? How could i do that?
using something like
.* { do_something; }
won’t work because it also applies to the above rules.
According to the lex spec:
So I would go with:
…and put it as the last rule.
This will match a single character, except for newline (“A <newline> shall not be matched by a period operator”). If you also want to match newline:
Finally, if you do not actually want to consume the character, you need an extended regular expression (ERE) that matches the empty string. You could try:
As I read the spec for lex and EREs, I believe that should work, but it would not surprise me if it tickled some bug somewhere 🙂