ケースをサンプルするだけ
test.grm
%{
#include <stdio.h>
%}
%token id
%start program
%%
program: exp
exp: ID
ID: id
bison -d test.grm -o test.c aute test.h を生成します
#ifndef YY_TEST_H
# define YY_TEST_H
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype {
id = 258
};
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_TEST_H */
#include がこのファイルに含まれていないことがわかります。%{ %} のヘッド ファイルで定義された定義を .grm が使用する場合に問題が発生します。
これが私の質問です。test.h を自動生成するにはどうすればよいですか? %{ %} に含まれるものを含めます。