]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: parser: Add keyword rule which allows keywords to be words
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 Mar 2019 05:16:21 +0000 (05:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 15 Mar 2019 05:18:03 +0000 (05:18 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser/grammar.y

index 6f193746fc4b3b2d9f717de233657933aad56f7d..c50ab1e44be8599b8f6734e450a3932c0803e577 100644 (file)
@@ -64,14 +64,15 @@ char* current_block = NULL;
 
 %token                                                 T_APPEND
 %token                                                 T_ASSIGN
-%token                                                 T_DEFINE
-%token                                                 T_END
+%token <string>                                        T_DEFINE
+%token <string>                                        T_END
 %token <string>                                        T_EQUALS
 %token <string>                                        T_IF
 %token                                                 T_EOL
 %token <string>                                        T_WORD
 
 %type <string>                                 define;
+%type <string>                                 keyword;
 %type <string>                                 line;
 %type <string>                                 text;
 %type <string>                                 variable;
@@ -110,9 +111,14 @@ value                                              : words
                                                                $$ = NULL;
                                                        };
 
+                                                       // XXX T_DEFINE is sort of missing here, but adding it
+                                                       // generates a highly ambiguous grammar
+keyword                                                : T_IF;
+
                                                        // IF can show up in values and therefore this
                                                        // hack is needed to parse those properly
-word                                           : T_WORD | T_IF;
+word                                           : T_WORD
+                                                       | keyword;
 
 words                                          : word
                                                        | words word