Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Thing parse(string* text) {
- if (text.accept "(") {
- Thing[] things;
- while (!text.accept ")")
- things ~= parse text;
- return new List things;
- }
- if (gotNum(text, &float f)) {
- return new Number f;
- }
- if (text.accept("\"")) {
- auto str = slice(text, "\"");
- return new String str;
- }
- if (text.accept("'")) {
- return new Escape (parse text);
- }
- auto t2 = *text #.strip();
- char[auto~] token;
- while (t2.length && t2[0] != " " && t2[0] != ")" && t2[0] != "(" && t2[0] != "\r" && t2[0] != "\n") {
- token ~= t2[0];
- t2 = t2[1..$];
- }
- if (!token.length)
- error "Don't know what to do at $t2";
- *text = t2;
- return new Token token[];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement