X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fparser%2Fhslexer.flex;fp=ghc%2Fcompiler%2Fparser%2Fhslexer.flex;h=037bee49c31dce64a8c626b31c55a2a4fe0055a3;hb=03b13d394c280ebf7eebcd9cdfc20c8c97c1edd9;hp=02bc1ef711b5a7cf8255840233eb21836f5c59dc;hpb=9b199f223c965638998d50435f33672457d9ffe3;p=ghc-hetmet.git diff --git a/ghc/compiler/parser/hslexer.flex b/ghc/compiler/parser/hslexer.flex index 02bc1ef..037bee4 100644 --- a/ghc/compiler/parser/hslexer.flex +++ b/ghc/compiler/parser/hslexer.flex @@ -114,6 +114,7 @@ static BOOLEAN noGap = TRUE; /* For checking string gaps */ static BOOLEAN forgetindent = FALSE; /* Don't bother applying indentation rules */ static int nested_comments; /* For counting comment nesting depth */ +static int comment_start; /* OLD: Hacky definition of yywrap: see flex doc. @@ -336,19 +337,19 @@ NL [\n\r] } "{-#"{WS}*"GENERATE_SPECS" { /* these are handled by hscpp */ - nested_comments =1; + nested_comments =1; comment_start = hsplineno; PUSH_STATE(Comment); } "{-#"{WS}*"OPTIONS" { /* these are for the driver! */ - nested_comments =1; + nested_comments =1; comment_start = hsplineno; PUSH_STATE(Comment); } "{-#"{WS}*"SOURCE"{WS}*"#"?"-}" { /* these are used by `make depend' and the compiler to indicate that a module should be imported from source */ - nested_comments =1; + nested_comments =1; comment_start = hsplineno; RETURN(SOURCE_UPRAGMA); } @@ -357,7 +358,7 @@ NL [\n\r] input_filename, hsplineno); format_string(stderr, (unsigned char *) yytext, yyleng); fputs("'\n", stderr); - nested_comments = 1; + nested_comments = 1; comment_start = hsplineno; PUSH_STATE(Comment); } "#-}" { POP_STATE; RETURN(END_UPRAGMA); } @@ -848,7 +849,7 @@ NL [\n\r] %} "{-" { - noGap = FALSE; nested_comments = 1; PUSH_STATE(Comment); + noGap = FALSE; nested_comments = 1; comment_start = hsplineno; PUSH_STATE(Comment); } [^-{]* | @@ -932,8 +933,10 @@ NL [\n\r] hsperror("unterminated character literal"); } <> { + char errbuf[ERR_BUF_SIZE]; hsplineno = hslineno; hspcolno = hscolno; - hsperror("unterminated comment"); + sprintf(errbuf, "unterminated comment (which started on line %d)", comment_start); + hsperror(errbuf); } <> { hsplineno = hslineno; hspcolno = hscolno;