Skip to content

Instantly share code, notes, and snippets.

@snaka
Created March 24, 2016 20:08
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 snaka/c8bc1dc96197ec50544f to your computer and use it in GitHub Desktop.
Save snaka/c8bc1dc96197ec50544f to your computer and use it in GitHub Desktop.
lex(flex)でズンドコキヨシ
%option noyywrap
%{
int zun = 0;
%}
%state ZUN
%state FILLED
%%
<INITIAL>ズン { ECHO; BEGIN ZUN; zun = 1; }
<ZUN>ズン {
ECHO;
zun++;
if (zun >= 4) BEGIN FILLED;
}
<ZUN>ドコ {
ECHO;
BEGIN INITIAL;
zun = 0;
}
<FILLED>ドコ {
ECHO;
printf("\n\キ・ヨ・シ!/\n");
exit(0);
}
%%
int main(void) {
yylex();
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment