X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=userv.git;a=blobdiff_plain;f=lexer.l.m4;h=78aab9d4020f4ced1b63aa6942844679f82e6aa0;hp=7b26c1507c6c44981be7a1f89746a2ae29d5cde0;hb=dc9e0a48601e4dc7b3060c1e816692f07e6be095;hpb=c7ad3b51358d0b7704e5670d973ad1a376caf4e1 diff --git a/lexer.l.m4 b/lexer.l.m4 index 7b26c15..78aab9d 100644 --- a/lexer.l.m4 +++ b/lexer.l.m4 @@ -42,6 +42,7 @@ include(language.i4) #include "common.h" #include "daemon.h" #include "lib.h" +#include "both.h" #include "tokens.h" #define HYPHEN '-' @@ -131,6 +132,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 @@ -157,10 +159,8 @@ changequote({*,*}) 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}- { @@ -171,23 +171,20 @@ changequote({*,*}) 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" */ *} changequote(`,') %%