|There is some arc stuff in rainbow that isn't rainbow-specific, so I've committed it to anarki.|
It includes an arc parser (spun off because welder needed a tokeniser for colourising) and a little test runner.
This parser or something like it could eventually replace 'sread. An advantage of having an arc parser written in arc is that there can be no ambiguity about what is officially arc syntax; also, it will be easier to make certain kinds of syntax changes. A temporary disadvantage is that this parser doesn't support all the scheme syntax that arc supports. It's a very simple implementation (apart from the token generator function which took some wikipedia support to get working) and probably needs improvements.
The test runner runs simple tests, or test suites, of this form:
arc>(apply (eval (parse "[* _ _]")) '(27))
There are lots of test examples under lib/tests. "foundation-test.arc" covers the most basic, low-level arc functions, and might be useful to anyone building their own arc interpreter. "parser-test.arc" provides a bunch of tests for the parser, and for the source indexer (used by welder).
(suite "parser tests"
("parse foo" (parse "foo") foo)
("parse a list" (parse "(a b c)") (a b c)))
This is one way to launch tests:
I've been a fan of test-driven-development for a few years and this test runner, unsophisticated though it may be, has already been pretty helpful.
arc> (load "lib/unit-test.arc")
arc> (load "lib/parser.arc")
arc> (load "lib/tests/parser-test.arc")