summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-01-29 17:28:06 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-01-29 17:28:06 -0500
commitacbe89c2fd6d093dee1eac23521da1fbcd222962 (patch)
tree498267710d8c6990f811685e4bf5f4a542a1f7ad
parent01f2052b91d2c352e8b3ff455a9dda5a2a44fc0f (diff)
more namespaces
-rw-r--r--.parse.c.swpbin0 -> 94208 bytes
-rw-r--r--copy.c3
-rw-r--r--main.c2
-rw-r--r--parse.c7
4 files changed, 11 insertions, 1 deletions
diff --git a/.parse.c.swp b/.parse.c.swp
new file mode 100644
index 0000000..68b132c
--- /dev/null
+++ b/.parse.c.swp
Binary files 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;
}
}