[project @ 1999-06-01 16:15:42 by simonmar]
[ghc-hetmet.git] / ghc / compiler / parser / hslexer.flex
index 02bc1ef..a3bb035 100644 (file)
@@ -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.
 
@@ -322,45 +323,61 @@ NL                        [\n\r]
                              PUSH_STATE(UserPragma);
                              RETURN(SPECIALISE_UPRAGMA);
                            }
+<Code,GlaExt>"{-#"{WS}*"speciali"[sz]e {
+                             PUSH_STATE(UserPragma);
+                             RETURN(SPECIALISE_UPRAGMA);
+                           }
 <Code,GlaExt>"{-#"{WS}*"INLINE" {
                              PUSH_STATE(UserPragma);
                              RETURN(INLINE_UPRAGMA);
                            }
+<Code,GlaExt>"{-#"{WS}*"RULES" {
+                             PUSH_STATE(Code); /* I'm not sure about this */
+                             RETURN(RULES_UPRAGMA);
+                           }
+<Code,GlaExt>"{-#"{WS}*"inline" {
+                             PUSH_STATE(UserPragma);
+                             RETURN(INLINE_UPRAGMA);
+                           }
 <Code,GlaExt>"{-#"{WS}*"NOINLINE" {
                              PUSH_STATE(UserPragma);
                              RETURN(NOINLINE_UPRAGMA);
                            }
+<Code,GlaExt>"{-#"{WS}*"notInline" {
+                             PUSH_STATE(UserPragma);
+                             RETURN(NOINLINE_UPRAGMA);
+                           }
 <Code,GlaExt>"{-#"{WS}*"MAGIC_UNFOLDING" {
                              PUSH_STATE(UserPragma);
                              RETURN(MAGIC_UNFOLDING_UPRAGMA);
                            }
 <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); 
                            }
 
-<Code,GlaExt>"{-#"{WS}*[A-Z_]+ {
+<Code,GlaExt>"{-#"{WS}*[a-zA-Z_]+ {
                              fprintf(stderr, "%s:%d: Warning: Unrecognised pragma '",
                                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); }
+<Code,GlaExt,UserPragma>"#-}"      { POP_STATE; RETURN(END_UPRAGMA); }
 
 %{
     /*
@@ -848,7 +865,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 +949,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;