%top { #include "grammar.h" } %{ #include "manual.h" %} %option noyywrap %option nounput %option yylineno %option stack %option noyy_top_state %x comments %x ins_name try_details ins_details %x encoding encoding_type encoding_content %x encoding_bits encoding_bits_size %x raw_line %% [ \t\n]+ { } "/*" { BEGIN(comments); } "*/" { BEGIN(INITIAL); } [^*\n] { } "Copyright"[^\n]* { yylvalp->string = strdup(yytext); return COPYRIGHT; } "*" { } "\n" { } "@title" { BEGIN(ins_name); return TITLE; } [ ][A-Za-z0-9-]+ { yylvalp->string = strdup(yytext + 1); BEGIN(try_details); return INS_NAME; } [ ,/-] { BEGIN(ins_details); yylvalp->character = yytext[0]; return INS_SEP; } [\n] { BEGIN(INITIAL); } [^\n]* { yylvalp->cstring = yytext; return INS_DETAILS; } [\n] { BEGIN(INITIAL); } "@desc" { yy_push_state(raw_line); return DESC; } "@encoding" { BEGIN(encoding); return ENCODING; } [ ] { } "(" { BEGIN(encoding_type); } [A-Za-z] { yylvalp->string = strdup(yytext); return TYPE; } [0-9]+ { yylvalp->integer = atoi(yytext); return NUMBER; } ")" { BEGIN(encoding); } "{" { BEGIN(encoding_content); } [ \t\n]+ { } "}" { BEGIN(INITIAL); } "@format" { yy_push_state(raw_line); return FORMAT; } "@half" { yy_push_state(raw_line); return HALF; } "@word" { yy_push_state(raw_line); return WORD; } "@syntax" { yy_push_state(raw_line); return SYNTAX; } "@conv" { return CONV; } "@hooks" { return HOOKS; } "@rules" { return RULES; } [^\n]+ { yylvalp->cstring = yytext; return RAW_LINE; } "\n" { yy_pop_state(); } "{" { read_block(temp); yylvalp->cstring = temp; return RAW_BLOCK; } %%