注釈付きでマークされた文字列の解析 #5
そんな瑣末なことよりもyylexがif文の塊になりつつあることこそ気にするべきと気付いた。
...snip %token CHAR_EXCEPT_SPECIAL ...snip char_except_parenthesis : CHAR_EXCEPT_SPECIAL | ':' ; marked_string_body_with_annotation : marked_string_body | marked_string_body ':' annotation ; ...snip int yylex(void) { int c = getchar(); switch (c) { case '(': case ')': return c; case ':': return yylval = c; case EOF: return 0; default: return yylval = c, CHAR_EXCEPT_SPECIAL; } } ...snip
COLONの宣言は取った。リテラル文字トークンの方が分かりやすい気がしてきた。