aboutsummaryrefslogtreecommitdiff
path: root/parser.d
diff options
context:
space:
mode:
Diffstat (limited to 'parser.d')
-rw-r--r--parser.d24
1 files changed, 24 insertions, 0 deletions
diff --git a/parser.d b/parser.d
index 1a1e5fb..004e1fb 100644
--- a/parser.d
+++ b/parser.d
@@ -486,6 +486,27 @@ class Parser {
return new Atom(to!double(to!string(acc)), line);
}
+ Form parseBoolean() {
+ char[] acc;
+ char next;
+ while (peekable()) {
+ next = peek();
+ if (isBoundary(next)) {
+ break;
+ }
+ acc ~= next;
+ advance();
+ }
+ switch (to!string(acc)) {
+ case "true":
+ return new Atom(true, line);
+ case "false":
+ return new Atom(false, line);
+ default:
+ return new ParseError(format("unparseable bool: #%s", to!string(acc)), line);
+ }
+ }
+
Form parseDef() {
// we've parsed `def`, but not the symbol yet
Form sym = parseForm();
@@ -726,6 +747,9 @@ class Parser {
}
writefln("received (but ignoring) type %s on line %d", to!string(typ), line);
return parseForm();
+ case '#':
+ advance(); // go past the hash
+ return parseBoolean();
default:
return parseSymbol();
}