X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fgrub2%2Flexer.l;h=e1aad9931252f98be623a5fc87035a61f3de4ef2;hp=3e1f9fa148c62174acb30258328c578c231f954e;hb=a1fb38f17bfa60aac89d0dd21dd8ccc739d794bf;hpb=e651a16f85e9df51ed65d96ea32932f69cbf302d diff --git a/discover/grub2/lexer.l b/discover/grub2/lexer.l index 3e1f9fa..e1aad99 100644 --- a/discover/grub2/lexer.l +++ b/discover/grub2/lexer.l @@ -3,6 +3,8 @@ #include "grub2.h" #include "parser.h" #include + +void yyerror(struct grub2_parser *parser, const char *fmt, ...); %} %option nounput noinput @@ -12,6 +14,7 @@ %option stack noyy_top_state %option reentrant %option bison-bridge +%option yylineno %option noyyalloc noyyfree noyyrealloc %option extra-type="struct grub2_parser *" %option header-file="lexer.h" @@ -20,7 +23,7 @@ %x sqstring %x dqstring -WORD [^{}|&$;<> \t\n'"]+ +WORD [^{}|&$;<> \t\n'"#]+ VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#]) %% @@ -28,7 +31,7 @@ VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#]) /* discard leading & trailing whitespace, but keep inter-word delimeters */ ^[ \t]+ ; [ \t]+$ ; -[ \t]* return TOKEN_DELIM; +[ \t]+ return TOKEN_DELIM; /* reserved words */ "[[" return TOKEN_LDSQBRACKET; @@ -46,6 +49,7 @@ VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#]) "in" return TOKEN_IN; "menuentry" return TOKEN_MENUENTRY; "select" return TOKEN_SELECT; +"submenu" return TOKEN_SUBMENU; "then" return TOKEN_THEN; "time" return TOKEN_TIME; "until" return TOKEN_UTIL; @@ -114,10 +118,12 @@ VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#]) [ \t]*(;|\n)[ \t]* return TOKEN_EOL; /* strip comments */ -#.*$ ; - +#.* ; -. printf("unknown token '%s'\n", yytext); exit(1); +. { + yyerror(yyget_extra(yyscanner), "unknown token '%s'\n", yytext); + yyterminate(); + } %%