Skip to content

Instantly share code, notes, and snippets.

@wei2912
Created December 13, 2014 05:15
Show Gist options
  • Select an option

  • Save wei2912/5362ee165f2f8407fdf0 to your computer and use it in GitHub Desktop.

Select an option

Save wei2912/5362ee165f2f8407fdf0 to your computer and use it in GitHub Desktop.
%{
#include <stdio.h>
enum yytokentype {
COMMA = 258,
SEMICOLON = 259
};
char *yylval;
%}
%%
"#".+?"\n" { /* comment */ }
\s+ {}
"," { return COMMA; }
";" { return SEMICOLON; }
%%
int main(int argc, char **argv) {
int tok;
while (tok = yylex()) {
printf("%d\n", tok);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment