]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: parser: Move whitespace handling to variable/value
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 14 Mar 2019 04:46:27 +0000 (04:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 14 Mar 2019 04:46:27 +0000 (04:46 +0000)
This removes more shift/reduce and reduce/reduce errors

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser/grammar.y

index 35bc72fcd425ae6150104328debd6b2fd56f963e..fd5535bb8eb5b8cafbe19c1d3d439bcb686b56c4 100644 (file)
@@ -95,14 +95,14 @@ whitespace                                  : WHITESPACE
                                                        | /* empty */
                                                        ;
 
-variable                                       : WORD
+variable                                       : whitespace WORD whitespace
                                                        {
-                                                               $$ = $1;
+                                                               $$ = $2;
                                                        };
 
-value                                          : words
+value                                          : whitespace words whitespace
                                                        {
-                                                               $$ = $1;
+                                                               $$ = $2;
                                                        }
                                                        | /* empty */
                                                        {
@@ -162,19 +162,21 @@ assignments                                       : assignments assignment_or_empty
 assignment_or_empty                    : assignment
                                                        | empty;
 
-assignment                                     : whitespace variable whitespace ASSIGN whitespace value whitespace NEWLINE
+assignment                                     : variable ASSIGN value NEWLINE
                                                        {
-                                                               int r = pakfire_parser_add_declaration(pakfire, declarations, $2, $6);
+                                                               int r = pakfire_parser_add_declaration(pakfire, declarations, $1, $3);
                                                                if (r < 0)
                                                                        ABORT;
                                                        }
-                                                       | whitespace DEFINE WHITESPACE variable NEWLINE text whitespace END NEWLINE
+                                                       | define WHITESPACE variable NEWLINE text whitespace END NEWLINE
                                                        {
-                                                               int r = pakfire_parser_add_declaration(pakfire, declarations, $4, $6);
+                                                               int r = pakfire_parser_add_declaration(pakfire, declarations, $3, $5);
                                                                if (r < 0)
                                                                        ABORT;
                                                        }
 
+define                                         : whitespace DEFINE;
+
 %%
 
 static void cleanup(void) {