]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: parser: Allow parsing block assignments
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 10 Mar 2019 16:43:37 +0000 (16:43 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 10 Mar 2019 16:43:37 +0000 (16:43 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser/grammar.y
src/libpakfire/parser/scanner.l

index 53b26280fc9cf172e36124ee9bd475b5e208fffe..e034a1fb4debb7568bc76b5e7cba1af77a906b15 100644 (file)
@@ -46,6 +46,8 @@ static void yyerror(const char* s);
 %token WHITESPACE
 %token <string>                                        WORD
 
+%type <string>                                 line;
+%type <string>                                 text;
 %type <string>                                 variable;
 %type <string>                                 value;
 %type <string>                                 words;
@@ -89,7 +91,17 @@ words                                                : WORD
                                                        {
                                                                $$ = $1;
                                                        }
-                                                       | words WHITESPACE WORD;
+                                                       | words WHITESPACE WORD
+                                                       | /* empty */;
+
+line                                           : whitespace words NEWLINE
+                                                       {
+                                                               printf("line = %s\n", $2);
+                                                       };
+
+text                                           : text line
+                                                       | line
+                                                       | /* empty */;
 
 block_opening                          : variable NEWLINE
                                                        {
@@ -108,6 +120,7 @@ block                                               : block_opening assignments block_closing
 
 assignments                                    : assignments assignment
                                                        | assignments empty
+                                                       | assignments block_assignment
                                                        | /* empty */
                                                        ;
 
@@ -116,6 +129,11 @@ assignment                                 : whitespace variable whitespace ASSIGN whitespace value whitespa
                                                                printf("ASSIGNMENT FOUND: %s = %s\n", $2, $6);
                                                        };
 
+block_assignment                       : whitespace DEFINE WHITESPACE variable NEWLINE text whitespace END NEWLINE
+                                                       {
+                                                               printf("BLOCK ASSIGNMENT: %s: %s\n", $4, $6);
+                                                       }
+
 %%
 
 int pakfire_parser_parse_metadata(Pakfire _pakfire, const char* data, size_t len) {
index d1bd32a8f80a2c352298f549c1cfbb850735818a..d920a28dc3c29f9f6d254659cbb1b6afc2224fe6 100644 (file)
@@ -32,7 +32,7 @@ int num_lines;
 digit                  [0-9]
 letter                 [A-Za-z]
 underscore             _
-special                        [/!@$%&*()+=:<>,;?_\.\[\]\-\\]+
+special                        [/'!@$%&*()+=:<>,;?_\.\[\]\-\\]+
 whitespace             ([ \t])+
 
 word                   ({digit}|{letter}|{special})+