Skip to content
Snippets Groups Projects
Commit 5aeafc40 authored by sof's avatar sof
Browse files

[project @ 1999-01-15 18:32:22 by sof]

Be a little bit more user-friendly when encountering record puns,
which is no longer supported by Haskell. Instead of a Plain Old Parse
Error, print out

  foo.hs:11:11: Haskell 98 does not support 'punning' on records ....

Hopefully that should give the user a big enough hint at what's
going wrong..
parent 03a86b16
No related branches found
No related tags found
No related merge requests found
...@@ -61,6 +61,11 @@ extern int modulelineno; ...@@ -61,6 +61,11 @@ extern int modulelineno;
extern int startlineno; extern int startlineno;
extern int endlineno; extern int endlineno;
/* Local helper functions */
static void checkinpat PROTO((void));
static void punningNowIllegal PROTO((void));
/********************************************************************** /**********************************************************************
* * * *
* * * *
...@@ -1090,8 +1095,9 @@ rbinds1 : rbind { $$ = lsing($1); } ...@@ -1090,8 +1095,9 @@ rbinds1 : rbind { $$ = lsing($1); }
| rbinds1 COMMA rbind { $$ = lapp($1,$3); } | rbinds1 COMMA rbind { $$ = lapp($1,$3); }
; ;
rbind : qvar EQUAL exp { $$ = mkrbind($1,mkjust($3)); } rbind : qvar { punningNowIllegal(); }
; | qvar EQUAL exp { $$ = mkrbind($1,mkjust($3)); }
;
texps : exp { $$ = lsing($1); } texps : exp { $$ = lsing($1); }
| exp COMMA texps { $$ = mklcons($1, $3) } | exp COMMA texps { $$ = mklcons($1, $3) }
...@@ -1298,7 +1304,8 @@ rpats1 : rpat { $$ = lsing($1); } ...@@ -1298,7 +1304,8 @@ rpats1 : rpat { $$ = lsing($1); }
| rpats1 COMMA rpat { $$ = lapp($1,$3); } | rpats1 COMMA rpat { $$ = lapp($1,$3); }
; ;
rpat : qvar EQUAL pat { $$ = mkrbind($1,mkjust($3)); } rpat : qvar { punningNowIllegal(); }
| qvar EQUAL pat { $$ = mkrbind($1,mkjust($3)); }
; ;
...@@ -1622,13 +1629,18 @@ vccurly1: ...@@ -1622,13 +1629,18 @@ vccurly1:
**********************************************************************/ **********************************************************************/
void static void checkinpat()
checkinpat()
{ {
if(pat_check) if(pat_check)
hsperror("pattern syntax used in expression"); hsperror("pattern syntax used in expression");
} }
static void punningNowIllegal()
{
hsperror("Haskell 98 does not support 'punning' on records");
}
/* The parser calls "hsperror" when it sees a /* The parser calls "hsperror" when it sees a
`report this and die' error. It sets the stage `report this and die' error. It sets the stage
and calls "yyerror". and calls "yyerror".
......
...@@ -92,7 +92,6 @@ void hsindentoff PROTO((void)); ...@@ -92,7 +92,6 @@ void hsindentoff PROTO((void));
int checkfixity PROTO((char *)); int checkfixity PROTO((char *));
void checksamefn PROTO((tree)); void checksamefn PROTO((tree));
void checkinpat PROTO((void));
void expORpat PROTO((int,tree)); void expORpat PROTO((int,tree));
/* the "int" arg says what we want; it is one of: */ /* the "int" arg says what we want; it is one of: */
......
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