[vlc-devel] [PATCH 1/2] CSSGrammar: refactor lex/parse-param

Rémi Denis-Courmont remi at remlab.net
Tue Mar 10 08:47:35 CET 2020


Le tiistaina 10. maaliskuuta 2020, 1.58.29 EET Alexandre Janniaux a écrit :
> Scanner is used by both lexer and parser, so %param allows binding to
> both, and css_parser is only used by the parser so there is no need to
> declare it in the yylex function. As the function was not correctly
> exposed to the lexer code, it was leading to different prototype for
> both generated compile unit.
> ---
>  modules/codec/webvtt/CSSGrammar.y | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/modules/codec/webvtt/CSSGrammar.y
> b/modules/codec/webvtt/CSSGrammar.y index f9d7fd06b0..e51b132525 100644
> --- a/modules/codec/webvtt/CSSGrammar.y
> +++ b/modules/codec/webvtt/CSSGrammar.y
> @@ -28,10 +28,9 @@
>   */
>  %define api.pure full
> 
> -%parse-param { yyscan_t scanner }
> +%param { yyscan_t scanner }
>  %parse-param { vlc_css_parser_t *css_parser }
> -%lex-param   { yyscan_t scanner }
> -%lex-param   { vlc_css_parser_t *css_parser }
> +
> 
>  %{
>  #ifdef HAVE_CONFIG_H
> @@ -64,7 +63,7 @@ typedef void* yyscan_t;
> 
>  %{
>  /* See bison pure calling */
> -#define YY_DECL int yylex(union YYSTYPE *, yyscan_t, vlc_css_parser_t *)
> +#define YY_DECL int yylex(union YYSTYPE *, yyscan_t)

The function cannot be called yylex since this might be the global namespace 
(when linking statically). Admittedly, that's a preexisting problem.

Is your argument that the CSS parser context should only be exposed to the 
parser, and not the lexer? This needs explaining in the patch description.

>  YY_DECL;
> 
>  static int yyerror(yyscan_t scanner, vlc_css_parser_t *p, const char *msg)


-- 
レミ・デニ-クールモン
http://www.remlab.net/





More information about the vlc-devel mailing list