Refactor reader macros in AOC Day 8 pt 1

This commit is contained in:
2020-12-09 21:46:07 -07:00
parent 1a5eb07d48
commit 3afad56f71
4 changed files with 25 additions and 31 deletions

View File

@@ -1,28 +1,10 @@
(load "BootCodeCommon.kiss")
(defreadermacro "" [stream] #| ReaderExp.CallExp(
{
pos: {file: "bleh", line: 1, column: 1, absoluteChar: 1},
def: ReaderExp.Symbol(stream.expect("an instruction", function () { stream.takeUntilAndDrop(" "); }))
},
[
{
pos: {file: "fefea", line: 1, column: 1, absoluteChar: 1},
def: ReaderExp.CallExp(
{
pos: {file: "treh", line: 1, column: 1, absoluteChar: 1},
def: ReaderExp.Symbol(stream.expect("+/-", function () { stream.takeChars(1); }))
},
[
{
pos: {file: "smeeh", line: 1, column: 1, absoluteChar: 1},
def: ReaderExp.Symbol("0")
},
{
pos: {file: "greeeh", line: 1, column: 1, absoluteChar: 1},
def: ReaderExp.Symbol(stream.expect("an argument", function () { stream.takeUntilAndDrop("\n"); }))
}
])
}
])
|#)
(defreadermacro "" [stream]
`(,(ReaderExp.Symbol
(begin (stream.dropWhitespace) (nextToken stream)))
(,(ReaderExp.Symbol
(begin (stream.dropWhitespace) (stream.expect "+/-" (lambda [] (stream.takeChars 1)))))
0
,(ReaderExp.Symbol
(nextToken stream)))))