* *
**********************************************************************/
-#include "../../includes/config.h"
+/* The includes/config.h one */
+#include "config.h"
#include <stdio.h>
%%
%{
+ /*
+ * Simple comments and whitespace. Normally, we would just ignore these, but
+ * in case we're processing a string escape, we need to note that we've seen
+ * a gap.
+ *
+ * Note that we cater for a comment line that *doesn't* end in a newline.
+ * This is incorrect, strictly speaking, but seems like the right thing
+ * to do. Reported by Rajiv Mirani. (WDP 95/08)
+ *
+ * Hackily moved up here so that --<<EOF>> will match -- SOF 5/97
+ */
+%}
+
+<Code,GlaExt,StringEsc>"--"[^\n\r]*{NL}?{WS}* |
+<Code,GlaExt,UserPragma,StringEsc>{WS}+ { noGap = FALSE; }
+
+%{
/*
* Special GHC pragma rules. Do we need a start state for interface files,
* so these won't be matched in source files? --JSM
*/
+
%}
+%{
+/* I believe the next rule is not ever matched.
+
+ The '#line ' rule is un-cool, recognising a cpp directive inside hs source.
+ Driver has now been modified to output `standard' {-# LINE ..-} pragmas
+ where possible, so the lexer should now never see cpp directives
+ like '# ' and '#line'.
+
+ -- SOF
+
<Code,GlaExt>^"# ".*{NL} {
char tempf[FILENAME_SIZE];
sscanf(yytext+1, "%d \"%[^\"]", &hslineno, tempf);
new_filename(tempf);
hsplineno = hslineno; hscolno = 0; hspcolno = 0;
}
+*/
+%}
<Code,GlaExt>"{-# LINE ".*"-}"{NL} {
/* partain: pragma-style line directive */
PUSH_STATE(UserPragma);
RETURN(INLINE_UPRAGMA);
}
+<Code,GlaExt>"{-#"{WS}*"NOINLINE" {
+ PUSH_STATE(UserPragma);
+ RETURN(NOINLINE_UPRAGMA);
+ }
<Code,GlaExt>"{-#"{WS}*"MAGIC_UNFOLDING" {
PUSH_STATE(UserPragma);
RETURN(MAGIC_UNFOLDING_UPRAGMA);
}
-<Code,GlaExt>"{-#"{WS}*"DEFOREST" {
- PUSH_STATE(UserPragma);
- RETURN(DEFOREST_UPRAGMA);
- }
<Code,GlaExt>"{-#"{WS}*"GENERATE_SPECS" {
/* these are handled by hscpp */
nested_comments =1;
PUSH_STATE(Comment);
}
+<Code,GlaExt>"{-#"{WS}*"OPTIONS" {
+ /* these are for the driver! */
+ nested_comments =1;
+ 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;
+ RETURN(SOURCE_UPRAGMA);
+ }
+
<Code,GlaExt>"{-#"{WS}*[A-Z_]+ {
- fprintf(stderr, "\"%s\", line %d: Warning: Unrecognised pragma '",
+ fprintf(stderr, "%s:%d: Warning: Unrecognised pragma '",
input_filename, hsplineno);
format_string(stderr, (unsigned char *) yytext, yyleng);
fputs("'\n", stderr);
<GlaExt>"_ccall_GC_" { RETURN(CCALL_GC); }
<GlaExt>"_casm_" { RETURN(CASM); }
<GlaExt>"_casm_GC_" { RETURN(CASM_GC); }
+<GlaExt>"foreign" { RETURN(FOREIGN); }
+<GlaExt>"export" { RETURN(EXPORT); }
+<GlaExt>"unsafe" { RETURN(UNSAFE); }
+<GlaExt>"_stdcall" { RETURN(STDCALL); }
+<GlaExt>"_ccall" { RETURN(C_CALL); }
+<GlaExt>"_pascal" { RETURN(PASCAL); }
+<GlaExt>"_fastcall" { RETURN(FASTCALL); }
+<GlaExt>"dynamic" { RETURN(DYNAMIC); }
%{
/*
<Code,GlaExt>"<-" { RETURN(LARROW); }
<Code,GlaExt,UserPragma>"->" { RETURN(RARROW); }
<Code,GlaExt>"-" { RETURN(MINUS); }
+<Code,GlaExt>"+" { RETURN(PLUS); }
<Code,GlaExt,UserPragma>"=>" { RETURN(DARROW); }
<Code,GlaExt>"@" { RETURN(AT); }
%{
/* These SHOULDNAE work in "Code" (sigh) */
%}
-<Code,GlaExt,UserPragma>{Id}"#" {
- if (! nonstandardFlag) {
+<GlaExt,UserPragma>{Id}"#" {
+ if (! nonstandardFlag) {
char errbuf[ERR_BUF_SIZE];
sprintf(errbuf, "Non-standard identifier (trailing `#'): %s\n", yytext);
hsperror(errbuf);
hsnewid(yytext, yyleng);
RETURN(isconstr(yytext) ? CONSYM : VARSYM);
}
+<Code,GlaExt,UserPragma>{Mod}"."{Id}"#" {
+ BOOLEAN is_constr;
+ if (! nonstandardFlag) {
+ char errbuf[ERR_BUF_SIZE];
+ sprintf(errbuf, "Non-standard identifier (trailing `#'): %s\n", yytext);
+ hsperror(errbuf);
+ }
+ is_constr = hsnewqid(yytext, yyleng);
+ RETURN(is_constr ? QCONID : QVARID);
+ }
<Code,GlaExt,UserPragma>{Mod}"."{Id} {
BOOLEAN is_constr = hsnewqid(yytext, yyleng);
RETURN(is_constr ? QCONID : QVARID);
}
if (length > 1) {
- fprintf(stderr, "\"%s\", line %d, column %d: Unboxed character literal '",
+ fprintf(stderr, "%s:%d:%d: Unboxed character literal '",
input_filename, hsplineno, hspcolno + 1);
format_string(stderr, (unsigned char *) text, length);
fputs("' too long\n", stderr);
text = fetchtext(&length);
if (length > 1) {
- fprintf(stderr, "\"%s\", line %d, column %d: Character literal '",
+ fprintf(stderr, "%s:%d:%d: Character literal '",
input_filename, hsplineno, hspcolno + 1);
format_string(stderr, (unsigned char *) text, length);
fputs("' too long\n", stderr);
POP_STATE;
}
-%{
- /*
- * Simple comments and whitespace. Normally, we would just ignore these, but
- * in case we're processing a string escape, we need to note that we've seen
- * a gap.
- *
- * Note that we cater for a comment line that *doesn't* end in a newline.
- * This is incorrect, strictly speaking, but seems like the right thing
- * to do. Reported by Rajiv Mirani. (WDP 95/08)
- */
-%}
-
-<Code,GlaExt,StringEsc>"--".*{NL}?{WS}* |
-<Code,GlaExt,UserPragma,StringEsc>{WS}+ { noGap = FALSE; }
%{
/*
%}
<INITIAL,Code,GlaExt,UserPragma>(.|\n) {
- fprintf(stderr, "\"%s\", line %d, column %d: Illegal character: `",
+ fprintf(stderr, "%s:%d:%d: Illegal character: `",
input_filename, hsplineno, hspcolno + 1);
format_string(stderr, (unsigned char *) yytext, 1);
fputs("'\n", stderr);
hsperror("");
}
<Char>(.|\n) {
- fprintf(stderr, "\"%s\", line %d, column %d: Illegal character: `",
+ fprintf(stderr, "%s:%d:%d: Illegal character: `",
input_filename, hsplineno, hspcolno + 1);
format_string(stderr, (unsigned char *) yytext, 1);
fputs("' in a character literal\n", stderr);
hsperror("");
}
<CharEsc>(.|\n) {
- fprintf(stderr, "\"%s\", line %d, column %d: Illegal character escape: `\\",
+ fprintf(stderr, "%s:%d:%d: Illegal character escape: `\\",
input_filename, hsplineno, hspcolno + 1);
format_string(stderr, (unsigned char *) yytext, 1);
fputs("'\n", stderr);
<String>(.|\n) { if (nonstandardFlag) {
addtext(yytext, yyleng);
} else {
- fprintf(stderr, "\"%s\", line %d, column %d: Illegal character: `",
+ fprintf(stderr, "%s:%d:%d: Illegal character: `",
input_filename, hsplineno, hspcolno + 1);
format_string(stderr, (unsigned char *) yytext, 1);
fputs("' in a string literal\n", stderr);
}
<StringEsc>(.|\n) {
if (noGap) {
- fprintf(stderr, "\"%s\", line %d, column %d: Illegal string escape: `\\",
+ fprintf(stderr, "%s:%d:%d: Illegal string escape: `\\",
input_filename, hsplineno, hspcolno + 1);
format_string(stderr, (unsigned char *) yytext, 1);
fputs("'\n", stderr);
hsperror("");
} else {
- fprintf(stderr, "\"%s\", line %d, column %d: Illegal character: `",
+ fprintf(stderr, "%s:%d:%d: Illegal character: `",
input_filename, hsplineno, hspcolno + 1);
format_string(stderr, (unsigned char *) yytext, 1);
fputs("' in a string gap\n", stderr);