include <grammar/lex.h> static int n = 0;
class item { char* s; public: item(char* p) { n = n + 1; s = new char[strlen(p)+1]; strcpy(s,p); } char* str() { return s; } int sum() { return n; } }; inline ostream& operator<<(ostream& c, item& a) { c << " (" << a.sum() << ") " << a.str(); return c; } [a-z]+ { item x(yytext); cout << x; } int main() { lex l(istrstream("this is a test\n")); l(); lex k; k(); return 0; }
Hush Online Technology
hush@cs.vu.nl
09/09/98 |
![]() |
![]() |