今更だけれど、あんまりきちんとまとまったものがなかったので。クラスを使った場合は、今までとは結構書き方が変わるのとautotoolsとの相性が非常によくない(ylwrapを書き換えればうまくいくと思う)ので、字句解析側、構文解析側ともに、従来の書き方で。 まずはflex側。 再入可能な字句解析機に変更する %option reentrant を指定すると、再入可能な字句解析機が出来る。c++のlexerを作るよりも、既存のコードを書き換える量が少なくてすむかも。 これで作成されるlexerは extern int yylex (yyscan_t yyscanner); となる。yyscan_t は実際は void* で、字句解析時には struct yyguts_t* にキャストされて利用される。構文解析側からは、yyscan_t を同様に定義するか邪魔くさければ void* でも良いかも