/* $Id$ */
/* L E X I C A L A N A L Y Z E R */
+#include <string.h>
+
#include "idfsize.h"
#include "numsize.h"
#include "strsize.h"
struct token dot;
+char *string_token(char *nm, int stop_char);
+arith char_constant(char *nm);
+int val_in_base(int ch, int base);
+int quoted(int ch);
+int trigraph();
+
int ReplaceMacros = 1; /* replacing macros */
int AccDefined = 0; /* accept "defined(...)" */
int UnknownIdIsZero = 0; /* interpret unknown id as integer 0 */
int LexSave = 0; /* last character read by GetChar */
extern int InputLevel; /* # of current macro expansions */
-extern char *string_token();
-extern char *strcpy();
-extern arith char_constant();
#define FLG_ESEEN 0x01 /* possibly a floating point number */
#define FLG_DOTSEEN 0x02 /* certainly a floating point number */
};
#include "file_info.h"
+#include <symbol2str.h>
#define tk_symb tok_symb
#define tk_str tok_data.tok_str
extern int err_occurred; /* "error.c" */
+struct idf;
+struct repl;
void skipcomment();
+void fatal(char *fmt, ...);
+void error(char *fmt, ...);
+void warning(char *fmt, ...);
+void strict(char *fmt, ...);
+void crash(char *fmt, ...);
+int GetToken(struct token *ptok);
+void EnableMacros();
+int replace(struct idf *idf);
+int skipspaces(int ch, int skipnl);
+int SkipToNewLine();
+void do_pragma();
+int ifexpr();
+void If_expr(void);
+void add_dependency(char *s);
+int getparams(char *buf[], char parbuf[]);
+int macroeq(char *s, char *t);
+void add2repl(struct repl *repl, int ch);
+char *GetIdentifier(int skiponerr);
+void macro_def(struct idf *id, char *text, int nformals, int length, int flags);
+void unstackrepl();
+void init_pp();
+void do_option(char *text);
+void preprocess(char *fn);
+void do_undef(char *argstr);
+void domacro();
+int actual(struct repl *repl);
+void ch3mon(int oper, arith *pval, int *puns);
+int rank_of(int oper);
+void ch3bin(arith *pval, int *pis_uns, int oper, arith val, int is_uns);
+/* External */
+int InsertFile(char *, char **, char **);
#define DOT dot.tk_symb
#include "Lpars.h"
#include "arith.h"
+#include "LLlex.h"
#define arith_sign (1L << (sizeof(arith)*8-1))
void macro_def(struct idf *id, char *text, int nformals, int length, int flags)
{
- register struct macro *newdef = id->id_macro;
+ struct macro *newdef = id->id_macro;
/* macro_def() puts the contents and information of a macro
definition into a structure and stores it into the symbol
return;
} else {
#ifdef DOBITS
- register char *p = id->id_text;
+ unsigned char *p = (unsigned char *)id->id_text;
#define setbit(bx) if (!*p) goto go_on; bits[*p++] |= (bx)
setbit(bit0);
setbit(bit1);
#include <varargs.h>
#endif
+#include "print.h"
#include "arith.h"
#include "errout.h"
#include "LLlex.h"
/* $Id$ */
/* F I L E I N F O R M A T I O N S T R U C T U R E */
+#ifndef LANG_CEM_CPP_ANSI_FILE_INFO_H
+#define LANG_CEM_CPP_ANSI_FILE_INFO_H
+
struct file_info {
unsigned int fil_lino;
char *fil_name;
#define WorkingDir finfo.fil_wdir
extern struct file_info finfo; /* input.c */
+
+#endif /* LANG_CEM_CPP_ANSI_FILE_INFO_H */
\ No newline at end of file
#include "class.h"
#include "macro.h"
#include "idf.h"
+#include "print.h"
+#include "arith.h"
+#include "LLlex.h"
struct mkey {
char *mk_reserved;
#include <string.h>
#include "file_info.h"
#include "input.h"
+#include "arith.h"
+#include "LLlex.h"
#define INP_PUSHBACK 3
#define INP_TYPE struct file_info
#include "idfsize.h"
#include "idf.h"
#include "macro.h"
+#include "print.h"
+#include "LLlex.h"
-extern char *symbol2str();
extern char *getwdir();
extern int err_occurred;
extern int do_dependencies;
#include "class.h"
#include "macro.h"
#include "idf.h"
+#include "arith.h"
+#include "LLlex.h"
char options[128]; /* one for every char */
int inc_pos = 1; /* place where next -I goes */
extern int idfsize;
+int txt2int(char **tp);
+
void do_option(char *text)
{
switch(*text++) {
case '-':
- options[*text] = 1;
+ options[*(unsigned char *)text] = 1;
break;
case 'u':
if (! strcmp(text, "ndef")) {
case 'm':
case 'o': /* ignore garbage after #else or #endif */
case 'C' : /* comment output */
- options[*(text-1)] = 1;
+ options[*(unsigned char *)(text-1)] = 1;
break;
case 'D' : /* -Dname : predefine name */
{
- register char *cp = text, *name, *mactext;
+ char *cp = text, *name, *mactext;
unsigned maclen;
- if (class(*cp) != STIDF && class(*cp) != STELL) {
+ if (class(*(unsigned char *)cp) != STIDF && class(*(unsigned char *)cp) != STELL) {
error("identifier missing in -D%s", text);
break;
}
name = cp;
- while (*cp && in_idf(*cp))
+ while (*cp && in_idf(*(unsigned char *)cp))
++cp;
if (!*cp) { /* -Dname */
maclen = 1;
}
case 'I' : /* -Ipath : insert "path" into include list */
if (*text) {
- register int i;
- register char *new = text;
+ int i;
+ char *new = text;
if (++inc_total > inc_max) {
inctable = (char **)
/* the integer pointed to by *tp is read, while increasing
*tp; the resulting value is yielded.
*/
- register int val = 0;
- register int ch;
+ int val = 0;
+ int ch;
while (ch = **tp, ch >= '0' && ch <= '9') {
val = val * 10 + ch - '0';
void do_pragma()
{
- register int size = ITEXTSIZE;
+ int size = ITEXTSIZE;
char *cur_line = Malloc((unsigned)size);
- register char *c_ptr = cur_line;
- register int c = GetChar();
- register int delim = 0;
+ char *c_ptr = cur_line;
+ int c = GetChar();
+ int delim = 0;
while(c != '\n') {
if (c_ptr + 1 - cur_line == size) {
void preprocess(char *fn)
{
- register int c;
- register char *op = _obuf;
- register char *ob = &_obuf[OBUFSIZE];
+ int c;
+ char *op = _obuf;
+ char *ob = &_obuf[OBUFSIZE];
int lineno = 0;
int startline;
/* Generate a line directive communicating the
source filename
*/
- register char *p = Xbuf;
+ char *p = Xbuf;
sprint(p, "%s 1 \"%s\"\n",
LINE_PREFIX,
fn = FileName; \
lineno = LineNumber; \
if (! options['P']) { \
- register char *p = Xbuf; \
+ char *p = Xbuf; \
sprint(Xbuf, "%s %d \"%s\"\n", \
LINE_PREFIX, \
(int)LineNumber, \
FileName); \
op--; \
while (op >= _obuf \
- && (class(*op) == STSKIP \
+ && (class(*(unsigned char *)op) == STSKIP \
|| *op == '\n')) op--; \
op++; \
newline(); \
while (startline) {
/* first flush the saved pragma's */
if (pragma_nr) {
- register int i = 0;
+ int i = 0;
int LiNo = LineNumber;
char *FiNam = FileName;
while (i < pragma_nr) {
- register char *c_ptr = "#pragma";
+ char *c_ptr = "#pragma";
LineNumber = pragma_tab[i].pr_linnr;
FileName = pragma_tab[i].pr_fil;
case STSTR:
case STCHAR:
{
- register int stopc = c;
+ int stopc = c;
int escaped;
do {
case STIDF: {
extern int idfsize; /* ??? */
char buf[IDFSIZE + 1];
- register char *tg = &buf[0];
- register char *maxpos = &buf[idfsize];
- register struct idf *idef;
+ char *tg = &buf[0];
+ char *maxpos = &buf[idfsize];
+ struct idf *idef;
int NoExpandNext = 0;
#define tstmac(bx) if (!(bits[c] & bx)) goto nomac
static char *SkipComment(char *op, int *lineno)
{
char *ob = &_obuf[OBUFSIZE];
- register int c, oldc = '\0';
+ int c, oldc = '\0';
NoUnstack++;
if (options['C']) {
void macro2buffer(struct repl *repl, struct idf *idf, struct args *args);
void add2repl(struct repl *repl, int ch);
void stash(struct repl *repl, int ch, int stashraw);
-
-char *GetIdentifier(int skiponerr); /* domacro.c */
+int expand_macro(struct repl *repl, struct idf *idf);
int replace(struct idf *idf)
{
/* trim the actual replacement list */
--repl->r_ptr;
while (repl->r_ptr >= repl->r_text
- && is_wsp(*repl->r_ptr))
+ && is_wsp(*(unsigned char *)repl->r_ptr))
--repl->r_ptr;
/* ## occurred at the beginning of the replacement list.
/* tmpindex can be 0 */
/* skip space in macro replacement list */
- while ((*ptr & FORMALP) == 0 && is_wsp(*ptr))
+ while ((*ptr & FORMALP) == 0 && is_wsp(*(unsigned char *)ptr))
ptr++;
/* ## occurred at the end of the replacement list.
assert(n > 0);
p = args->a_rawvec[n-1];
if (p) { /* else macro argument missing */
- while (is_wsp(*p)) p++;
+ while (is_wsp(*(unsigned char *)p)) p++;
if (*p == NOEXPM) p++;
while (*p)
add2repl(repl, *p++);
}
while (tmpindex > 0
- && in_idf(repl->r_text[tmpindex]))
+ && in_idf((unsigned char)repl->r_text[tmpindex]))
tmpindex--;
if (tmpindex >= 0
&& repl->r_text[tmpindex] == NOEXPM)
err = 1;
break;
} else {
- if (in_idf(*ptr)) {
+ if (in_idf(*(unsigned char *)ptr)) {
tmpindex--;
while (tmpindex > 0
- && in_idf(repl->r_text[tmpindex]))
+ && in_idf((unsigned char)repl->r_text[tmpindex]))
tmpindex--;
if (tmpindex >= 0
&& repl->r_text[tmpindex] == NOEXPM)
argument buffer instead of the expanded
one.
*/
- for (p = ptr; (*p & FORMALP) == 0 && is_wsp(*p); p++)
+ for (p = ptr; (*p & FORMALP) == 0 && is_wsp(*(unsigned char *)p); p++)
/* EMPTY */;
if (*p == '#' && p[1] == '#')
q = args->a_rawvec[n-1];
register int backslash = 0; /* last character was a \ */
/* skip spaces macro replacement list */
- while ((*ptr & FORMALP) == 0 && is_wsp(*ptr))
+ while ((*ptr & FORMALP) == 0 && is_wsp(*(unsigned char *)ptr))
ptr++;
if (*ptr & FORMALP) {
p = args->a_rawvec[n-1];
add2repl(repl, '"');
while (*p) {
- if (is_wsp(*p)) {
+ if (is_wsp(*(unsigned char *)p)) {
if (!space) {
space = 1;
add2repl(repl, ' ');
}
/* trim spaces in the replacement list */
- for (--repl->r_ptr; is_wsp(*repl->r_ptr); repl->r_ptr--)
+ for (--repl->r_ptr; is_wsp(*(unsigned char *)repl->r_ptr); repl->r_ptr--)
/* EMPTY */;
++repl->r_ptr; /* oops, one to far */
add2repl(repl, '"');
extern int InputLevel;
-int
-skipspaces(ch, skipnl)
- register int ch;
+int skipspaces(int ch, int skipnl)
{
/* skipspaces() skips any white space and returns the first
non-space character.
*/
- register int nlseen = 0;
+ int nlseen = 0;
for (;;) {
while (class(ch) == STSKIP)
}
}
-SkipToNewLine()
+int SkipToNewLine()
{
- register int ch;
- register int garbage = 0;
- register int delim = 0;
+ int ch;
+ int garbage = 0;
+ int delim = 0;
while ((ch = GetChar()) != '\n') {
if (delim) {
void do_option(char *text);
void preprocess(char *fn);
void domacro();
+int rank_of(int oper);
+char *GetIdentifier();
+char **getactuals(struct idf *idef);
/* External */
int InsertFile(char *, char **, char **);
\ No newline at end of file
#include "Lpars.h"
-int
-rank_of(oper)
- int oper;
+int rank_of(int oper)
{
/* The rank of the operator oper is returned.
*/
static char *macro2buffer(struct idf *idef, char **actpars, int *siztext);
static void macro_func(struct idf *idef);
-
-char *GetIdentifier(); /* domacro.c */
-char **getactuals(struct idf *idef); /* scan.c */
char *long2str(long value, int base); /* External lib */
int replace(struct idf *idef)
replace() returns 1 if the replacement succeeded and 0 if
some error has occurred.
*/
- register struct macro *mac = idef->id_macro;
- register char c;
+ struct macro *mac = idef->id_macro;
+ char c;
char **actpars;
char *reptext;
- register struct mlist *repl;
+ struct mlist *repl;
int size;
if (mac->mc_flag & NOREPLACE) {
replacement texts must be evaluated at the time they are
used.
*/
- register struct macro *mac = idef->id_macro;
+ struct macro *mac = idef->id_macro;
switch (idef->id_text[2]) { /* This switch is very blunt... */
case 'F' : /* __FILE__ */
If there are no parameters, this function behaves
the same as strcpy().
*/
- register unsigned int size = idef->id_macro->mc_length + ITEXTSIZE;
- register char *text = Malloc(size);
- register int pos = 0;
- register char *ptr = idef->id_macro->mc_text;
+ unsigned int size = idef->id_macro->mc_length + ITEXTSIZE;
+ char *text = Malloc(size);
+ int pos = 0;
+ char *ptr = idef->id_macro->mc_text;
while (*ptr) {
if (*ptr & FORMALP) { /* non-asc formal param. mark */
- register int n = *ptr++ & 0177;
- register char *p;
+ int n = *ptr++ & 0177;
+ char *p;
assert(n != 0);
/* copy the text of the actual parameter
void EnableMacros()
{
- register struct mlist *p = ReplList, *prev = 0;
+ struct mlist *p = ReplList, *prev = 0;
assert(Unstacked > 0);
while (p) {