Skip to content

Instantly share code, notes, and snippets.

@vishichoudhary
Created November 22, 2017 20:30
Show Gist options
  • Save vishichoudhary/fec4aad9d0e2f32bb5592b6aeac0ca27 to your computer and use it in GitHub Desktop.
Save vishichoudhary/fec4aad9d0e2f32bb5592b6aeac0ca27 to your computer and use it in GitHub Desktop.
ho haa
%{
#include<stdio.h>
%}
delim [\t ]
ws {delim}+
letter [A-Za-z]
digit [0-9]
id {letter}({letter}|{digit})*
num {digit}+(\.{digit}+)?(E[+/-]?{digit}+)?
%%
ws {printf("no action fuck you");}
if|else|then {printf("%s is a keyword",yytext);}
{id} {printf("%s is a identifier",yytext);}
{num} {printf(" it is a number");}
"<" {printf("it is a relational operator less than");}
"<=" {printf("it is a relational operator less than or equal");}
">" {printf("it is a relational operator greater than");}
">=" {printf("it is a relational operator greater than");}
"==" {printf("it is a relational operator equal");}
"<>" {printf("it is a relational operator not equal");}
. { printf("i don't recognize it ");}
%%
main()
{
yylex();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment