Last active
December 29, 2016 12:56
-
-
Save miku/2ea921730b3db2bd4f6b918b6ec381e5 to your computer and use it in GitHub Desktop.
Cat in Lex
This file contains 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
%% | |
/* match everything except newline */ | |
. ECHO; | |
/* match newline */ | |
\n ECHO; | |
%% | |
int yywrap(void) { | |
return 1; | |
} | |
int main(void) { | |
yylex(); | |
return 0; | |
} |
This file contains 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
cat: lex.yy.c | |
cc -o cat lex.yy.c -ll | |
lex.yy.c: cat.l | |
lex cat.l | |
clean: | |
rm -f lex.yy.c | |
rm -f cat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment