X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=userv.git;a=blobdiff_plain;f=lexer.l;h=5b98073c2b8cc88f697680784c60afcf8566cdfb;hp=f3a2957dfc1b5f6d3e4bf194bc0eb13c2c8113c7;hb=26f06c01c4cb357d9e4fb6d0cd0386e70f7e6b6e;hpb=949af4df9625f3371e146f7c78f4f1a17a2bf6db diff --git a/lexer.l b/lexer.l index f3a2957..5b98073 100644 --- a/lexer.l +++ b/lexer.l @@ -133,6 +133,7 @@ struct error_handling { static struct error_handling eh = { tokv_word_errorstostderr, 0,0,0,0,0 }; static int dequote(char *inplace); +static void countnewlines(void); #define YY_NO_UNPUT @@ -251,10 +252,8 @@ error { lr_dir= df_error; lr_loglevel= LOG_ERR; return tokv_word_error; } assert(*++ep); lr_max= (int)strtoul(ep,&ep,10); assert(!*ep); - if (lr_max < lr_min) { - parseerrprint("fd range has min > max"); - return tokv_error; - } + if (lr_max < lr_min) + return parseerrprint("fd range has min > max"); return tokv_fdrange; } [0-9]{1,8}- { @@ -265,23 +264,20 @@ error { lr_dir= df_error; lr_loglevel= LOG_ERR; return tokv_word_error; } lr_max=-1; return tokv_fdstoend; } -([\ \t]*\\[\ \t]*\n[\ \t]*)+ return tokv_lwsp; +([\ \t]*\\[\ \t]*\n[\ \t]*)+ countnewlines(); return tokv_lwsp; [\ \t]+ return tokv_lwsp; [\ \t]*\n cstate->lineno++; return tokv_newline; [\ \t]*\#[^\n]*\n cstate->lineno++; return tokv_newline; -[\ \t]*\#[^\n]* { - parseerrprint("missing newline at eof after comment"); - return tokv_error; - } +[\ \t]*\#[^\n]* return parseerrprint("missing newline at eof after comment"); \"([^\\\"\n]|\\[a-z]|\\[0-9]{3}|\\x[0-9A-Fa-f]{2}|\\[[:punct:]]|\\[ \t]*\n)*\" { + countnewlines(); return dequote(yytext); } -\".* { - parseerrprint("misquoted or unterminated string"); - return tokv_error; - } -[^\ \t\n\\]+ return tokv_barestring; -<> return tokv_eof; +[^\ \t\n\\\"]+ return tokv_barestring; +<> return tokv_eof; +\" return parseerrprint("misquoted or unterminated string"); +\\ return parseerrprint("unexpected backslash"); +. abort(); /* expect lex warning "rule cannot be matched" */ %%