scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit a95148537302c8fe01bef6538943d4313068f988
parent 65ab399458b19e47f7c8ef723eb8710159bb6e23
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 17 Apr 2014 13:48:20 +0200

Add out of function expressions

This funtcionality is needed for boxer.

Diffstat:
Mcc.h | 3+++
Mdecl.c | 5++++-
Mmain.c | 2+-
Mstmt.c | 2--
4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/cc.h b/cc.h @@ -222,4 +222,7 @@ extern Node #define ISNODEBIN(n) ((n)->code == emitbin) #define ISNODELOG(n) (ISNODEBIN(n) && (n)->u.op & 0x40) +extern Node *expr(void); +extern void extdecl(void), decl(void), compound(void); + #endif diff --git a/decl.c b/decl.c @@ -470,7 +470,6 @@ extdecl(void) int8_t sclass; Symbol *sym; char *err; - extern void compound(void); forbid_eof = 0; /* TODO: Fix when find EOF */ @@ -481,6 +480,10 @@ extdecl(void) goto bad_storage; case ';': break; + case '@': + next(); + emitexp(expr()); + return; default: goto dcl_expected; } diff --git a/main.c b/main.c @@ -4,7 +4,7 @@ #include "cc.h" -extern void extdecl(void), init_keywords(void), +extern void init_keywords(void), open_file(const char *file), init_expr(void); struct user_opt options; diff --git a/stmt.c b/stmt.c @@ -6,8 +6,6 @@ Symbol *curfun; -extern void decl(void); -extern Node *expr(void); extern Node *convert(Node *np, Type *tp1, char iscast); static void