]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: parser: Make define optional
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 14 Mar 2019 04:56:35 +0000 (04:56 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 14 Mar 2019 04:56:35 +0000 (04:56 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser/grammar.y

index fd5535bb8eb5b8cafbe19c1d3d439bcb686b56c4..7ffded0afc7274f43c16ae76dcd28bb834d94874 100644 (file)
@@ -67,6 +67,7 @@ char* current_block = NULL;
 %token WHITESPACE
 %token <string>                                        WORD
 
+%type <string>                                 define;
 %type <string>                                 line;
 %type <string>                                 text;
 %type <string>                                 variable;
@@ -168,14 +169,23 @@ assignment                                        : variable ASSIGN value NEWLINE
                                                                if (r < 0)
                                                                        ABORT;
                                                        }
-                                                       | define WHITESPACE variable NEWLINE text whitespace END NEWLINE
+                                                       | define text end
                                                        {
-                                                               int r = pakfire_parser_add_declaration(pakfire, declarations, $3, $5);
+                                                               int r = pakfire_parser_add_declaration(pakfire, declarations, $1, $2);
                                                                if (r < 0)
                                                                        ABORT;
                                                        }
 
-define                                         : whitespace DEFINE;
+define                                         : whitespace DEFINE WHITESPACE variable NEWLINE
+                                                       {
+                                                               $$ = $4;
+                                                       }
+                                                       | whitespace variable NEWLINE
+                                                       {
+                                                               $$ = $2;
+                                                       };
+
+end                                                    : whitespace END NEWLINE;
 
 %%