diff --git a/CMakeLists.txt b/CMakeLists.txt index 70df0a8..b2edcca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,5 +34,30 @@ if(FE_ABSL) set(ABSL_ENABLE_INSTALL ON) find_package(abseil) endif() + add_subdirectory(external/fe) -add_subdirectory(src) + +add_executable(let) +target_sources(let + PRIVATE + src/main.cpp + src/let/eval.cpp + src/let/lexer.cpp + src/let/parser.cpp + src/let/stream.cpp + src/let/tok.cpp + include/let/ast.h + include/let/driver.h + include/let/lexer.h + include/let/tok.h +) +target_link_libraries(let PRIVATE fe) +target_include_directories(let + PUBLIC + $ + $ +) +target_compile_features(let PUBLIC cxx_std_${CMAKE_CXX_STANDARD}) +if (MSVC AND BUILD_SHARED_LIBS AND FE_ABSL) + target_compile_definitions(liblet PUBLIC ABSL_CONSUME_DLL) +endif() diff --git a/external/fe b/external/fe index c26fe06..ad53460 160000 --- a/external/fe +++ b/external/fe @@ -1 +1 @@ -Subproject commit c26fe0620971c7f936e680258a7c40846be0ea5d +Subproject commit ad53460a104cd0a8662d0481bac0a303542edbff diff --git a/include/let/tok.h b/include/let/tok.h index cfc2f07..add6dfb 100644 --- a/include/let/tok.h +++ b/include/let/tok.h @@ -44,6 +44,7 @@ class Tok { public: // clang-format off enum class Tag { + Nil, #define CODE(t, _) t, LET_KEY(CODE) LET_VAL(CODE) @@ -80,6 +81,7 @@ class Tok { Tag tag() const { return tag_; } bool isa(Tag tag) const { return tag == tag_; } bool isa_key() const { return (int)tag() < Num_Keys; } + explicit operator bool() const { return tag_ != Tag::Nil; } Sym sym() const { assert(isa(Tag::V_sym)); @@ -96,7 +98,7 @@ class Tok { private: Loc loc_; - Tag tag_; + Tag tag_ = Tag::Nil; union { Sym sym_; uint64_t u64_; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index b572a89..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -add_executable(let main.cpp) - -target_sources(let PRIVATE main.cpp) -target_link_libraries(let PRIVATE fe) -target_include_directories(let - PUBLIC - $ - $ -) -target_compile_features(let PUBLIC cxx_std_${CMAKE_CXX_STANDARD}) -if (MSVC AND BUILD_SHARED_LIBS AND FE_ABSL) - target_compile_definitions(liblet PUBLIC ABSL_CONSUME_DLL) -endif() - -add_subdirectory(let) diff --git a/src/let/CMakeLists.txt b/src/let/CMakeLists.txt deleted file mode 100644 index 8317735..0000000 --- a/src/let/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -target_sources(let - PRIVATE - eval.cpp - lexer.cpp - parser.cpp - stream.cpp - tok.cpp -)