[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux: rename json parser

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Mar 25 11:37:56 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
e958bf5e by Mehdi Sabwat at 2022-03-25T10:48:27+00:00
demux: rename json parser

ylwrap expects the generated scanner file to be lex.yy.c. The prefix feature in yacc and lex will make sure yy will be replaced by prefix (json in this case).

Functions used outside the generated code will have to be correctly named (exccept YYSTYPE).

- - - - -
5fde254a by Mehdi Sabwat at 2022-03-25T10:48:27+00:00
webvtt: rename css parser

ylwrap expects the generated scanner file to be lex.yy.c. The prefix feature in yacc and lex will make sure yy will be replaced by prefix (css in this case).

Functions used outside the generated code will have to be correctly named (exccept YYSTYPE).

- - - - -


8 changed files:

- modules/codec/webvtt/CSSGrammar.y
- modules/codec/webvtt/CSSLexer.l
- modules/codec/webvtt/css_bridge.h
- modules/codec/webvtt/css_parser.c
- modules/codec/webvtt/css_parser.h
- modules/demux/json/grammar.y
- modules/demux/json/json.h
- modules/demux/json/lexicon.l


Changes:

=====================================
modules/codec/webvtt/CSSGrammar.y
=====================================
@@ -27,6 +27,7 @@
  *
  */
 %define api.pure full
+%define api.prefix {css}
 
 %param { yyscan_t scanner }
 %parse-param { vlc_css_parser_t *css_parser }


=====================================
modules/codec/webvtt/CSSLexer.l
=====================================
@@ -25,6 +25,7 @@
 %option noinput
 %option never-interactive
 %option nostdinit
+%option prefix="css" outfile="lex.yy.c"
 
 %{
 #ifdef HAVE_CONFIG_H


=====================================
modules/codec/webvtt/css_bridge.h
=====================================
@@ -18,10 +18,11 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 #define yyconst const
+#define YYSTYPE CSSSTYPE
 typedef void* yyscan_t;
 typedef struct yy_buffer_state *YY_BUFFER_STATE;
-int yylex_init (yyscan_t* scanner);
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes, int, yyscan_t yyscanner );
-int yylex_destroy (yyscan_t yyscanner );
-void yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner);
+int csslex_init (yyscan_t* scanner);
+YY_BUFFER_STATE css_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+YY_BUFFER_STATE css_scan_bytes (yyconst char *bytes, int, yyscan_t yyscanner );
+int csslex_destroy (yyscan_t yyscanner );
+void css_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner);


=====================================
modules/codec/webvtt/css_parser.c
=====================================
@@ -257,14 +257,14 @@ void vlc_css_parser_Init( vlc_css_parser_t *p_parser )
 bool vlc_css_parser_ParseBytes( vlc_css_parser_t *p_parser, const uint8_t *p_data, size_t i_data )
 {
     yyscan_t yy;
-    yylex_init(&yy);
+    csslex_init(&yy);
 
-    YY_BUFFER_STATE buf = yy_scan_bytes( (const char*) p_data, i_data, yy );
+    YY_BUFFER_STATE buf = css_scan_bytes( (const char*) p_data, i_data, yy );
 
-    bool b_ret = !yyparse( yy, p_parser );
+    bool b_ret = !cssparse( yy, p_parser );
 
-    yy_delete_buffer( buf, yy );
-    yylex_destroy( yy );
+    css_delete_buffer( buf, yy );
+    csslex_destroy( yy );
 
     return b_ret;
 }
@@ -272,14 +272,14 @@ bool vlc_css_parser_ParseBytes( vlc_css_parser_t *p_parser, const uint8_t *p_dat
 bool vlc_css_parser_ParseString( vlc_css_parser_t *p_parser, const char *psz_css )
 {
     yyscan_t yy;
-    yylex_init(&yy);
+    csslex_init(&yy);
 
-    YY_BUFFER_STATE buf = yy_scan_string( psz_css, yy );
+    YY_BUFFER_STATE buf = css_scan_string( psz_css, yy );
 
-    bool b_ret = !yyparse( yy, p_parser );
+    bool b_ret = !cssparse( yy, p_parser );
 
-    yy_delete_buffer( buf, yy );
-    yylex_destroy( yy );
+    css_delete_buffer( buf, yy );
+    csslex_destroy( yy );
 
     return b_ret;
 }


=====================================
modules/codec/webvtt/css_parser.h
=====================================
@@ -22,6 +22,7 @@
 
 //#define YYDEBUG 1
 //#define CSS_PARSER_DEBUG
+#define YYSTYPE CSSSTYPE
 
 typedef struct vlc_css_parser_t vlc_css_parser_t;
 typedef struct vlc_css_selector_t vlc_css_selector_t;


=====================================
modules/demux/json/grammar.y
=====================================
@@ -19,6 +19,8 @@
  *****************************************************************************/
 
 %define api.pure full
+%define api.prefix {json}
+
 %lex-param { void *scanner }
 %parse-param { void *log }
 %parse-param { void *scanner }
@@ -153,9 +155,9 @@ static void yyerror(void *log, void *scanner, struct json_object *result,
 	(void) scanner; (void) result;
 }
 
-extern int yylex_init_extra(void *, void **);
+extern int jsonlex_init_extra(void *, void **);
 extern int yylex(YYSTYPE *value, void *scanner);
-extern int yylex_destroy(void *);
+extern int jsonlex_destroy(void *);
 
 %}
 
@@ -216,12 +218,12 @@ value:
 int json_parse(void *opaque, struct json_object *result)
 {
 	void *scanner;
-	int ret = yylex_init_extra(opaque, &scanner);
+	int ret = jsonlex_init_extra(opaque, &scanner);
 
 	if (ret)
 		return ret;
 
 	ret = yyparse(opaque, scanner, result);
-	yylex_destroy(scanner);
+	jsonlex_destroy(scanner);
 	return ret;
 }


=====================================
modules/demux/json/json.h
=====================================
@@ -24,6 +24,8 @@
 #include <stdbool.h>
 #include <stdio.h>
 
+#define YYSTYPE JSONSTYPE
+
 enum json_type {
     JSON_NULL,
     JSON_BOOLEAN,


=====================================
modules/demux/json/lexicon.l
=====================================
@@ -26,6 +26,7 @@
 %option nostdinit
 %option nounput
 %option noyywrap
+%option prefix="json" outfile="lex.yy.c"
 
 %{
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8ef84bf711b9eb20a2c68fe6baf6386f6c288c21...5fde254a2c61f6dee589def657c38ee19258cb48

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8ef84bf711b9eb20a2c68fe6baf6386f6c288c21...5fde254a2c61f6dee589def657c38ee19258cb48
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list