From edfe93593306cebc7981f5df2d634f9547849587 Mon Sep 17 00:00:00 2001 From: sof Date: Wed, 25 Feb 1998 19:17:21 +0000 Subject: [PATCH] [project @ 1998-02-25 19:17:19 by sof] Magic constant removal (id.h now has #defines for the `special-syntax' identifiers.) --- ghc/compiler/parser/hsparser.y | 18 +++++++++--------- ghc/compiler/parser/id.c | 17 +++++++++-------- ghc/compiler/parser/id.h | 11 +++++++++++ 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/ghc/compiler/parser/hsparser.y b/ghc/compiler/parser/hsparser.y index 970412a..5c3910a 100644 --- a/ghc/compiler/parser/hsparser.y +++ b/ghc/compiler/parser/hsparser.y @@ -408,8 +408,8 @@ import : var { $$ = mkentid(mknoqual($1)); } ; itycon : tycon { $$ = mknoqual($1); } - | OBRACK CBRACK { $$ = creategid(-1); } - | OPAREN CPAREN { $$ = creategid(0); } + | OBRACK CBRACK { $$ = creategid(NILGID); } + | OPAREN CPAREN { $$ = creategid(UNITGID); } | OPAREN commas CPAREN { $$ = creategid($2); } ; @@ -677,9 +677,9 @@ atype : gtycon { $$ = mktname($1); } ; gtycon : qtycon - | OPAREN RARROW CPAREN { $$ = creategid(-2); } - | OBRACK CBRACK { $$ = creategid(-1); } - | OPAREN CPAREN { $$ = creategid(0); } + | OPAREN RARROW CPAREN { $$ = creategid(ARROWGID); } + | OBRACK CBRACK { $$ = creategid(NILGID); } + | OPAREN CPAREN { $$ = creategid(UNITGID); } | OPAREN commas CPAREN { $$ = creategid($2); } ; @@ -1314,14 +1314,14 @@ apatck : qvark { $$ = mkident($1); } gcon : qcon - | OBRACK CBRACK { $$ = creategid(-1); } - | OPAREN CPAREN { $$ = creategid(0); } + | OBRACK CBRACK { $$ = creategid(NILGID); } + | OPAREN CPAREN { $$ = creategid(UNITGID); } | OPAREN commas CPAREN { $$ = creategid($2); } ; gconk : qconk - | obrackkey CBRACK { $$ = creategid(-1); } - | oparenkey CPAREN { $$ = creategid(0); } + | obrackkey CBRACK { $$ = creategid(NILGID); } + | oparenkey CPAREN { $$ = creategid(UNITGID); } | oparenkey commas CPAREN { $$ = creategid($2); } ; diff --git a/ghc/compiler/parser/id.c b/ghc/compiler/parser/id.c index 04228be..053dc44 100644 --- a/ghc/compiler/parser/id.c +++ b/ghc/compiler/parser/id.c @@ -281,11 +281,12 @@ qid_to_pmod(q) look at qid.ugn) with a key (number) and a string. Here's the deal - key - -2 function arrow -> - -1 list type constructor [], or the empty list [] - 0 unit type constructor (), or the unity value () - n n-tuple type constructor (,,,) + key + + ARROWCON function arrow -> + LISTCON list type constructor [], or the empty list [] + UNITCON unit type constructor (), or the unity value () + n n-tuple type constructor (,,,) */ qid @@ -293,11 +294,11 @@ creategid(i) long i; { switch(i) { - case -2: + case ARROWGID: return(mkgid(i,install_literal("->"))); - case -1: + case NILGID: return(mkgid(i,install_literal("[]"))); - case 0: + case UNITGID: return(mkgid(i,install_literal("()"))); default: { diff --git a/ghc/compiler/parser/id.h b/ghc/compiler/parser/id.h index b0fd009..841fdbf 100644 --- a/ghc/compiler/parser/id.h +++ b/ghc/compiler/parser/id.h @@ -12,4 +12,15 @@ typedef Hstring *hstring; long get_hstring_len PROTO((hstring)); char *get_hstring_bytes PROTO((hstring)); +id installid PROTO((char *)); /* Create a new identifier */ +hstring installHstring PROTO((int, char *)); /* Create a new literal string */ + +/* defines for special-syntax ids, see comment next + to creategid() +*/ +#define ARROWGID (-2) +#define NILGID (-1) +#define UNITGID (0) + + #endif -- 1.7.10.4