%{
+#include "grub2.h"
#include "parser.h"
#include <talloc/talloc.h>
%}
/* anything that's not a metachar: return as a plain word */
{WORD} {
- yylval->strval = talloc_strdup(yyscanner, yytext);
- yylval->expand = 0;
+ yylval->word = create_word_text(yyget_extra(yyscanner), yytext);
return TOKEN_WORD;
}
\${VARNAME} |
\$\{{VARNAME}\} {
- yylval->strval = talloc_strdup(yyscanner, yytext);
- yylval->expand = 1;
- yylval->split = 1;
+ if (yytext[1] == '{') {
+ yytext[yyleng-1] = '\0';
+ yytext++;
+ }
+ yytext++;
+ yylval->word = create_word_var(yyget_extra(yyscanner), yytext,
+ true);
return TOKEN_WORD;
}
}
<sqstring>\' {
yy_pop_state(yyscanner);
- return TOKEN_WORD;
}
<sqstring>[^']+ {
- yylval->expand = 0;
- yylval->split = 0;
- yylval->strval = talloc_strdup(yyscanner, yytext);
+ yylval->word = create_word_text(yyget_extra(yyscanner), yytext);
+ return TOKEN_WORD;
}
/* double-quoted strings: return a single, expanded word token */
}
<dqstring>\" {
yy_pop_state(yyscanner);
+ }
+<dqstring>([^"\$]|\\\")+ {
+ yylval->word = create_word_text(yyget_extra(yyscanner), yytext);
return TOKEN_WORD;
}
-<dqstring>([^"]|\\\")+ {
- yylval->expand = 1;
- yylval->split = 0;
- yylval->strval = talloc_strdup(yyscanner, yytext);
+<dqstring>\${VARNAME} |
+<dqstring>\$\{{VARNAME}\} {
+ if (yytext[1] == '{') {
+ yytext[yyleng-1] = '\0';
+ yytext++;
+ }
+ yytext++;
+ yylval->word = create_word_var(yyget_extra(yyscanner), yytext,
+ false);
+ return TOKEN_WORD;
}
+
/* blocks */
"{" return '{';
"}" return '}';