From b075c000c2c52a674bb7c27a398dc3a795b40d8f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 4 Mar 2023 10:07:01 +0800 Subject: [PATCH] 1 --- a8/lisp.cc | 7 ++++++- a8/lisp.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/a8/lisp.cc b/a8/lisp.cc index ccdea56..1c06f57 100644 --- a/a8/lisp.cc +++ b/a8/lisp.cc @@ -158,6 +158,9 @@ namespace a8 if (token == "(") { List new_list = std::make_shared>>(); stack.push_back(new_list); + if (depth >= 0) { + stack.at(depth)->push_back(std::make_shared(new_list)); + } ++depth; } else if (token == ")") { --depth; @@ -178,7 +181,9 @@ namespace a8 } stack.at(depth)->push_back(symbol); } else { - abort(); + Symbol symbol; + symbol.name = token; + stack.at(depth)->push_back(std::make_shared(symbol)); } } } diff --git a/a8/lisp.h b/a8/lisp.h index 37c74c2..95ecef4 100644 --- a/a8/lisp.h +++ b/a8/lisp.h @@ -47,7 +47,7 @@ namespace a8 a8::XObject ToXObject(); }; - class Scope + class Scope : public std::enable_shared_from_this { public: std::shared_ptr Find(const std::string& name);