Skip to content

Instantly share code, notes, and snippets.

@miku
Last active December 29, 2016 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miku/2ea921730b3db2bd4f6b918b6ec381e5 to your computer and use it in GitHub Desktop.
Save miku/2ea921730b3db2bd4f6b918b6ec381e5 to your computer and use it in GitHub Desktop.
Cat in Lex
%%
/* match everything except newline */
. ECHO;
/* match newline */
\n ECHO;
%%
int yywrap(void) {
return 1;
}
int main(void) {
yylex();
return 0;
}
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