Starting ANSI C frontend
This commit is contained in:
parent
452127650a
commit
03763cbbf0
@ -1,5 +1,5 @@
|
|||||||
!File: lint.h
|
!File: lint.h
|
||||||
/*#define LINT 1 /* if defined, 'lint' is produced */
|
/*#define LINT 1*/ /* if defined, 'lint' is produced */
|
||||||
|
|
||||||
|
|
||||||
!File: pathlength.h
|
!File: pathlength.h
|
||||||
@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
|
|
||||||
!File: botch_free.h
|
!File: botch_free.h
|
||||||
/*#define BOTCH_FREE 1 /* when defined, botch freed memory, as a check */
|
/*#define BOTCH_FREE 1*/ /* when defined, botch freed memory, as a check */
|
||||||
|
|
||||||
|
|
||||||
!File: dataflow.h
|
!File: dataflow.h
|
||||||
@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
|
|
||||||
!File: debug.h
|
!File: debug.h
|
||||||
/*#define DEBUG 1 /* perform various self-tests */
|
/*#define DEBUG 1*/ /* perform various self-tests */
|
||||||
#define NDEBUG 1 /* disable assertions */
|
#define NDEBUG 1 /* disable assertions */
|
||||||
|
|
||||||
|
|
||||||
@ -112,17 +112,17 @@
|
|||||||
|
|
||||||
|
|
||||||
!File: nopp.h
|
!File: nopp.h
|
||||||
/*#define NOPP 1 /* if NOT defined, use built-int preprocessor */
|
/*#define NOPP 1*/ /* if NOT defined, use built-int preprocessor */
|
||||||
|
|
||||||
|
|
||||||
!File: nobitfield.h
|
!File: nobitfield.h
|
||||||
/*#define NOBITFIELD 1 /* if NOT defined, implement bitfields */
|
/*#define NOBITFIELD 1*/ /* if NOT defined, implement bitfields */
|
||||||
|
|
||||||
|
|
||||||
!File: spec_arith.h
|
!File: spec_arith.h
|
||||||
/* describes internal compiler arithmetics */
|
/* describes internal compiler arithmetics */
|
||||||
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
||||||
/*#define UNSIGNED_ARITH unsigned arith /* if it is supported */
|
/*#define UNSIGNED_ARITH unsigned arith*/ /* if it is supported */
|
||||||
|
|
||||||
|
|
||||||
!File: static.h
|
!File: static.h
|
||||||
@ -130,11 +130,11 @@
|
|||||||
|
|
||||||
|
|
||||||
!File: nocross.h
|
!File: nocross.h
|
||||||
/*#define NOCROSS 1 /* if NOT defined, cross compiler */
|
/*#define NOCROSS 1*/ /* if NOT defined, cross compiler */
|
||||||
|
|
||||||
|
|
||||||
!File: regcount.h
|
!File: regcount.h
|
||||||
/*#define REGCOUNT 1 /* count occurrences for register messages */
|
/*#define REGCOUNT 1*/ /* count occurrences for register messages */
|
||||||
|
|
||||||
|
|
||||||
!File: dbsymtab.h
|
!File: dbsymtab.h
|
||||||
|
|||||||
@ -62,7 +62,7 @@ static LexSP = 0;
|
|||||||
E.g. at the invocation of a sub-parser that uses LLlex(), the
|
E.g. at the invocation of a sub-parser that uses LLlex(), the
|
||||||
state of the current parser should be saved.
|
state of the current parser should be saved.
|
||||||
*/
|
*/
|
||||||
PushLex()
|
void PushLex()
|
||||||
{
|
{
|
||||||
ASSERT(LexSP < MAX_LL_DEPTH);
|
ASSERT(LexSP < MAX_LL_DEPTH);
|
||||||
ASSERT(ASIDE == 0); /* ASIDE = 0; */
|
ASSERT(ASIDE == 0); /* ASIDE = 0; */
|
||||||
@ -70,15 +70,14 @@ PushLex()
|
|||||||
LexStack[LexSP++] = dot;
|
LexStack[LexSP++] = dot;
|
||||||
}
|
}
|
||||||
|
|
||||||
PopLex()
|
void PopLex()
|
||||||
{
|
{
|
||||||
ASSERT(LexSP > 0);
|
ASSERT(LexSP > 0);
|
||||||
dot = LexStack[--LexSP];
|
dot = LexStack[--LexSP];
|
||||||
}
|
}
|
||||||
#endif /* NOPP */
|
#endif /* NOPP */
|
||||||
|
|
||||||
int
|
int LLlex()
|
||||||
LLlex()
|
|
||||||
{
|
{
|
||||||
/* LLlex() plays the role of Lexical Analyzer for the C parser.
|
/* LLlex() plays the role of Lexical Analyzer for the C parser.
|
||||||
The look-ahead and putting aside of tokens are taken into
|
The look-ahead and putting aside of tokens are taken into
|
||||||
@ -108,12 +107,13 @@ LLlex()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *string_token();
|
char *string_token(char *nm, int stop_char, int *plen);
|
||||||
arith char_constant();
|
arith char_constant(char *nm);
|
||||||
|
void skipcomment();
|
||||||
|
void strint2tok(char intbuf[], struct token *ptok);
|
||||||
|
void strflt2tok(char fltbuf[], struct token *ptok);
|
||||||
|
|
||||||
int
|
int GetToken(struct token *ptok)
|
||||||
GetToken(ptok)
|
|
||||||
register struct token *ptok;
|
|
||||||
{
|
{
|
||||||
/* GetToken() is the actual token recognizer. It calls the
|
/* GetToken() is the actual token recognizer. It calls the
|
||||||
control line interpreter if it encounters a "\n{w}*#"
|
control line interpreter if it encounters a "\n{w}*#"
|
||||||
@ -121,7 +121,7 @@ GetToken(ptok)
|
|||||||
needed.
|
needed.
|
||||||
*/
|
*/
|
||||||
char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1];
|
char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1];
|
||||||
register int ch, nch;
|
int ch, nch;
|
||||||
|
|
||||||
token_nmb++;
|
token_nmb++;
|
||||||
|
|
||||||
@ -227,8 +227,7 @@ garbage:
|
|||||||
case '<':
|
case '<':
|
||||||
if (AccFileSpecifier) {
|
if (AccFileSpecifier) {
|
||||||
UnGetChar(); /* pushback nch */
|
UnGetChar(); /* pushback nch */
|
||||||
ptok->tk_bts = string_token("file specifier",
|
ptok->tk_bts = string_token("file specifier", '>', &(ptok->tk_len));
|
||||||
'>', &(ptok->tk_len));
|
|
||||||
return ptok->tk_symb = FILESPECIFIER;
|
return ptok->tk_symb = FILESPECIFIER;
|
||||||
}
|
}
|
||||||
if (nch == '<') {
|
if (nch == '<') {
|
||||||
@ -312,10 +311,10 @@ garbage:
|
|||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case STIDF:
|
case STIDF:
|
||||||
{
|
{
|
||||||
register char *tg = &buf[0];
|
char *tg = &buf[0];
|
||||||
register int pos = -1;
|
int pos = -1;
|
||||||
register struct idf *idef;
|
struct idf *idef;
|
||||||
extern int idfsize; /* ??? */
|
int idfsize; /* ??? */
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
int NoExpandNext = 0;
|
int NoExpandNext = 0;
|
||||||
|
|
||||||
@ -361,8 +360,8 @@ garbage:
|
|||||||
}
|
}
|
||||||
case STNUM: /* a numeric constant */
|
case STNUM: /* a numeric constant */
|
||||||
{
|
{
|
||||||
register int siz_left = NUMSIZE - 1;
|
int siz_left = NUMSIZE - 1;
|
||||||
register char *np = &buf[0];
|
char *np = &buf[0];
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
#define store(ch) if (--siz_left >= 0) \
|
#define store(ch) if (--siz_left >= 0) \
|
||||||
@ -444,10 +443,11 @@ garbage:
|
|||||||
crash("bad class for char 0%o", ch);
|
crash("bad class for char 0%o", ch);
|
||||||
}
|
}
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
skipcomment()
|
void skipcomment()
|
||||||
{
|
{
|
||||||
/* The last character read has been the '*' of '/_*'. The
|
/* The last character read has been the '*' of '/_*'. The
|
||||||
characters, except NL and EOI, between '/_*' and the first
|
characters, except NL and EOI, between '/_*' and the first
|
||||||
@ -459,7 +459,7 @@ skipcomment()
|
|||||||
EOI is returned by LoadChar only on encountering EOF of the
|
EOI is returned by LoadChar only on encountering EOF of the
|
||||||
top-level file...
|
top-level file...
|
||||||
*/
|
*/
|
||||||
register int c, oldc = '\0';
|
int c, oldc = '\0';
|
||||||
|
|
||||||
NoUnstack++;
|
NoUnstack++;
|
||||||
c = GetChar();
|
c = GetChar();
|
||||||
@ -501,12 +501,10 @@ skipcomment()
|
|||||||
}
|
}
|
||||||
#endif /* NOPP */
|
#endif /* NOPP */
|
||||||
|
|
||||||
arith
|
arith char_constant(char *nm)
|
||||||
char_constant(nm)
|
|
||||||
char *nm;
|
|
||||||
{
|
{
|
||||||
register arith val = 0;
|
arith val = 0;
|
||||||
register int ch;
|
int ch;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
ch = GetChar();
|
ch = GetChar();
|
||||||
@ -534,15 +532,12 @@ char_constant(nm)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *string_token(char *nm, int stop_char, int *plen)
|
||||||
string_token(nm, stop_char, plen)
|
|
||||||
char *nm;
|
|
||||||
int *plen;
|
|
||||||
{
|
{
|
||||||
register int ch;
|
int ch;
|
||||||
register int str_size;
|
int str_size;
|
||||||
register char *str = Malloc((unsigned) (str_size = ISTRSIZE));
|
char *str = Malloc((unsigned) (str_size = ISTRSIZE));
|
||||||
register int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
ch = GetChar();
|
ch = GetChar();
|
||||||
while (ch != stop_char) {
|
while (ch != stop_char) {
|
||||||
@ -567,9 +562,7 @@ string_token(nm, stop_char, plen)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int quoted(int ch)
|
||||||
quoted(ch)
|
|
||||||
register int ch;
|
|
||||||
{
|
{
|
||||||
/* quoted() replaces an escaped character sequence by the
|
/* quoted() replaces an escaped character sequence by the
|
||||||
character meant.
|
character meant.
|
||||||
@ -628,9 +621,7 @@ quoted(ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int hex_val(int ch)
|
||||||
hex_val(ch)
|
|
||||||
register int ch;
|
|
||||||
{
|
{
|
||||||
return is_dig(ch) ? ch - '0'
|
return is_dig(ch) ? ch - '0'
|
||||||
: is_hex(ch) ? (ch - 'a' + 10) & 017
|
: is_hex(ch) ? (ch - 'a' + 10) & 017
|
||||||
@ -638,13 +629,12 @@ hex_val(ch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int GetChar()
|
||||||
GetChar()
|
|
||||||
{
|
{
|
||||||
/* The routines GetChar and trigraph parses the trigraph
|
/* The routines GetChar and trigraph parses the trigraph
|
||||||
sequences and removes occurences of \\\n.
|
sequences and removes occurences of \\\n.
|
||||||
*/
|
*/
|
||||||
register int ch;
|
int ch;
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
again:
|
again:
|
||||||
@ -671,10 +661,9 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
int
|
int trigraph()
|
||||||
trigraph()
|
|
||||||
{
|
{
|
||||||
register int ch;
|
int ch;
|
||||||
|
|
||||||
LoadChar(ch);
|
LoadChar(ch);
|
||||||
if (ch == '?') {
|
if (ch == '?') {
|
||||||
@ -718,11 +707,9 @@ trigraph()
|
|||||||
/* strflt2tok only checks the syntax of the floating-point number and
|
/* strflt2tok only checks the syntax of the floating-point number and
|
||||||
* selects the right type for the number.
|
* selects the right type for the number.
|
||||||
*/
|
*/
|
||||||
strflt2tok(fltbuf, ptok)
|
void strflt2tok(char fltbuf[], struct token *ptok)
|
||||||
char fltbuf[];
|
|
||||||
struct token *ptok;
|
|
||||||
{
|
{
|
||||||
register char *cp = fltbuf;
|
char *cp = fltbuf;
|
||||||
int malformed = 0;
|
int malformed = 0;
|
||||||
|
|
||||||
while (is_dig(*cp)) cp++;
|
while (is_dig(*cp)) cp++;
|
||||||
@ -757,11 +744,9 @@ struct token *ptok;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strint2tok(intbuf, ptok)
|
void strint2tok(char intbuf[], struct token *ptok)
|
||||||
char intbuf[];
|
|
||||||
struct token *ptok;
|
|
||||||
{
|
{
|
||||||
register char *cp = intbuf;
|
char *cp = intbuf;
|
||||||
int base = 10;
|
int base = 10;
|
||||||
arith val = 0, dig, ubound;
|
arith val = 0, dig, ubound;
|
||||||
int uns_flg = 0, lng_flg = 0, malformed = 0, ovfl = 0;
|
int uns_flg = 0, lng_flg = 0, malformed = 0, ovfl = 0;
|
||||||
|
|||||||
@ -11,9 +11,10 @@
|
|||||||
#include "LLlex.h"
|
#include "LLlex.h"
|
||||||
#include "Lpars.h"
|
#include "Lpars.h"
|
||||||
|
|
||||||
extern char *symbol2str();
|
char *symbol2str(int tok);
|
||||||
|
|
||||||
LLmessage(tk) {
|
void LLmessage(tk)
|
||||||
|
{
|
||||||
err_occurred = 1;
|
err_occurred = 1;
|
||||||
if (tk < 0) {
|
if (tk < 0) {
|
||||||
error("end of file expected");
|
error("end of file expected");
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
!File: lint.h
|
!File: lint.h
|
||||||
/*#define LINT 1 /* if defined, 'lint' is produced */
|
/*#define LINT 1*/ /* if defined, 'lint' is produced */
|
||||||
|
|
||||||
|
|
||||||
!File: pathlength.h
|
!File: pathlength.h
|
||||||
@ -75,24 +75,24 @@
|
|||||||
|
|
||||||
|
|
||||||
!File: botch_free.h
|
!File: botch_free.h
|
||||||
/*#define BOTCH_FREE 1 /* when defined, botch freed memory, as a check */
|
/*#define BOTCH_FREE 1*/ /* when defined, botch freed memory, as a check */
|
||||||
|
|
||||||
|
|
||||||
!File: dataflow.h
|
!File: dataflow.h
|
||||||
/*#define DATAFLOW 1 /* produce some compile-time xref */
|
/*#define DATAFLOW 1*/ /* produce some compile-time xref */
|
||||||
|
|
||||||
|
|
||||||
!File: debug.h
|
!File: debug.h
|
||||||
/*#define DEBUG 1 /* perform various self-tests */
|
/*#define DEBUG 1*/ /* perform various self-tests */
|
||||||
#define NDEBUG 1 /* disable assertions */
|
#define NDEBUG 1 /* disable assertions */
|
||||||
|
|
||||||
|
|
||||||
!File: use_tmp.h
|
!File: use_tmp.h
|
||||||
/*#define PREPEND_SCOPES 1 /* collect exa, exp, ina and inp commands
|
/*#define PREPEND_SCOPES 1*/ /* collect exa, exp, ina and inp commands
|
||||||
and if USE_TMP is defined let them
|
and if USE_TMP is defined let them
|
||||||
precede the rest of the generated
|
precede the rest of the generated
|
||||||
compact code */
|
compact code */
|
||||||
/*#define USE_TMP 1 /* use C_insertpart, C_endpart mechanism
|
/*#define USE_TMP 1*/ /* use C_insertpart, C_endpart mechanism
|
||||||
to generate EM-code in the order needed
|
to generate EM-code in the order needed
|
||||||
for the code-generators. If not defined,
|
for the code-generators. If not defined,
|
||||||
the old-style peephole optimizer is
|
the old-style peephole optimizer is
|
||||||
@ -108,7 +108,7 @@
|
|||||||
|
|
||||||
|
|
||||||
!File: inputtype.h
|
!File: inputtype.h
|
||||||
/*#define INP_READ_IN_ONE 1 /* read input file in one */
|
/*#define INP_READ_IN_ONE 1*/ /* read input file in one */
|
||||||
|
|
||||||
|
|
||||||
!File: nopp.h
|
!File: nopp.h
|
||||||
@ -116,13 +116,13 @@
|
|||||||
|
|
||||||
|
|
||||||
!File: nobitfield.h
|
!File: nobitfield.h
|
||||||
/*#define NOBITFIELD 1 /* if NOT defined, implement bitfields */
|
/*#define NOBITFIELD 1*/ /* if NOT defined, implement bitfields */
|
||||||
|
|
||||||
|
|
||||||
!File: spec_arith.h
|
!File: spec_arith.h
|
||||||
/* describes internal compiler arithmetics */
|
/* describes internal compiler arithmetics */
|
||||||
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
||||||
/*#define UNSIGNED_ARITH unsigned arith /* if it is supported */
|
/*#define UNSIGNED_ARITH unsigned arith*/ /* if it is supported */
|
||||||
|
|
||||||
|
|
||||||
!File: static.h
|
!File: static.h
|
||||||
@ -130,14 +130,14 @@
|
|||||||
|
|
||||||
|
|
||||||
!File: nocross.h
|
!File: nocross.h
|
||||||
/*#define NOCROSS 1 /* if NOT defined, cross compiler */
|
/*#define NOCROSS 1*/ /* if NOT defined, cross compiler */
|
||||||
|
|
||||||
|
|
||||||
!File: regcount.h
|
!File: regcount.h
|
||||||
/*#define REGCOUNT 1 /* count occurrences for register messages */
|
/*#define REGCOUNT 1*/ /* count occurrences for register messages */
|
||||||
|
|
||||||
|
|
||||||
!File: dbsymtab.h
|
!File: dbsymtab.h
|
||||||
/*#define DBSYMTAB 1 /* ability to produce symbol table for debugger */
|
/*#define DBSYMTAB 1*/ /* ability to produce symbol table for debugger */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
extern char options[];
|
extern char options[];
|
||||||
extern arith full_mask[/*MAXSIZE + 1*/]; /* cstoper.c */
|
extern arith full_mask[/*MAXSIZE + 1*/]; /* cstoper.c */
|
||||||
char *symbol2str();
|
char *symbol2str(int tok);
|
||||||
|
|
||||||
ch3mon(oper, expp)
|
ch3mon(oper, expp)
|
||||||
register struct expr **expp;
|
register struct expr **expp;
|
||||||
|
|||||||
@ -5,9 +5,7 @@ cat <<'--EOT--'
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include "Lpars.h"
|
#include "Lpars.h"
|
||||||
|
|
||||||
char *
|
char *symbol2str(int tok)
|
||||||
symbol2str(tok)
|
|
||||||
int tok;
|
|
||||||
{
|
{
|
||||||
#define SIZBUF 8
|
#define SIZBUF 8
|
||||||
/* allow for a few invocations in f.i. an argument list */
|
/* allow for a few invocations in f.i. an argument list */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user