Last active
November 24, 2018 03:08
-
-
Save nityeshaga/ae606b7e6f1b29dc6e66ff93af485621 to your computer and use it in GitHub Desktop.
lex sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %{ | |
| #include <stdio.h> | |
| #include "y.tab.h" | |
| void yyerror(char *s); | |
| %} | |
| letter [a-zA-Z] | |
| digit [0-9] | |
| %% | |
| {letter}({letter}|{digit})* {countt++;} | |
| [0-9]+ {yylval.val=atoi(yytext);return NUM;} | |
| [ \t\n] {;} | |
| . {return yytext[0];} | |
| %% | |
| void yyerror(char *s) | |
| { | |
| printf("ERROR IN LINENO : %d \n",yylineno); | |
| exit(0); | |
| } | |
| int yywrap() | |
| { | |
| return 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment