-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
125 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
.PHONY: all clean | ||
|
||
TARGETS = mylisp | ||
|
||
all: $(TARGETS) | ||
|
||
# コンパイラオプション: | ||
# https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++ | ||
# 英語版のほうが更新されている。 | ||
|
||
# GDB でデバグする場合, `-g` オプションよりも `-g3` のほうが便利. | ||
# リリースビルド = -DNDEBUG | ||
DEBUG = -g3 -D_DEBUG | ||
|
||
# _FORTIFY_SOURCE は副作用がありうる | ||
CXXFLAGS = -Wall -Wextra -Wno-unused-parameter -Wno-format-extra-args \ | ||
-O2 -Wformat -Wformat=2 -Wimplicit-fallthrough -Werror=format-security \ | ||
$(DEBUG) \ | ||
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 \ | ||
-D_GLIBCXX_ASSERTIONS \ | ||
-fstrict-flex-arrays=3 \ | ||
-fstack-clash-protection -fstack-protector-strong \ | ||
-Wl,-z,nodlopen -Wl,-z,noexecstack \ | ||
-Wl,-z,relro -Wl,-z,now \ | ||
-Wl,--as-needed -Wl,--no-copy-dt-needed-entries \ | ||
-fPIE -pie | ||
|
||
mylisp: main.o edit_line.o reader.o object_print.o environment.o evaluation.o macros.o builtin-functions.o | ||
$(CXX) $^ $(LDFLAGS) $(LDLIBS) -lstdc++ -licuuc -licuio -ledit -o $@ | ||
|
||
reader.o: reader.cpp s_expr.h | ||
object_print.o: object_print.cpp s_expr.h | ||
s_expr.h: my_debug.h | ||
environment.o: environment.cpp environment.h s_expr.h | ||
evaluation.o: evaluation.cpp environment.h s_expr.h | ||
builtin-functions.o: builtin-functions.cpp environment.h s_expr.h | ||
|
||
clean: | ||
rm -f *.o $(TARGETS) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
#ifndef MYLISP_EVAL_H | ||
#define MYLISP_EVAL_H | ||
|
||
#include "s_expr.h" | ||
#include "environment.h" | ||
|
||
namespace my { | ||
|
||
extern value_t EVAL1(value_t ast, EnvPtr env); | ||
extern bool value_isTrue(const value_t& value) ; | ||
|
||
extern void setup_functions(); | ||
|
||
extern void define_macro(const icu::UnicodeString& name, | ||
const icu::UnicodeString& params, | ||
ListPtr body); | ||
|
||
} // namespace my | ||
|
||
#endif // !MYLISP_EVAL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#include "edit_line.h" | ||
#include "environment.h" | ||
#include "s_expr.h" | ||
#include "eval.h" | ||
#include <iostream> | ||
#include <unicode/unistr.h> | ||
using namespace icu; | ||
|
||
int main() | ||
{ | ||
my::EditLine editLine("~/my-lisp.history"); | ||
|
||
my::EnvPtr toplevel = std::make_shared<my::Environment>(); | ||
my::setup_functions(); | ||
|
||
UnicodeString line; | ||
bool f; | ||
while ( editLine.get("* ", &line) ) { | ||
my::value_t astv = my::read_from_string(line); | ||
my::value_t r = my::EVAL1(astv, toplevel); | ||
PRINT(r, std::cout); std::cout << "\n"; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters