注釈付きでマークされた文字列の解析 #4

コロンをリテラル文字トークンでなく普通のトークンCOLONとでも宣言してやれば違和感が減るかもと思い、

...snip
%token CHAR_EXCEPT_SPECIAL COLON
...snip
char_except_parenthesis :
      CHAR_EXCEPT_SPECIAL
    | COLON
    ;

marked_string_body_with_annotation :
      marked_string_body
    | marked_string_body COLON annotation
    ;
...snip
int yylex(void)
{
    int c = getchar();
    if (c == '(' || c == ')') return c;
    if (c == EOF) return 0;
    yylval = c;
    return c == ':' ? COLON : CHAR_EXCEPT_SPECIAL;
}
...snip

あまり変わらないか……