Skip to content
Snippets Groups Projects
Commit 03b13d39 authored by sof's avatar sof
Browse files

[project @ 1999-03-01 10:20:39 by sof]

Handle block comments that haven't been closed a little bit better: record
(and report) the start of the comment.

Simple implementation - doesn't bother dealing with nested comments.
parent 9b199f22
No related merge requests found
......@@ -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]
}
<Code,GlaExt>"{-#"{WS}*"GENERATE_SPECS" {
/* these are handled by hscpp */
nested_comments =1;
nested_comments =1; comment_start = hsplineno;
PUSH_STATE(Comment);
}
<Code,GlaExt>"{-#"{WS}*"OPTIONS" {
/* these are for the driver! */
nested_comments =1;
nested_comments =1; comment_start = hsplineno;
PUSH_STATE(Comment);
}
<Code,GlaExt>"{-#"{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);
}
<UserPragma>"#-}" { POP_STATE; RETURN(END_UPRAGMA); }
......@@ -848,7 +849,7 @@ NL [\n\r]
%}
<Code,GlaExt,UserPragma,StringEsc>"{-" {
noGap = FALSE; nested_comments = 1; PUSH_STATE(Comment);
noGap = FALSE; nested_comments = 1; comment_start = hsplineno; PUSH_STATE(Comment);
}
<Comment>[^-{]* |
......@@ -932,8 +933,10 @@ NL [\n\r]
hsperror("unterminated character literal");
}
<Comment><<EOF>> {
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);
}
<String,StringEsc><<EOF>> {
hsplineno = hslineno; hspcolno = hscolno;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment