check_PROGRAMS =
lib_LTLIBRARIES =
libexec_PROGRAMS =
+noinst_LTLIBRARIES =
pkgpyexec_LTLIBRARIES =
pkginclude_HEADERS =
# ------------------------------------------------------------------------------
+CLEANFILES += \
+ src/libpakfire/grammar.c \
+ src/libpakfire/grammar.h \
+ src/libpakfire/scanner.c
+
+noinst_LTLIBRARIES += \
+ libpakfire-parser.la
+
+libpakfire_parser_la_SOURCES = \
+ src/libpakfire/parser/grammar.h \
+ src/libpakfire/parser/grammar.y \
+ src/libpakfire/parser/scanner.l
+
+libpakfire_parser_la_CFLAGS = \
+ $(AM_CFLAGS)
+
+src/libpakfire/parser/scanner.c: src/libpakfire/parser/grammar.h
+
lib_LTLIBRARIES += \
libpakfire.la
src/libpakfire/include/pakfire/package.h \
src/libpakfire/include/pakfire/packagelist.h \
src/libpakfire/include/pakfire/pakfire.h \
+ src/libpakfire/include/pakfire/parser.h \
src/libpakfire/include/pakfire/private.h \
src/libpakfire/include/pakfire/problem.h \
src/libpakfire/include/pakfire/relation.h \
-Wl,--version-script=$(top_srcdir)/src/libpakfire/libpakfire.sym
libpakfire_la_LIBADD = \
+ libpakfire-parser.la \
$(ARCHIVE_LIBS) \
$(GPGME_LIBS) \
$(LIBGCRYPT_LIBS) \
$(SOLV_LIBS)
libpakfire_la_DEPENDENCIES = \
- src/libpakfire/libpakfire.sym
+ src/libpakfire/libpakfire.sym \
+ libpakfire-parser.la
EXTRA_DIST += \
src/libpakfire/libpakfire.sym
return 1;
}
- #warning actually parse this
+ // Parse metadata file
+ r = pakfire_parser_parse_metadata(archive->pakfire, data, data_size);
pakfire_free(data);
- return 0;
+ return r;
}
static int pakfire_archive_parse_entry_filelist(PakfireArchive archive,
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2019 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 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 General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#ifndef PAKFIRE_PARSER_H
+#define PAKFIRE_PARSER_H
+
+#ifdef PAKFIRE_PRIVATE
+
+int pakfire_parser_parse_metadata(const char* data, size_t len);
+
+#endif /* PAKFIRE_PRIVATE */
+
+#endif /* PAKFIRE_PARSER_H */
--- /dev/null
+/grammar.[ch]
+/scanner.c
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2019 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 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 General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+%{
+#include <stdio.h>
+#include <stdlib.h>
+
+#define YYERROR_VERBOSE 1
+
+typedef struct yy_buffer_state* YY_BUFFER_STATE;
+extern YY_BUFFER_STATE yy_scan_bytes(const char* buffer, size_t len);
+extern void yy_delete_buffer(YY_BUFFER_STATE buffer);
+
+extern int yylex();
+extern int yyparse();
+void yyerror(const char* s);
+%}
+
+%token APPEND
+%token ASSIGN
+%token DEFINE
+%token END
+%token NEWLINE
+%token TAB
+%token VARIABLE
+%token VALUE
+%token WHITESPACE
+
+%%
+
+top: NEWLINE
+
+%%
+
+int pakfire_parser_parse_metadata(const char* data, size_t len) {
+ YY_BUFFER_STATE buffer = yy_scan_bytes(data, len);
+ int r = yyparse();
+ yy_delete_buffer(buffer);
+
+ return r;
+}
+
+void yyerror(const char* s) {
+ fprintf(stderr, "Parse error: %s\n", s);
+ abort();
+}
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2019 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 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 General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+%option nounput noinput noyywrap yylineno
+
+%{
+#define YY_DECL int yylex()
+
+#include "grammar.h"
+%}
+
+%%
+
+[ \t] { return WHITESPACE; }
+\t { return TAB; }
+\n { return NEWLINE; }
+
+[A-Za-z] { return VARIABLE; }
+[A-Za-z0-9] { return VALUE; }
+
+"=" { return ASSIGN; }
+"+=" { return APPEND; }
+
+"define" { return DEFINE; }
+"def" { return DEFINE; }
+"end" { return END; }
+
+%%