%{
short count_newlines ( char* s ) {
  short c = 0;
  for(char* r = s; *r; r++) if (*r=='\n') c++;
  return c;
};
%}
/* remove the following line if flex complains */
%option noyywrap
DIGIT    [0-9]
ALPHA    [a-zA-Z][a-zA-Z0-9_]*
%%
{DIGIT}+		{ return NUM; }

"=>"			{ return fsyms(IMPLIES); }
"logical"		{ return fsyms(LOGICAL); }
"physical"		{ return fsyms(PHYSICAL); }
"inherited"		{ return fsyms(INHERITED); }
"synthesized"		{ return fsyms(SYNTHESIZED); }
"compute"		{ return fsyms(COMPUTE); }
"trace"			{ return fsyms(TRACE); }
"let"			{ return fsyms(LET); }
"fail"			{ return fsyms(FAIL); }
"in"			{ return fsyms(IN); }
"do"			{ return fsyms(DO); }
"<-"			{ return fsyms(IS); }
"..."			{ return fsyms(DOTS); }
"#case"			{ return CASE; }
"#forall"			{ return FORALL; }
"#end"			{ return END; }
"#<"			{ return META; }

{ALPHA}			{ return ID; }

\"[^"]*\"		{ lineno += count_newlines(yytext); return CSTRING; }

\/\*[^*/]*\*\/		{ lineno += count_newlines(yytext); }

"%"|"#"|"^"		{ return yytext[0]; }

"_"|"|"|"("|")"|","|"`"|"{"|"}"|":"|"="|";"|"<"|">"|"["|"]"		{ return fsyms(yytext[0]); }

\n			{ cout << "\n"; lineno++; }
\ 			{ cout << " "; }
\t			{ cout << "\t"; }
.			{ return SPECIAL; }
%%
