(flex.info)How can I match text only at the end of a file?


Next: How can I make REJECT cascade across start condition boundaries? Prev: Can I build nested parsers that work with the same input file? Up: FAQ
Enter node , (file) or (file)node

How can I match text only at the end of a file?
===============================================

There is no way to write a rule which is "match this text, but only if
it comes at the end of the file".  You can fake it, though, if you
happen to have a character lying around that you don't allow in your
input.  Then you redefine 'YY_INPUT' to call your own routine which, if
it sees an 'EOF', returns the magic character first (and remembers to
return a real 'EOF' next time it's called).  Then you could write:

     <COMMENT>(.|\n)*{EOF_CHAR}    /* saw comment at EOF */


automatically generated by info2www version 1.2.2.9