X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fgrub2%2Flexer.l;h=5a4447b500452694efff642649c19b888b4e84f2;hp=18d16672e59d4c07019cbcb3ce3d8215ca0fa2da;hb=2ea5eb23b027519372dd20fbe8f958c06ac2aa6c;hpb=0ac0cc8dbd8c3687880f3115ae41f9903e9f2333 diff --git a/discover/grub2/lexer.l b/discover/grub2/lexer.l index 18d1667..5a4447b 100644 --- a/discover/grub2/lexer.l +++ b/discover/grub2/lexer.l @@ -1,10 +1,12 @@ %{ +#include "grub2.h" #include "parser.h" #include %} %option nounput noinput +%option batch never-interactive %option warn %option noyywrap %option stack noyy_top_state @@ -50,16 +52,19 @@ VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#]) /* 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; } @@ -69,12 +74,10 @@ VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#]) } \' { yy_pop_state(yyscanner); - return TOKEN_WORD; } [^']+ { - 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 */ @@ -83,15 +86,25 @@ VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#]) } \" { yy_pop_state(yyscanner); + } +([^"\$]|\\\")+ { + yylval->word = create_word_text(yyget_extra(yyscanner), yytext); return TOKEN_WORD; } -([^"]|\\\")+ { - yylval->expand = 1; - yylval->split = 0; - yylval->strval = talloc_strdup(yyscanner, yytext); +\${VARNAME} | +\$\{{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 '}';