projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 1996-03-22 09:24:22 by partain]
[ghc-hetmet.git]
/
ghc
/
compiler
/
yaccParser
/
hslexer.flex
diff --git
a/ghc/compiler/yaccParser/hslexer.flex
b/ghc/compiler/yaccParser/hslexer.flex
index
7d0ce0f
..
3c2ab36
100644
(file)
--- a/
ghc/compiler/yaccParser/hslexer.flex
+++ b/
ghc/compiler/yaccParser/hslexer.flex
@@
-64,7
+64,7
@@
#define _isconstr(s) (CharTable[*s]&(_C))
BOOLEAN isconstr PROTO((char *)); /* fwd decl */
#define _isconstr(s) (CharTable[*s]&(_C))
BOOLEAN isconstr PROTO((char *)); /* fwd decl */
-unsigned char CharTable[NCHARS] = {
+static unsigned char CharTable[NCHARS] = {
/* nul */ 0, 0, 0, 0, 0, 0, 0, 0,
/* bs */ 0, _S, _S, _S, _S, 0, 0, 0,
/* dle */ 0, 0, 0, 0, 0, 0, 0, 0,
/* nul */ 0, 0, 0, 0, 0, 0, 0, 0,
/* bs */ 0, _S, _S, _S, _S, 0, 0, 0,
/* dle */ 0, 0, 0, 0, 0, 0, 0, 0,
@@
-115,12
+115,12
@@
char *input_filename = NULL; /* Always points to a dynamically allocated string
* have been renamed as hsXXXXX rather than yyXXXXX. --JSM
*/
* have been renamed as hsXXXXX rather than yyXXXXX. --JSM
*/
-int hslineno = 0; /* Line number at end of token */
+static int hslineno = 0; /* Line number at end of token */
int hsplineno = 0; /* Line number at end of previous token */
int hsplineno = 0; /* Line number at end of previous token */
-int hscolno = 0; /* Column number at end of token */
+static int hscolno = 0; /* Column number at end of token */
int hspcolno = 0; /* Column number at end of previous token */
int hspcolno = 0; /* Column number at end of previous token */
-int hsmlcolno = 0; /* Column number for multiple-rule lexemes */
+static int hsmlcolno = 0; /* Column number for multiple-rule lexemes */
int startlineno = 0; /* The line number where something starts */
int endlineno = 0; /* The line number where something ends */
int startlineno = 0; /* The line number where something starts */
int endlineno = 0; /* The line number where something ends */
@@
-142,12
+142,15
@@
static int nested_comments; /* For counting comment nesting depth */
/* Essential forward declarations */
/* Essential forward declarations */
-static VOID hsnewid PROTO((char *, int));
-static VOID layout_input PROTO((char *, int));
-static VOID cleartext (NO_ARGS);
-static VOID addtext PROTO((char *, unsigned));
-static VOID addchar PROTO((char));
+static void hsnewid PROTO((char *, int));
+static void layout_input PROTO((char *, int));
+static void cleartext (NO_ARGS);
+static void addtext PROTO((char *, unsigned));
+static void addchar PROTO((char));
static char *fetchtext PROTO((unsigned *));
static char *fetchtext PROTO((unsigned *));
+static void new_filename PROTO((char *));
+static int Return PROTO((int));
+static void hsentercontext PROTO((int));
/* Special file handling for IMPORTS */
/* Note: imports only ever go *one deep* (hence no need for a stack) WDP 94/09 */
/* Special file handling for IMPORTS */
/* Note: imports only ever go *one deep* (hence no need for a stack) WDP 94/09 */
@@
-384,6
+387,14
@@
NL [\n\r]
PUSH_STATE(UserPragma);
RETURN(ABSTRACT_UPRAGMA);
}
PUSH_STATE(UserPragma);
RETURN(ABSTRACT_UPRAGMA);
}
+<Code,GlaExt>"{-#"{WS}*[A-Z_]+ {
+ fprintf(stderr, "Warning: \"%s\", line %d: Unrecognised pragma '",
+ input_filename, hsplineno);
+ format_string(stderr, (unsigned char *) yytext, yyleng);
+ fputs("'\n", stderr);
+ nested_comments = 1;
+ PUSH_STATE(Comment);
+ }
<UserPragma>"#-}" { POP_STATE; RETURN(END_UPRAGMA); }
%{
<UserPragma>"#-}" { POP_STATE; RETURN(END_UPRAGMA); }
%{
@@
-527,13
+538,18
@@
NL [\n\r]
<GhcPragma>"_TUP_"{D}+ { hsnewid(yytext, yyleng); RETURN(CONID); }
<GhcPragma>[a-z]{i}*"$"[a-z]{i}* { hsnewid(yytext, yyleng); RETURN(TYVAR_TEMPLATE_ID); }
<GhcPragma>"_TUP_"{D}+ { hsnewid(yytext, yyleng); RETURN(CONID); }
<GhcPragma>[a-z]{i}*"$"[a-z]{i}* { hsnewid(yytext, yyleng); RETURN(TYVAR_TEMPLATE_ID); }
-<GlaExt,GhcPragma,UserPragma>{Id}"#" {
+%{
+/* These SHOULDNAE work in "Code" (sigh) */
+%}
+<Code,GlaExt,GhcPragma,UserPragma>{Id}"#" {
+ if (! (nonstandardFlag || in_interface)) {
+ char errbuf[ERR_BUF_SIZE];
+ sprintf(errbuf, "Non-standard identifier (trailing `#'): %s\n", yytext);
+ hsperror(errbuf);
+ }
hsnewid(yytext, yyleng);
RETURN(_isconstr(yytext) ? CONID : VARID);
}
hsnewid(yytext, yyleng);
RETURN(_isconstr(yytext) ? CONID : VARID);
}
-%{
-/* This SHOULDNAE work in "Code" (sigh) */
-%}
<Code,GlaExt,GhcPragma,UserPragma>_+{Id} {
if (! (nonstandardFlag || in_interface)) {
char errbuf[ERR_BUF_SIZE];
<Code,GlaExt,GhcPragma,UserPragma>_+{Id} {
if (! (nonstandardFlag || in_interface)) {
char errbuf[ERR_BUF_SIZE];
@@
-817,10
+833,14
@@
NL [\n\r]
* 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.
* 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,StringEsc>"--".*{NL}?{WS}* |
<Code,GlaExt,GhcPragma,UserPragma,StringEsc>{WS}+ { noGap = FALSE; }
%{
<Code,GlaExt,GhcPragma,UserPragma,StringEsc>{WS}+ { noGap = FALSE; }
%{
@@
-947,11
+967,11
@@
NL [\n\r]
This allows unnamed sources to be piped into the parser.
*/
This allows unnamed sources to be piped into the parser.
*/
+extern BOOLEAN acceptPrim;
+
void
void
-yyinit()
+yyinit(void)
{
{
- extern BOOLEAN acceptPrim;
-
input_filename = xstrdup("<stdin>");
/* We must initialize the input buffer _now_, because we call
input_filename = xstrdup("<stdin>");
/* We must initialize the input buffer _now_, because we call
@@
-964,9
+984,8
@@
yyinit()
PUSH_STATE(Code);
}
PUSH_STATE(Code);
}
-void
-new_filename(f) /* This looks pretty dodgy to me (WDP) */
- char *f;
+static void
+new_filename(char *f) /* This looks pretty dodgy to me (WDP) */
{
if (input_filename != NULL)
free(input_filename);
{
if (input_filename != NULL)
free(input_filename);
@@
-986,8
+1005,8
@@
new_filename(f) /* This looks pretty dodgy to me (WDP) */
forcing insertion of ; or } as appropriate
*/
forcing insertion of ; or } as appropriate
*/
-BOOLEAN
-hsshouldindent()
+static BOOLEAN
+hsshouldindent(void)
{
return (!forgetindent && INDENTON);
}
{
return (!forgetindent && INDENTON);
}
@@
-995,7
+1014,7
@@
hsshouldindent()
/* Enter new context and set new indentation level */
void
/* Enter new context and set new indentation level */
void
-hssetindent()
+hssetindent(void)
{
#ifdef HSP_DEBUG
fprintf(stderr, "hssetindent:hscolno=%d,hspcolno=%d,INDENTPT[%d]=%d\n", hscolno, hspcolno, icontexts, INDENTPT);
{
#ifdef HSP_DEBUG
fprintf(stderr, "hssetindent:hscolno=%d,hspcolno=%d,INDENTPT[%d]=%d\n", hscolno, hspcolno, icontexts, INDENTPT);
@@
-1024,7
+1043,7
@@
hssetindent()
/* Enter a new context without changing the indentation level */
void
/* Enter a new context without changing the indentation level */
void
-hsincindent()
+hsincindent(void)
{
#ifdef HSP_DEBUG
fprintf(stderr, "hsincindent:hscolno=%d,hspcolno=%d,INDENTPT[%d]=%d\n", hscolno, hspcolno, icontexts, INDENTPT);
{
#ifdef HSP_DEBUG
fprintf(stderr, "hsincindent:hscolno=%d,hspcolno=%d,INDENTPT[%d]=%d\n", hscolno, hspcolno, icontexts, INDENTPT);
@@
-1035,16
+1054,15
@@
hsincindent()
/* Turn off indentation processing, usually because an explicit "{" has been seen */
void
/* Turn off indentation processing, usually because an explicit "{" has been seen */
void
-hsindentoff()
+hsindentoff(void)
{
forgetindent = TRUE;
}
/* Enter a new layout context. */
{
forgetindent = TRUE;
}
/* Enter a new layout context. */
-void
-hsentercontext(indent)
- int indent;
+static void
+hsentercontext(int indent)
{
/* Enter new context and set indentation as specified */
if (++icontexts >= MAX_CONTEXTS) {
{
/* Enter new context and set indentation as specified */
if (++icontexts >= MAX_CONTEXTS) {
@@
-1063,7
+1081,7
@@
hsentercontext(indent)
/* Exit a layout context */
void
/* Exit a layout context */
void
-hsendindent()
+hsendindent(void)
{
--icontexts;
#ifdef HSP_DEBUG
{
--icontexts;
#ifdef HSP_DEBUG
@@
-1075,9
+1093,8
@@
hsendindent()
* Return checks the indentation level and returns ;, } or the specified token.
*/
* Return checks the indentation level and returns ;, } or the specified token.
*/
-int
-Return(tok)
- int tok;
+static int
+Return(int tok)
{
#ifdef HSP_DEBUG
extern int yyleng;
{
#ifdef HSP_DEBUG
extern int yyleng;
@@
-1174,12
+1191,11
@@
yylex()
**********************************************************************/
/* setyyin(file) open file as new lex input buffer */
**********************************************************************/
/* setyyin(file) open file as new lex input buffer */
+extern FILE *yyin;
+
void
void
-setyyin(file)
- char *file;
+setyyin(char *file)
{
{
- extern FILE *yyin;
-
hsbuf_save = YY_CURRENT_BUFFER;
if ((yyin = fopen(file, "r")) == NULL) {
char errbuf[ERR_BUF_SIZE];
hsbuf_save = YY_CURRENT_BUFFER;
if ((yyin = fopen(file, "r")) == NULL) {
char errbuf[ERR_BUF_SIZE];
@@
-1210,10
+1226,8
@@
setyyin(file)
#endif
}
#endif
}
-static VOID
-layout_input(text, len)
-char *text;
-int len;
+static void
+layout_input(char *text, int len)
{
#ifdef HSP_DEBUG
fprintf(stderr, "Scanning \"%s\"\n", text);
{
#ifdef HSP_DEBUG
fprintf(stderr, "Scanning \"%s\"\n", text);
@@
-1243,7
+1257,7
@@
int len;
}
void
}
void
-setstartlineno()
+setstartlineno(void)
{
startlineno = hsplineno;
#if 1/*etags*/
{
startlineno = hsplineno;
#if 1/*etags*/
@@
-1269,8
+1283,8
@@
static struct {
char *text;
} textcache = { 0, 0, NULL };
char *text;
} textcache = { 0, 0, NULL };
-static VOID
-cleartext()
+static void
+cleartext(void)
{
/* fprintf(stderr, "cleartext\n"); */
textcache.next = 0;
{
/* fprintf(stderr, "cleartext\n"); */
textcache.next = 0;
@@
-1280,10
+1294,8
@@
cleartext()
}
}
}
}
-static VOID
-addtext(text, length)
-char *text;
-unsigned length;
+static void
+addtext(char *text, unsigned length)
{
/* fprintf(stderr, "addtext: %d %s\n", length, text); */
{
/* fprintf(stderr, "addtext: %d %s\n", length, text); */
@@
-1298,13
+1310,8
@@
unsigned length;
textcache.next += length;
}
textcache.next += length;
}
-static VOID
-#ifdef __STDC__
+static void
addchar(char c)
addchar(char c)
-#else
-addchar(c)
- char c;
-#endif
{
/* fprintf(stderr, "addchar: %c\n", c); */
{
/* fprintf(stderr, "addchar: %c\n", c); */
@@
-1316,8
+1323,7
@@
addchar(c)
}
static char *
}
static char *
-fetchtext(length)
-unsigned *length;
+fetchtext(unsigned *length)
{
/* fprintf(stderr, "fetchtext: %d\n", textcache.next); */
{
/* fprintf(stderr, "fetchtext: %d\n", textcache.next); */
@@
-1338,10
+1344,8
@@
unsigned *length;
hsnewid Enters an id of length n into the symbol table.
*/
hsnewid Enters an id of length n into the symbol table.
*/
-static VOID
-hsnewid(name, length)
-char *name;
-int length;
+static void
+hsnewid(char *name, int length)
{
char save = name[length];
{
char save = name[length];
@@
-1351,8
+1355,7
@@
int length;
}
BOOLEAN
}
BOOLEAN
-isconstr(s) /* walks past leading underscores before using the macro */
- char *s;
+isconstr(char *s) /* walks past leading underscores before using the macro */
{
char *temp = s;
{
char *temp = s;