Skip to content

Commit

Permalink
doc: modernize Bison snippets (#420)
Browse files Browse the repository at this point in the history
The proper way to use a pure parser since 2.7 (2012-12-12) is "%define
api.pure full".  The proper way to pass params since 3.0 (2013-07-25)
is "%param".
  • Loading branch information
akimd authored Mar 29, 2024
1 parent d009124 commit ba1efdf
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions doc/flex.texi
Original file line number Diff line number Diff line change
Expand Up @@ -8512,10 +8512,10 @@ is compatible with @code{bison}.
%option bison-bridge bison-locations
%
[[:digit:]]+ { yylval->num = atoi(yytext); return NUMBER;}
[[:alnum:]]+ { yylval->str = strdup(yytext); return STRING;}
"="|";" { return yytext[0];}
. {}
[[:digit:]]+ { yylval->num = atoi(yytext); return NUMBER; }
[[:alnum:]]+ { yylval->str = strdup(yytext); return STRING; }
"="|";" { return yytext[0]; }
. { continue; }
%
@end verbatim
@end example
Expand All @@ -8529,13 +8529,12 @@ As you can see, there really is no magic here. We just use
@example
@verbatim
/* Parser to convert "C" assignments to lisp. */
%{
%require "3.0"
/* Pass the argument to yyparse through to yylex. */
#define YYPARSE_PARAM scanner
#define YYLEX_PARAM scanner
%}
%param {yyscan_t scanner}
%locations
%pure_parser
%define api.pure full
%union {
int num;
char* str;
Expand All @@ -8545,7 +8544,7 @@ As you can see, there really is no magic here. We just use
%%
assignment:
STRING '=' NUMBER ';' {
printf( "(setf %s %d)", $1, $3 );
printf("(setf %s %d)", $1, $3);
}
;
@end verbatim
Expand Down

0 comments on commit ba1efdf

Please sign in to comment.