This is more generic although it allows any variable name
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
extern int num_lines;
static Pakfire pakfire;
static void yyerror(const char* s);
+
%}
%token APPEND
%token END
%token NEWLINE
%token TAB
-%token <string> VARIABLE
-%token <string> VALUE
%token WHITESPACE
+%token <string> WORD
%type <string> variable;
%type <string> value;
+%type <string> words;
%union {
char* string;
| /* empty */
;
-variable : VARIABLE
+variable : WORD
{
$$ = $1;
};
-value : VALUE
- | variable
+value : words
{
$$ = $1;
}
$$ = NULL;
};
+words : WORD
+ {
+ $$ = $1;
+ }
+ | words WHITESPACE WORD;
+
block_opening : variable NEWLINE
{
printf("BLOCK OPEN: %s\n", $1);
digit [0-9]
letter [A-Za-z]
underscore _
-variable {letter}({digit}|{letter}|{underscore})+
+special [/!@$%&*()+=:<>,;?_\.\[\]\-\\]+
whitespace ([ \t])+
-string [a-zA-Z0-9`~!@#$%\^&*()_\-+=:\[\]<>,\.?\\/]+
+
+word ({digit}|{letter}|{special})+
%%
"def" { return DEFINE; }
"end" { return END; }
-{variable} {
- yylval.string = pakfire_strdup(yytext);
- return VARIABLE;
- }
-
-{string} {
+{word} {
yylval.string = pakfire_strdup(yytext);
- return VALUE;
+ return WORD;
}
%%