From: Michael Tremer Date: Mon, 1 Mar 2021 18:01:27 +0000 (+0000) Subject: parser: Handle "export" keyword X-Git-Tag: 0.9.28~1285^2~671 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ba098cf976469e0d3789a674a3304703b9ab4cb;p=pakfire.git parser: Handle "export" keyword Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/include/pakfire/parser.h b/src/libpakfire/include/pakfire/parser.h index 732b0c57f..78f33c58a 100644 --- a/src/libpakfire/include/pakfire/parser.h +++ b/src/libpakfire/include/pakfire/parser.h @@ -72,6 +72,10 @@ Pakfire pakfire_parser_get_pakfire(PakfireParser parser); struct pakfire_parser_declaration { char* name; char* value; + enum flags { + PAKFIRE_PARSER_DECLARATION_NONE = 0, + PAKFIRE_PARSER_DECLARATION_EXPORT = (1 << 0), + } flags; }; int pakfire_parser_apply_declaration( diff --git a/src/libpakfire/parser/grammar.y b/src/libpakfire/parser/grammar.y index b627d6f35..d1e210fb8 100644 --- a/src/libpakfire/parser/grammar.y +++ b/src/libpakfire/parser/grammar.y @@ -76,7 +76,7 @@ static PakfireParser make_if_stmt(Pakfire pakfire, PakfireParser* parser, const const char* val1, const char* val2, PakfireParser if_block, PakfireParser else_block); static inline int pakfire_parser_new_declaration( - struct pakfire_parser_declaration** declaration, const char* name, const char* value) { + struct pakfire_parser_declaration** declaration, const char* name, const char* value, int flags) { if (!name) return EINVAL; @@ -93,6 +93,9 @@ static inline int pakfire_parser_new_declaration( else d->value = NULL; + // Copy flags + d->flags = flags; + *declaration = d; return 0; @@ -120,6 +123,7 @@ static void pakfire_parser_free_declaration(struct pakfire_parser_declaration* d %token T_END %token T_IF %token T_ELSE +%token T_EXPORT %token T_EQUALS %token T_ASSIGN @@ -208,26 +212,33 @@ subgrammar : T_INDENT grammar T_OUTDENT declaration : key T_ASSIGN value T_EOL { - int r = pakfire_parser_new_declaration(&$$, $1, $3); + int r = pakfire_parser_new_declaration(&$$, $1, $3, 0); if (r) ABORT; } | key T_APPEND value T_EOL { // XXX HANDLE APPEND PROPERLY - int r = pakfire_parser_new_declaration(&$$, $1, $3); + int r = pakfire_parser_new_declaration(&$$, $1, $3, 0); if (r) ABORT; } | key T_EOL empty_lines T_INDENT lines T_OUTDENT T_END T_EOL { - int r = pakfire_parser_new_declaration(&$$, $1, $5); + int r = pakfire_parser_new_declaration(&$$, $1, $5, 0); if (r) ABORT; } | key T_EOL empty_lines T_END T_EOL { - int r = pakfire_parser_new_declaration(&$$, $1, ""); + int r = pakfire_parser_new_declaration(&$$, $1, "", 0); + if (r) + ABORT; + } + | T_EXPORT key T_ASSIGN value T_EOL + { + int r = pakfire_parser_new_declaration(&$$, $key, $value, + PAKFIRE_PARSER_DECLARATION_EXPORT); if (r) ABORT; } diff --git a/src/libpakfire/parser/scanner.l b/src/libpakfire/parser/scanner.l index 4f964d39f..3af278083 100644 --- a/src/libpakfire/parser/scanner.l +++ b/src/libpakfire/parser/scanner.l @@ -232,6 +232,8 @@ scriptlet script(let)? "if" { return T_IF; } "else" { return T_ELSE; } +"export" { return T_EXPORT; } + "==" { return T_EQUALS; } "=" {