fork download
  1. % {
  2. /* Lex Program recognizing some tokens - C variables and constants*/
  3. % }
  4. %%
  5. letter [a-z A-Z]
  6. digit [0-9]
  7. id {letter} ({letter} / {digit} )* /*identifier starts with a letter*/
  8. number {digit+}(.{digit+} + ) ) ? {digit}+ )
  9. %%
  10. {id} {printf("%s...is an identifier",yytext);}
  11. {if} {printf("%s...is a keyword",yytext);}
  12. {else} {printf("%s...is a keyword",yytext);}
  13. "< "{printf("%s...is less than operator",yytext);}
  14. "<= "{printf("%s...is less than or equal to operator",yytext);}
  15. "> "{printf("%s...is greater than operator",yytext);}
  16. ">= "{printf("%s...is grater than or equal to operator",yytext);}
  17. "== "{printf("%s...is equal to operator",yytext);}
  18. "!= "{pirntf("%s...not equal to operator",yytext);}
  19. {numbers} {printf("%s...is a number",yytext);}
  20. %%
  21.  
Success #stdin #stdout #stderr 0.04s 6984KB
stdin
helelo 8 89 =
stdout
Standard output is empty
stderr
ERROR: /home/COpHsh/prog:20:2: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit