summaryrefslogtreecommitdiff
path: root/parse/node.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-11-04 00:06:59 -0800
committerOri Bernstein <ori@eigenstate.org>2015-11-06 00:39:35 -0800
commit2a27b2d8ac101e17e300a2e25421fc25c403b05b (patch)
tree00876c35ca526b7acc9858db9a51ea162535ad54 /parse/node.c
parentda4798f000d99dd326a542758da83ad04be72f86 (diff)
downloadmc-2a27b2d8ac101e17e300a2e25421fc25c403b05b.tar.gz
Rewrite pattern matching code.
Much cleaner, and more efficient.
Diffstat (limited to 'parse/node.c')
-rw-r--r--parse/node.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/parse/node.c b/parse/node.c
index eb613ff..6555ccf 100644
--- a/parse/node.c
+++ b/parse/node.c
@@ -260,7 +260,6 @@ Node *genlbl(Srcloc loc)
return mklbl(loc, buf);
}
-
Node *mkstr(Srcloc loc, Str val)
{
Node *n;
@@ -485,6 +484,14 @@ char *namestr(Node *name)
return name->name.name;
}
+char *lblstr(Node *n)
+{
+ assert(exprop(n) == Olit);
+ assert(n->expr.args[0]->type == Nlit);
+ assert(n->expr.args[0]->lit.littype == Llbl);
+ return n->expr.args[0]->lit.lblval;
+}
+
static size_t did(Node *n)
{
if (n->type == Ndecl) {