From acbe89c2fd6d093dee1eac23521da1fbcd222962 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Wed, 29 Jan 2020 17:28:06 -0500 Subject: more namespaces --- .parse.c.swp | Bin 0 -> 94208 bytes copy.c | 3 +++ main.c | 2 +- parse.c | 7 +++++++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .parse.c.swp diff --git a/.parse.c.swp b/.parse.c.swp new file mode 100644 index 0000000..68b132c Binary files /dev/null and b/.parse.c.swp differ diff --git a/copy.c b/copy.c index 02c23e4..7b8c24e 100644 --- a/copy.c +++ b/copy.c @@ -318,6 +318,9 @@ static void copy_stmt(Copier *c, Statement *out, Statement *in) { case STMT_DECL: copy_decl(c, &out->decl, &in->decl); break; + case STMT_NAMESPACE: + copy_block(c, &out->ns.body, &in->ns.body); + break; } } diff --git a/main.c b/main.c index 496c3cc..40ce416 100644 --- a/main.c +++ b/main.c @@ -18,7 +18,7 @@ /* TODO: -nested packages +namespace constants in structs #if diff --git a/parse.c b/parse.c index bd523ea..6b0a59a 100644 --- a/parse.c +++ b/parse.c @@ -2025,6 +2025,7 @@ static bool parse_stmt(Parser *p, Statement *s, bool *was_a_statement) { ++t->token; if (t->token->kind == TOKEN_IDENT) { s->ns.name = t->token->ident; + ++t->token; } else { s->ns.name = NULL; } @@ -2398,6 +2399,12 @@ static void fprint_stmt(FILE *out, Statement *s) { fprintf(out, ";\n"); } break; + case STMT_NAMESPACE: + fprintf(out, "namespace "); + if (s->ns.name) + fprint_ident(out, s->ns.name); + fprint_block(out, &s->ns.body); + break; } } -- cgit v1.2.3