aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-05-22 17:27:37 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-05-22 17:27:37 -0700
commit39e4332d45e770dfe684071db4d3427fa2ca6b0c (patch)
tree839faa275fd916808b4ab6bb00db32012080085c /sys
parent69487ed29aed49ca0e3481e9783e02e9156258b2 (diff)
fix: calling signature of popio
Diffstat (limited to 'sys')
-rw-r--r--sys/cmd/cc/ast.c2
-rw-r--r--sys/cmd/cc/cc.c55
-rw-r--r--sys/cmd/cc/cc.h10
-rw-r--r--sys/cmd/cc/lex.c30
-rw-r--r--sys/cmd/cc/pp.c2
-rw-r--r--sys/cmd/cc/rules.mk1
6 files changed, 55 insertions, 45 deletions
diff --git a/sys/cmd/cc/ast.c b/sys/cmd/cc/ast.c
index 184ddaf..825bade 100644
--- a/sys/cmd/cc/ast.c
+++ b/sys/cmd/cc/ast.c
@@ -48,6 +48,7 @@ closescope(Parser *p)
p->sp--;
}
+#if 0
static
void
declareobj(Parser *p, Decl *d)
@@ -107,6 +108,7 @@ declaretag(Parser *p, Type *t)
return define(&p->sp->tags, t->ident, Stype);
}
+#endif
static
Sym *
diff --git a/sys/cmd/cc/cc.c b/sys/cmd/cc/cc.c
index c06d1c3..16cc6e2 100644
--- a/sys/cmd/cc/cc.c
+++ b/sys/cmd/cc/cc.c
@@ -137,6 +137,36 @@ Nextdir:
}
// -----------------------------------------------------------------------
+// error reporting
+
+void
+errorat(Pos x, byte *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+
+ printf("error:%s:%d:%d: ", os·basename(x.path), x.line, x.col);
+ vprintf(fmt, args);
+ printf("\n");
+
+ va_end(args);
+ assert(0);
+}
+
+void
+warnat(Pos x, byte *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+
+ printf("warning:%s:%d:%d: ", os·basename(x.path), x.line, x.col);
+ vprintf(fmt, args);
+ printf("\n");
+
+ va_end(args);
+}
+
+// -----------------------------------------------------------------------
// main point of entry
void
@@ -167,7 +197,7 @@ init(void)
}
void
-initl(Lexer *lx)
+initlx(Lexer *lx)
{
int i;
@@ -187,12 +217,18 @@ initl(Lexer *lx)
lx->omit.cap = 100;
lx->omit.path = calloc(lx->omit.cap, sizeof(*C.inc.dir));
- lx->io = lx->iostk;
- lx->io->link = nil;
+ lx->new = lx->iostk;
+ lx->new->link = nil;
memset(lx->iostk, 0, sizeof(lx->iostk));
}
void
+freelx(Lexer *lx)
+{
+ free(lx->omit.path);
+}
+
+void
initp(Parser *p)
{
p->sp = p->spstk;
@@ -205,6 +241,7 @@ compile(byte *path)
{
Lexer lx;
Parser p;
+ error err;
byte *sep, out[400];
intern(&path);
@@ -229,17 +266,22 @@ compile(byte *path)
}
}
- initl(&lx);
+ initlx(&lx);
initp(&p);
- lx.io = openio(path);
+ lx.io = openio(&lx, path);
lx.pos = (Pos){
.path = path,
.line = 1,
.col = 1,
};
- return parse(&p, &lx);
+ Token t;
+ while (t = lex(&lx), t.kind != Aeof)
+ ;
+ // err = parse(&p, &lx);
+ freelx(&lx);
+ return err;
}
error
@@ -292,4 +334,3 @@ main(int argc, byte *argv[])
exit(0);
}
-
diff --git a/sys/cmd/cc/cc.h b/sys/cmd/cc/cc.h
index 62837c4..7d30360 100644
--- a/sys/cmd/cc/cc.h
+++ b/sys/cmd/cc/cc.h
@@ -314,13 +314,11 @@ rune getrune(Lexer *);
byte ungetbyte(Lexer *);
rune ungetrune(Lexer *, rune r);
-Io* openio(Lexer *lx, byte *path);
-Io* makeio(Lexer *lx, byte *name);
-void freeio(Lexer *lx, Io *io);
-void pushio(Lexer *lx, Io *new);
-void popio(Lexer *lx);
+Io* openio(Lexer *lx, byte *path);
+void pushio(Lexer *lx, Io *new);
+void popio(Lexer *lx);
-void puttok(Token);
+void puttok(Token);
// -----------------------------------------------------------------------
// parsing & type resolution
diff --git a/sys/cmd/cc/lex.c b/sys/cmd/cc/lex.c
index 1eb269c..dd6b476 100644
--- a/sys/cmd/cc/lex.c
+++ b/sys/cmd/cc/lex.c
@@ -852,33 +852,3 @@ forgetall(SymTab *tab)
{
MAP_RESET(tab);
}
-
-// -----------------------------------------------------------------------
-// error reporting
-
-void
-errorat(Pos x, byte *fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
-
- printf("error:%s:%d:%d: ", os·basename(x.path), x.line, x.col);
- vprintf(fmt, args);
- printf("\n");
-
- va_end(args);
- assert(0);
-}
-
-void
-warnat(Pos x, byte *fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
-
- printf("warning:%s:%d:%d: ", os·basename(x.path), x.line, x.col);
- vprintf(fmt, args);
- printf("\n");
-
- va_end(args);
-}
diff --git a/sys/cmd/cc/pp.c b/sys/cmd/cc/pp.c
index 5eed4b2..e05958d 100644
--- a/sys/cmd/cc/pp.c
+++ b/sys/cmd/cc/pp.c
@@ -892,7 +892,7 @@ ppinc(Lexer *lx)
goto Bad;
}
- io = openio(lx->buf);
+ io = openio(lx, lx->buf);
if (io != nil) {
pushio(lx, io);
}
diff --git a/sys/cmd/cc/rules.mk b/sys/cmd/cc/rules.mk
index d7a4ac1..b32d5b6 100644
--- a/sys/cmd/cc/rules.mk
+++ b/sys/cmd/cc/rules.mk
@@ -5,7 +5,6 @@ include share/push.mk
SRCS_$(d) := \
$(d)/pp.c \
$(d)/lex.c \
- $(d)/ast.c \
$(d)/cc.c
LIBS_$(d) :=