/////////////
// Compile
/////////////

flex lookahead.l
g++ lex.yy.c -ll -Wno-deprecated

////////////
// lookahead.l
////////////

//Try this regex. Since it never consumes a charcter, it runs forever.
//     ""/("$")           { cout << "Stuck!" << endl; }
//

%{
#include <iostream>
#include <stdio.h>
using namespace std;

%}

%%

 
"foo"/(.*"bar")     { cout << "Found foobar!" << endl; }
"bar"               { cout << "Found bar!" << endl; }
"if"/[^a-zA-Z0-9_]  { cout << "Found an if statement (rather than a variable with if inside of it)!" << endl; }

DO[ \t0-9A-Z]*/=.*"."  { cout << "Var:" << yytext << endl; }
DO                     { cout << "Keyword:" << yytext << endl; }

"-"/[0-9]+          { cout << "NEGATIVE NUMBER" << endl; 
                    // Note: * is illegal after a / but + is allowed. 
                    }
"-"                 { cout << "MINUS" << endl; }
(.|\n)              ; //Ignore all other chars and newlines.
 
%%

int main(int argc, char **argv)
{
 yylex();
 return 1;
}