X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fparser%2Fhslexer.flex;h=f66949f0a24ad5800a21572060dc017e90edaf99;hb=c49d51f812da9b1c2ceca7e0dad8f2a3626041a9;hp=5cfe16d90c2d973234cdf5f12062e2ca7fcaec65;hpb=6c381e873e222417d9a67aeec77b9555eca7b7a8;p=ghc-hetmet.git diff --git a/ghc/compiler/parser/hslexer.flex b/ghc/compiler/parser/hslexer.flex index 5cfe16d..f66949f 100644 --- a/ghc/compiler/parser/hslexer.flex +++ b/ghc/compiler/parser/hslexer.flex @@ -50,13 +50,13 @@ static unsigned char CharTable[NCHARS] = { /* dle */ 0, 0, 0, 0, 0, 0, 0, 0, /* can */ 0, 0, 0, 0, 0, 0, 0, 0, /* sp */ _S, 0, 0, 0, 0, 0, 0, 0, -/* '(' */ _C, 0, 0, 0, 0, 0, 0, 0, /* ( */ +/* '(' */ _C, 0, 0, 0, 0, 0, 0, 0, /* '0' */ _D|_H|_O,_D|_H|_O,_D|_H|_O,_D|_H|_O,_D|_H|_O,_D|_H|_O,_D|_H|_O,_D|_H|_O, /* '8' */ _D|_H, _D|_H, _C, 0, 0, 0, 0, 0, /* '@' */ 0, _H|_C, _H|_C, _H|_C, _H|_C, _H|_C, _H|_C, _C, /* 'H' */ _C, _C, _C, _C, _C, _C, _C, _C, /* 'P' */ _C, _C, _C, _C, _C, _C, _C, _C, -/* 'X' */ _C, _C, _C, _C, 0, 0, 0, 0, /* [ */ +/* 'X' */ _C, _C, _C, _C, 0, 0, 0, 0, /* '`' */ 0, _H, _H, _H, _H, _H, _H, 0, /* 'h' */ 0, 0, 0, 0, 0, 0, 0, 0, /* 'p' */ 0, 0, 0, 0, 0, 0, 0, 0, @@ -144,17 +144,10 @@ static int hslineno_save = 0, /* Line Number */ hspcolno_save = 0; /* Left Indentation */ static short icontexts_save = 0; /* Indent Context Level */ -static BOOLEAN etags_save; /* saved: whether doing etags stuff or not */ -extern BOOLEAN etags; /* that which is saved */ +static BOOLEAN etags_save; /* saved: whether doing etags stuff or not */ +extern BOOLEAN etags; /* that which is saved */ -extern BOOLEAN nonstandardFlag; /* Glasgow extensions allowed */ - -static BOOLEAN in_interface = FALSE; /* TRUE if we are reading a .hi file */ - -extern BOOLEAN ignorePragmas; /* True when we should ignore pragmas */ -extern int minAcceptablePragmaVersion; /* see documentation in main.c */ -extern int maxAcceptablePragmaVersion; -extern int thisIfacePragmaVersion; +extern BOOLEAN nonstandardFlag; /* Glasgow extensions allowed */ static int hssttok = -1; /* Stacked Token: -1 -- no token; -ve -- ";" * inserted before token +ve -- "}" inserted before @@ -162,8 +155,6 @@ static int hssttok = -1; /* Stacked Token: -1 -- no token; -ve -- ";" short icontexts = 0; /* Which context we're in */ - - /* Table of indentations: right bit indicates whether to use indentation rules (1 = use rules; 0 = ignore) @@ -237,7 +228,7 @@ static int StateDepth = -1; list of start states. */ -%x Char CharEsc Code Comment GlaExt GhcPragma UserPragma String StringEsc +%x Char CharEsc Code Comment GlaExt UserPragma String StringEsc isoS [\xa1-\xbf\xd7\xf7] isoL [\xc0-\xd6\xd8-\xde] @@ -292,67 +283,11 @@ NL [\n\r] new_filename(tempf); hsplineno = hslineno; hscolno = 0; hspcolno = 0; } -"{-# GHC_PRAGMA INTERFACE VERSION "{D}+" #-}" { - sscanf(yytext+33,"%d ",&thisIfacePragmaVersion); - } -"{-# GHC_PRAGMA " { - if ( ignorePragmas || - thisIfacePragmaVersion < minAcceptablePragmaVersion || - thisIfacePragmaVersion > maxAcceptablePragmaVersion) { - nested_comments = 1; - PUSH_STATE(Comment); - } else { - PUSH_STATE(GhcPragma); - RETURN(GHC_PRAGMA); - } - } -"_N_" { RETURN(NO_PRAGMA); } -"_NI_" { RETURN(NOINFO_PRAGMA); } -"_DEFOREST_" { RETURN(DEFOREST_PRAGMA); } -"_SPECIALISE_" { RETURN(SPECIALISE_PRAGMA); } -"_A_" { RETURN(ARITY_PRAGMA); } -"_U_" { RETURN(UPDATE_PRAGMA); } -"_S_" { RETURN(STRICTNESS_PRAGMA); } -"_K_" { RETURN(KIND_PRAGMA); } -"_MF_" { RETURN(MAGIC_UNFOLDING_PRAGMA); } -"_F_" { RETURN(UNFOLDING_PRAGMA); } - -"_!_" { RETURN(COCON); } -"_#_" { RETURN(COPRIM); } -"_APP_" { RETURN(COAPP); } -"_TYAPP_" { RETURN(COTYAPP); } -"_ALG_" { RETURN(CO_ALG_ALTS); } -"_PRIM_" { RETURN(CO_PRIM_ALTS); } -"_NO_DEFLT_" { RETURN(CO_NO_DEFAULT); } -"_LETREC_" { RETURN(CO_LETREC); } - -"_PRELUDE_DICTS_CC_" { RETURN(CO_PRELUDE_DICTS_CC); } -"_ALL_DICTS_CC_" { RETURN(CO_ALL_DICTS_CC); } -"_USER_CC_" { RETURN(CO_USER_CC); } -"_AUTO_CC_" { RETURN(CO_AUTO_CC); } -"_DICT_CC_" { RETURN(CO_DICT_CC); } - -"_DUPD_CC_" { RETURN(CO_DUPD_CC); } -"_CAF_CC_" { RETURN(CO_CAF_CC); } - -"_SDSEL_" { RETURN(CO_SDSEL_ID); } -"_METH_" { RETURN(CO_METH_ID); } -"_DEFM_" { RETURN(CO_DEFM_ID); } -"_DFUN_" { RETURN(CO_DFUN_ID); } -"_CONSTM_" { RETURN(CO_CONSTM_ID); } -"_SPEC_" { RETURN(CO_SPEC_ID); } -"_WRKR_" { RETURN(CO_WRKR_ID); } -"_ORIG_" { RETURN(CO_ORIG_NM); /* fully-qualified original name*/ } - -"_ALWAYS_" { RETURN(UNFOLD_ALWAYS); } -"_IF_ARGS_" { RETURN(UNFOLD_IF_ARGS); } - -"_NOREP_I_" { RETURN(NOREP_INTEGER); } -"_NOREP_R_" { RETURN(NOREP_RATIONAL); } -"_NOREP_S_" { RETURN(NOREP_STRING); } - -" #-}" { POP_STATE; RETURN(END_PRAGMA); } +"{-#"{WS}*"INTERFACE" { + PUSH_STATE(UserPragma); + RETURN(INTERFACE_UPRAGMA); + } "{-#"{WS}*"SPECIALI"[SZ]E { PUSH_STATE(UserPragma); RETURN(SPECIALISE_UPRAGMA); @@ -386,7 +321,7 @@ NL [\n\r] */ %} -"case" { RETURN(CASE); } +"case" { RETURN(CASE); } "class" { RETURN(CLASS); } "data" { RETURN(DATA); } "default" { RETURN(DEFAULT); } @@ -395,15 +330,15 @@ NL [\n\r] "else" { RETURN(ELSE); } "if" { RETURN(IF); } "import" { RETURN(IMPORT); } -"in" { RETURN(IN); } +"in" { RETURN(IN); } "infix" { RETURN(INFIX); } "infixl" { RETURN(INFIXL); } "infixr" { RETURN(INFIXR); } "instance" { RETURN(INSTANCE); } -"let" { RETURN(LET); } +"let" { RETURN(LET); } "module" { RETURN(MODULE); } "newtype" { RETURN(NEWTYPE); } -"of" { RETURN(OF); } +"of" { RETURN(OF); } "then" { RETURN(THEN); } "type" { RETURN(TYPE); } "where" { RETURN(WHERE); } @@ -411,14 +346,12 @@ NL [\n\r] "as" { RETURN(AS); } "hiding" { RETURN(HIDING); } "qualified" { RETURN(QUALIFIED); } -"interface" { RETURN(INTERFACE); } -"_scc_" { RETURN(SCC); } -"_ccall_" { RETURN(CCALL); } -"_ccall_GC_" { RETURN(CCALL_GC); } -"_casm_" { RETURN(CASM); } -"_casm_GC_" { RETURN(CASM_GC); } -"_forall_" { RETURN(FORALL); } +"_scc_" { RETURN(SCC); } +"_ccall_" { RETURN(CCALL); } +"_ccall_GC_" { RETURN(CCALL_GC); } +"_casm_" { RETURN(CASM); } +"_casm_GC_" { RETURN(CASM_GC); } %{ /* @@ -426,32 +359,30 @@ NL [\n\r] */ %} -"(" { RETURN(OPAREN); } -")" { RETURN(CPAREN); } -"[" { RETURN(OBRACK); } -"]" { RETURN(CBRACK); } -"{" { RETURN(OCURLY); } -"}" { RETURN(CCURLY); } -"," { RETURN(COMMA); } -";" { RETURN(SEMI); } -"`" { RETURN(BQUOTE); } -"_" { RETURN(WILDCARD); } - -".." { RETURN(DOTDOT); } -"::" { RETURN(DCOLON); } -"=" { RETURN(EQUAL); } -"\\" { RETURN(LAMBDA); } -"|" { RETURN(VBAR); } -"<-" { RETURN(LARROW); } -"->" { RETURN(RARROW); } -"-" { RETURN(MINUS); } - -"=>" { RETURN(DARROW); } -"@" { RETURN(AT); } -"!" { RETURN(BANG); } -"~" { RETURN(LAZY); } - -"_/\\_" { RETURN(TYLAMBDA); } +"(" { RETURN(OPAREN); } +")" { RETURN(CPAREN); } +"[" { RETURN(OBRACK); } +"]" { RETURN(CBRACK); } +"{" { RETURN(OCURLY); } +"}" { RETURN(CCURLY); } +"," { RETURN(COMMA); } +";" { RETURN(SEMI); } +"`" { RETURN(BQUOTE); } +"_" { RETURN(WILDCARD); } + +".." { RETURN(DOTDOT); } +"::" { RETURN(DCOLON); } +"=" { RETURN(EQUAL); } +"\\" { RETURN(LAMBDA); } +"|" { RETURN(VBAR); } +"<-" { RETURN(LARROW); } +"->" { RETURN(RARROW); } +"-" { RETURN(MINUS); } + +"=>" { RETURN(DARROW); } +"@" { RETURN(AT); } +"!" { RETURN(BANG); } +"~" { RETURN(LAZY); } %{ /* @@ -477,11 +408,11 @@ NL [\n\r] yylval.uid = xstrndup(yytext, yyleng); RETURN(INTEGER); } -("-")?{N}"#" { +("-")?{N}"#" { yylval.uid = xstrndup(yytext, yyleng - 1); RETURN(INTPRIM); } -{N} { +{N} { yylval.uid = xstrndup(yytext, yyleng); RETURN(INTEGER); } @@ -492,11 +423,11 @@ NL [\n\r] */ %} -("-")?{F}"##" { +("-")?{F}"##" { yylval.uid = xstrndup(yytext, yyleng - 2); RETURN(DOUBLEPRIM); } -("-")?{F}"#" { +("-")?{F}"#" { yylval.uid = xstrndup(yytext, yyleng - 1); RETURN(FLOATPRIM); } @@ -511,7 +442,7 @@ NL [\n\r] */ %} -"``"[^']+"''" { +"``"[^']+"''" { hsnewid(yytext + 2, yyleng - 4); RETURN(CLITLIT); } @@ -523,15 +454,12 @@ NL [\n\r] */ %} -"_NIL_" { hsnewid(yytext, yyleng); RETURN(CONID); } -"_TUP_"{D}+ { hsnewid(yytext, yyleng); RETURN(CONID); } -[a-z]{i}*"$"[a-z]{i}* { hsnewid(yytext, yyleng); RETURN(TYVAR_TEMPLATE_ID); } %{ /* These SHOULDNAE work in "Code" (sigh) */ %} -{Id}"#" { - if (! (nonstandardFlag || in_interface)) { +{Id}"#" { + if (! nonstandardFlag) { char errbuf[ERR_BUF_SIZE]; sprintf(errbuf, "Non-standard identifier (trailing `#'): %s\n", yytext); hsperror(errbuf); @@ -539,8 +467,8 @@ NL [\n\r] hsnewid(yytext, yyleng); RETURN(_isconstr(yytext) ? CONID : VARID); } -_+{Id} { - if (! (nonstandardFlag || in_interface)) { +_+{Id} { + if (! nonstandardFlag) { char errbuf[ERR_BUF_SIZE]; sprintf(errbuf, "Non-standard identifier (leading underscore): %s\n", yytext); hsperror(errbuf); @@ -549,19 +477,19 @@ NL [\n\r] RETURN(isconstr(yytext) ? CONID : VARID); /* NB: ^^^^^^^^ : not the macro! */ } -{Id} { +{Id} { hsnewid(yytext, yyleng); RETURN(_isconstr(yytext) ? CONID : VARID); } -{SId} { +{SId} { hsnewid(yytext, yyleng); RETURN(_isconstr(yytext) ? CONSYM : VARSYM); } -{Mod}"."{Id} { +{Mod}"."{Id} { BOOLEAN isconstr = hsnewqid(yytext, yyleng); RETURN(isconstr ? QCONID : QVARID); } -{Mod}"."{SId} { +{Mod}"."{SId} { BOOLEAN isconstr = hsnewqid(yytext, yyleng); RETURN(isconstr ? QCONSYM : QVARSYM); } @@ -576,7 +504,7 @@ NL [\n\r] */ %} -"`"{Id}"#`" { +"`"{Id}"#`" { hsnewid(yytext + 1, yyleng - 2); RETURN(_isconstr(yytext+1) ? CONSYM : VARSYM); } @@ -595,7 +523,7 @@ NL [\n\r] */ %} -'({CHAR}|"\"")"'#" { +'({CHAR}|"\"")"'#" { yylval.uhstring = installHstring(1, yytext+1); RETURN(CHARPRIM); } @@ -607,7 +535,7 @@ NL [\n\r] sprintf(errbuf, "'' is not a valid character (or string) literal\n"); hsperror(errbuf); } -'({CHAR}|"\"")* { +'({CHAR}|"\"")* { hsmlcolno = hspcolno; cleartext(); addtext(yytext+1, yyleng-1); @@ -620,7 +548,7 @@ NL [\n\r] addtext(yytext, yyleng - 2); text = fetchtext(&length); - if (! (nonstandardFlag || in_interface)) { + if (! nonstandardFlag) { char errbuf[ERR_BUF_SIZE]; sprintf(errbuf, "`Char-hash' literals are non-standard: %s\n", text); hsperror(errbuf); @@ -675,16 +603,16 @@ NL [\n\r] */ %} -"\""({CHAR}|"'")*"\""# { +"\""({CHAR}|"'")*"\""# { yylval.uhstring = installHstring(yyleng-3, yytext+1); /* the -3 accounts for the " on front, "# on the end */ RETURN(STRINGPRIM); } -"\""({CHAR}|"'")*"\"" { +"\""({CHAR}|"'")*"\"" { yylval.uhstring = installHstring(yyleng-2, yytext+1); RETURN(STRING); } -"\""({CHAR}|"'")* { +"\""({CHAR}|"'")* { hsmlcolno = hspcolno; cleartext(); addtext(yytext+1, yyleng-1); @@ -697,7 +625,7 @@ NL [\n\r] addtext(yytext, yyleng-2); text = fetchtext(&length); - if (! (nonstandardFlag || in_interface)) { + if (! nonstandardFlag) { char errbuf[ERR_BUF_SIZE]; sprintf(errbuf, "`String-hash' literals are non-standard: %s\n", text); hsperror(errbuf); @@ -838,7 +766,7 @@ NL [\n\r] %} "--".*{NL}?{WS}* | -{WS}+ { noGap = FALSE; } +{WS}+ { noGap = FALSE; } %{ /* @@ -848,7 +776,7 @@ NL [\n\r] */ %} -"{-" { +"{-" { noGap = FALSE; nested_comments = 1; PUSH_STATE(Comment); } @@ -867,7 +795,7 @@ NL [\n\r] */ %} -(.|\n) { +(.|\n) { fprintf(stderr, "\"%s\", line %d, column %d: Illegal character: `", input_filename, hsplineno, hspcolno + 1); format_string(stderr, (unsigned char *) yytext, 1); @@ -939,10 +867,6 @@ NL [\n\r] hsplineno = hslineno; hspcolno = hscolno; hsperror("unterminated string literal"); } -<> { - hsplineno = hslineno; hspcolno = hscolno; - hsperror("unterminated interface pragma"); - } <> { hsplineno = hslineno; hspcolno = hscolno; hsperror("unterminated user-specified pragma"); @@ -1164,14 +1088,16 @@ yylex() hscolno = hscolno_save; hspcolno = hspcolno_save; etags = etags_save; - in_interface = FALSE; icontexts = icontexts_save - 1; icontexts_save = 0; #ifdef HSP_DEBUG fprintf(stderr, "finished reading interface (%d:%d:%d)\n", hscolno, hspcolno, INDENTPT); #endif eof = FALSE; - RETURN(LEOF); + + /* RETURN(LEOF); */ + hsperror("No longer using yacc to parse interface files"); + } else { yyterminate(); } @@ -1182,7 +1108,7 @@ yylex() /********************************************************************** * * * * -* Input Processing for Interfaces * +* Input Processing for Interfaces -- Not currently used !!! * * * * * **********************************************************************/ @@ -1212,7 +1138,6 @@ setyyin(char *file) hscolno_save = hscolno; hspcolno_save = hspcolno; hscolno = hspcolno = 0; - in_interface = TRUE; etags_save = etags; /* do not do "etags" stuff in interfaces */ etags = 0; /* We remember whether we are doing it in the module, so we can restore it later [WDP 94/09] */