manpagez: man pages & more
info bison
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.7.6 Performing Actions before Parsing

Sometimes your parser needs to perform some initializations before parsing. The %initial-action directive allows for such arbitrary code.

Directive: %initial-action { code }

Declare that the braced code must be invoked before parsing each time yyparse is called. The code may use $$ and @$ — initial value and location of the lookahead — and the %parse-param.

For instance, if your locations use a file name, you may use

 
%parse-param { char const *file_name };
%initial-action
{
  @$.initialize (file_name);
};

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.