]> git.ipfire.org Git - pakfire.git/commitdiff
parser: Handle "export" keyword
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 1 Mar 2021 18:01:27 +0000 (18:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 1 Mar 2021 18:01:27 +0000 (18:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/parser.h
src/libpakfire/parser/grammar.y
src/libpakfire/parser/scanner.l

index 732b0c57ffa381795fd8dff3e652222defe44b52..78f33c58aa43e040c4f2efba4dffbcc76547d438 100644 (file)
@@ -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(
index b627d6f353e8d585a5c114a568888b8530ddec3c..d1e210fb8c836c63142d6c6723d5cc339367092b 100644 (file)
@@ -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;
                                                        }
index 4f964d39fb6f54759fcc7be32871c713d6f5f285..3af27808301e4340fde9078f2f1dffc906c9d3aa 100644 (file)
@@ -232,6 +232,8 @@ scriptlet                           script(let)?
 "if"                                   { return T_IF; }
 "else"                                 { return T_ELSE; }
 
+"export"                               { return T_EXPORT; }
+
 "=="                                   { return T_EQUALS; }
 
 "="                                            {