fork download
%{
#include<stdio.h>
#include<conio.h>
%}

%%
"int"               { printf("INT\n"); }
"void"              { printf("VOID\n"); }
"printf"            { printf("PRINTF\n"); }
"("                 { printf("LPAREN\n"); }
")"                 { printf("RPAREN\n"); }
"{"                 { printf("LBRACE\n"); }
"}"                 { printf("RBRACE\n"); }
"="                 { printf("ASSIGN\n"); }
";"                 { printf("SEMICOLON\n"); }
"+"                 { printf("PLUS\n"); }
","                 { printf("COMMA\n"); }
"\"%d\""            { printf("FORMAT\n"); }
[0-9]+              { printf("NUM: %s\n", yytext); }
[a-zA-Z][a-zA-Z0-9]*    { printf("ID: %s\n", yytext); }
[ \t\n]             ; /* Skip whitespace and newline */
.                   { printf("ERROR: Unexpected character: %s\n", yytext); }
%%

int main()
{
    yyin = fopen("input.c", "r");
    yylex();
    fclose(yyin);
    return 0;
}
Success #stdin #stdout #stderr 0.02s 6768KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/e3n0Ho/prog:2:1: Syntax error: Operator expected
ERROR: /home/e3n0Ho/prog:31:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit