DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(automk14.info.gz) Yacc and Lex

Info Catalog (automk14.info.gz) Program variables (automk14.info.gz) Programs (automk14.info.gz) C++ Support
 
 7.6 Yacc and Lex support
 ========================
 
 Automake has somewhat idiosyncratic support for Yacc and Lex.
 
    Automake assumes that the `.c' file generated by `yacc' (or `lex')
 should be named using the basename of the input file.  That is, for a
 yacc source file `foo.y', Automake will cause the intermediate file to
 be named `foo.c' (as opposed to `y.tab.c', which is more traditional).
 
    The extension of a yacc source file is used to determine the
 extension of the resulting `C' or `C++' file.  Files with the extension
 `.y' will be turned into `.c' files; likewise, `.yy' will become `.cc';
 `.y++', `c++'; and `.yxx', `.cxx'.
 
    Likewise, lex source files can be used to generate `C' or `C++'; the
 extensions `.l', `.ll', `.l++', and `.lxx' are recognized.
 
    You should never explicitly mention the intermediate (`C' or `C++')
 file in any `SOURCES' variable; only list the source file.
 
    The intermediate files generated by `yacc' (or `lex') will be
 included in any distribution that is made.  That way the user doesn't
 need to have `yacc' or `lex'.
 
    If a `yacc' source file is seen, then your `configure.in' must
 define the variable `YACC'.  This is most easily done by invoking the
 macro `AC_PROG_YACC' ( Particular Program Checks
 (autoconf)Particular Programs.).
 
    Similarly, if a `lex' source file is seen, then your `configure.in'
 must define the variable `LEX'.  You can use `AC_PROG_LEX' to do this
 ( Particular Program Checks (autoconf)Particular Programs.).
 Automake's `lex' support also requires that you use the `AC_DECL_YYTEXT'
 macro--automake needs to know the value of `LEX_OUTPUT_ROOT'.  This is
 all handled for you if you use the `AM_PROG_LEX' macro ( Macros).
 
    Automake makes it possible to include multiple `yacc' (or `lex')
 source files in a single program.  Automake uses a small program called
 `ylwrap' to run `yacc' (or `lex') in a subdirectory.  This is necessary
 because yacc's output filename is fixed, and a parallel make could
 conceivably invoke more than one instance of `yacc' simultaneously.
 The `ylwrap' program is distributed with Automake.  It should appear in
 the directory specified by `AC_CONFIG_AUX_DIR' ( Finding
 `configure' Input (autoconf)Input.), or the current directory if that
 macro is not used in `configure.in'.
 
    For `yacc', simply managing locking is insufficient.  The output of
 `yacc' always uses the same symbol names internally, so it isn't
 possible to link two `yacc' parsers into the same executable.
 
    We recommend using the following renaming hack used in `gdb':
      #define	yymaxdepth c_maxdepth
      #define	yyparse	c_parse
      #define	yylex	c_lex
      #define	yyerror	c_error
      #define	yylval	c_lval
      #define	yychar	c_char
      #define	yydebug	c_debug
      #define	yypact	c_pact
      #define	yyr1	c_r1
      #define	yyr2	c_r2
      #define	yydef	c_def
      #define	yychk	c_chk
      #define	yypgo	c_pgo
      #define	yyact	c_act
      #define	yyexca	c_exca
      #define yyerrflag c_errflag
      #define yynerrs	c_nerrs
      #define	yyps	c_ps
      #define	yypv	c_pv
      #define	yys	c_s
      #define	yy_yys	c_yys
      #define	yystate	c_state
      #define	yytmp	c_tmp
      #define	yyv	c_v
      #define	yy_yyv	c_yyv
      #define	yyval	c_val
      #define	yylloc	c_lloc
      #define yyreds	c_reds
      #define yytoks	c_toks
      #define yylhs	c_yylhs
      #define yylen	c_yylen
      #define yydefred c_yydefred
      #define yydgoto	c_yydgoto
      #define yysindex c_yysindex
      #define yyrindex c_yyrindex
      #define yygindex c_yygindex
      #define yytable	 c_yytable
      #define yycheck	 c_yycheck
      #define yyname   c_yyname
      #define yyrule   c_yyrule
 
    For each define, replace the `c_' prefix with whatever you like.
 These defines work for `bison', `byacc', and traditional `yacc's.  If
 you find a parser generator that uses a symbol not covered here, please
 report the new name so it can be added to the list.
 
Info Catalog (automk14.info.gz) Program variables (automk14.info.gz) Programs (automk14.info.gz) C++ Support
automatically generated byinfo2html