vlc | branch: master | Rémi Denis-Courmont <r...@remlab.net> | Sun Sep 27 15:30:31 2020 +0300| [7d9fdcfaef5ecb9b590bfd5fa7be450dcdf02d6d] | committer: Rémi Denis-Courmont
JSON tokenisation rules > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7d9fdcfaef5ecb9b590bfd5fa7be450dcdf02d6d --- modules/demux/Makefile.am | 1 + modules/demux/json/lexicon.l | 69 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am index f46fcdb92e..cde3c90776 100644 --- a/modules/demux/Makefile.am +++ b/modules/demux/Makefile.am @@ -514,6 +514,7 @@ libdemux_mock_plugin_la_LIBADD = $(LIBM) noinst_LTLIBRARIES += libdemux_mock_plugin.la libvlc_json_la_SOURCES = \ + demux/json/lexicon.l \ demux/json/json.c demux/json/json.h libvlc_json_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/demux/json libvlc_json_la_LIBADD = $(LTLIBVLCCORE) ../compat/libcompat.la diff --git a/modules/demux/json/lexicon.l b/modules/demux/json/lexicon.l new file mode 100644 index 0000000000..9aa655a245 --- /dev/null +++ b/modules/demux/json/lexicon.l @@ -0,0 +1,69 @@ +/***************************************************************************** + * json/lexicon.l: JSON tokeniser + ***************************************************************************** + * Copyright © 2020 Rémi Denis-Courmont + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +%option 8bit +%option nodefault +%option noinput +%option reentrant +%option nostdinit +%option nounput +%option noyywrap + +%{ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdbool.h> +#include <stdlib.h> +#include "json.h" + +enum { VALUE_NULL, BOOLEAN, NUMBER, STRING }; + +%} + +%% + +[\t\r\n ] ; + +"null" { return VALUE_NULL; } + +"false" { //yylval->boolean = false; + return BOOLEAN; } + +"true" { //yylval->boolean = true; + return BOOLEAN; } + +-?(0|([1-9][0-9]*))(\.[0-9]+)?(e[+-]?[0-9]+)? { + //yylval->number = atof(yytext); + return NUMBER; } + +\"([^"\\]|\\[\"\\/bfnrt]|\\u[0-9A-Fa-f]{4})*\" { + //yylval->string = json_unescape(yytext + 1, yyleng - 2); + return STRING; } + +[{}:,[\]] { return *yytext; } + +. { return *yytext; } + +<<EOF>> { return 0; } + +%% _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits