# HG changeset patch # User jwe # Date 791685014 0 # Node ID 54abf1b3a8e9a0ce7ded09837a9e66fe5b87be2f # Parent d5b0d11e3200f8e7f1b83fb0ed486352beedd4d5 [project @ 1995-02-02 00:30:14 by jwe] diff -r d5b0d11e3200 -r 54abf1b3a8e9 src/lex.l --- a/src/lex.l Wed Feb 01 22:25:07 1995 +0000 +++ b/src/lex.l Thu Feb 02 00:30:14 1995 +0000 @@ -121,8 +121,8 @@ static int handle_string (char delim, int text_style = 0); static int handle_close_brace (int spc_gobbled); static int handle_identifier (char *tok, int spc_gobbled); -static int have_continuation (void); -static int have_ellipsis_continuation (void); +static int have_continuation (int trailing_comments_ok = 1); +static int have_ellipsis_continuation (int trailing_comments_ok = 1); static int eat_whitespace (void); static int eat_continuation (void); @@ -1460,7 +1460,7 @@ // characters, return 0. Otherwise, return 1. static int -have_continuation (void) +have_continuation (int trailing_comments_ok) { ostrstream buf; @@ -1478,7 +1478,10 @@ case '%': case '#': - in_comment = 1; + if (trailing_comments_ok) + in_comment = 1; + else + goto cleanup; break; case '\n': @@ -1487,26 +1490,25 @@ return 1; default: - if (in_comment) - break; - else - { - buf << ends; - char *s = buf.str (); - if (s) - { - int len = strlen (s); - while (len--) - yyunput (s[len], yytext); - } - delete [] s; - return 0; - } + if (! in_comment) + goto cleanup; + break; } } yyunput (c, yytext); + return 0; + cleanup: + buf << ends; + char *s = buf.str (); + if (s) + { + int len = strlen (s); + while (len--) + yyunput (s[len], yytext); + } + delete [] s; return 0; } @@ -1515,13 +1517,13 @@ // line character. static int -have_ellipsis_continuation (void) +have_ellipsis_continuation (int trailing_comments_ok) { char c1 = yyinput (); if (c1 == '.') { char c2 = yyinput (); - if (c2 == '.' && have_continuation ()) + if (c2 == '.' && have_continuation (trailing_comments_ok)) return 1; else { @@ -1575,7 +1577,7 @@ } else { - if (have_continuation ()) + if (have_continuation (0)) escape_pending = 0; else { @@ -1587,7 +1589,7 @@ } else if (c == '.') { - if (! have_ellipsis_continuation ()) + if (! have_ellipsis_continuation (0)) buf << (char) c; } else if (c == '\n') diff -r d5b0d11e3200 -r 54abf1b3a8e9 src/parse.y --- a/src/parse.y Wed Feb 01 22:25:07 1995 +0000 +++ b/src/parse.y Thu Feb 02 00:30:14 1995 +0000 @@ -300,15 +300,9 @@ YYABORT; } | simple_list parse_error - { - yyerror ("parse error"); - ABORT_PARSE; - } + { ABORT_PARSE; } | parse_error - { - yyerror ("parse error"); - ABORT_PARSE; - } + { ABORT_PARSE; } ; input1 : '\n' @@ -322,6 +316,7 @@ ; parse_error : LEXICAL_ERROR + { yyerror ("parse error"); } | error ;