diff options
Diffstat (limited to 'parser.d')
| -rw-r--r-- | parser.d | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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(); } |
