Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realign to original 1 #633

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a146d19
Added Modula-2 and second C++ impls/ dirs.
Schol-R-LEA May 1, 2023
9bc67ff
removing extraneous .vscode directory.
Schol-R-LEA May 1, 2023
aa4b914
Removing .vscode, try #2
Schol-R-LEA May 1, 2023
cc2a02f
Delete .vscode directory
Schol-R-LEA May 1, 2023
eb521a0
Puttering around with various line editing libs
Schol-R-LEA May 4, 2023
6946ef4
intermediate check-in during dev of step 1
Schol-R-LEA May 5, 2023
917a40e
Interrim edit, some minor fixes
Schol-R-LEA May 5, 2023
0b89530
fixes to tokenizer
Schol-R-LEA May 5, 2023
7cd252e
Replaced 'token.cpp' with 'types.cpp'.
Schol-R-LEA May 6, 2023
f90bfde
bad const-removal hackery, but it mostly works now
Schol-R-LEA May 6, 2023
70f8098
Adding pr_str() and updating READ/EVAL/PRINT
Schol-R-LEA May 6, 2023
1987fc8
Fixed list and string input.
Schol-R-LEA May 7, 2023
df758af
Added exception handling for lists, vectors, strs
Schol-R-LEA May 7, 2023
f131146
Added Hashmaps, but not quite working.
Schol-R-LEA May 7, 2023
eabbf5c
Fixed issues with strings, reorganized tok fns
Schol-R-LEA May 7, 2023
51a64d1
Consolidated syntax tests as is_syntax
Schol-R-LEA May 7, 2023
3dfb102
Handling reader macros, but problems w/ lists.
Schol-R-LEA May 8, 2023
f8ddbd8
Fixed list problem.
Schol-R-LEA May 8, 2023
55accbe
Reorganizing number recognizer, more to come.
Schol-R-LEA May 9, 2023
dd86430
More refactoring of the number tokenizing
Schol-R-LEA May 9, 2023
5aab570
Finished refactoring numbers
Schol-R-LEA May 9, 2023
b6d940e
fixed decimal number input
Schol-R-LEA May 9, 2023
a703070
Fixed issue with null lists.
Schol-R-LEA May 10, 2023
5720254
Separated most of the parsing routines into files
Schol-R-LEA May 10, 2023
15cd76e
Fixed a problem with list balancing.
Schol-R-LEA May 10, 2023
a23acb5
Fixed hashmap balancing.
Schol-R-LEA May 10, 2023
e5729d7
Cheap hack to get the string parsing to pass tests
Schol-R-LEA May 10, 2023
7c88828
Initial scaffolding for step 2.
Schol-R-LEA May 11, 2023
c72eef6
Working on env extensions.
Schol-R-LEA May 13, 2023
9a3f0fc
Some fixes for MP-arith support, needs more work.
Schol-R-LEA May 14, 2023
faf9e79
Fixed MP-FP string representation.
Schol-R-LEA May 14, 2023
55c56f3
Fixed issues with MP-complex representation/print
Schol-R-LEA May 14, 2023
e701c29
Fixed false decimal problem in MP-complex.
Schol-R-LEA May 14, 2023
3fbf1f1
Procedure application sort of works
Schol-R-LEA May 14, 2023
af24c6f
adding support for addition of fp, rat, complex
Schol-R-LEA May 15, 2023
f117954
Added support for sub, mult, div.
Schol-R-LEA May 15, 2023
7ed0f55
Some simplifications of the arithmetic handling.
Schol-R-LEA May 16, 2023
b79917c
Fixed issue with complex input.
Schol-R-LEA May 16, 2023
172f2f4
Eval of vector and hashmap elements.
Schol-R-LEA May 16, 2023
5cbee0c
Implemented quasiquotation and unquoting.
Schol-R-LEA May 16, 2023
914f628
Completed step 2, pass.
Schol-R-LEA May 16, 2023
926e046
Brach to re-design the code to match the original
Schol-R-LEA May 16, 2023
5b58d02
Procedure application working, but maps need work
Schol-R-LEA May 18, 2023
cc36945
Cleared problems with HM internal evaluation.
Schol-R-LEA May 18, 2023
6de446d
Merging
Schol-R-LEA May 18, 2023
ab7b3d5
Get 'def! working
Schol-R-LEA May 18, 2023
333aaee
Almost finished with step 3 (1 test failing)
Schol-R-LEA May 18, 2023
b8601e0
Stage 3 passing.
Schol-R-LEA May 18, 2023
481897b
Added 'do' and 'if' support.
Schol-R-LEA May 18, 2023
00ad93d
Reorganized globals.
Schol-R-LEA May 19, 2023
ad1b57b
Functions now working.
Schol-R-LEA May 19, 2023
7ea52f5
Working on the core namespace.
Schol-R-LEA May 20, 2023
211f95c
Variable-length argument lists mostly working
Schol-R-LEA May 20, 2023
a469863
Finished work on variable-length argument lists.
Schol-R-LEA May 21, 2023
05c9b78
Fixed regression in 'def!'.
Schol-R-LEA May 21, 2023
fabba58
Whittling away at the print string errors.
Schol-R-LEA May 22, 2023
7e765e1
Passing all step 4
Schol-R-LEA May 22, 2023
ef7f095
Added world's least efficient cons, car, and cdr.
Schol-R-LEA May 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ GRTAGS
logs
old
tmp/

.vscode
8 changes: 6 additions & 2 deletions Makefile.impls
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ d_MODE = gdc
haxe_MODE = neko
# octave or matlab
matlab_MODE = octave
# gm2 or m2lang
modula2_MODE = gm2
# python, python2 or python3
python_MODE = python
# scheme (chibi, kawa, gauche, chicken, sagittarius, cyclone, foment)
Expand All @@ -34,10 +36,10 @@ wasm_MODE = wasmtime
# Implementation specific settings
#

IMPLS = ada ada.2 awk bash basic bbc-basic c c.2 chuck clojure coffee common-lisp cpp crystal cs d dart \
IMPLS = ada ada.2 awk bash basic bbc-basic c c.2 chuck clojure coffee common-lisp cpp cpp.2 crystal cs d dart \
elisp elixir elm erlang es6 factor fantom fennel forth fsharp go groovy gnu-smalltalk \
guile haskell haxe hy io janet java java-truffle js jq julia kotlin livescript logo lua make mal \
matlab miniMAL nasm nim objc objpascal ocaml perl perl6 php picolisp pike plpgsql \
matlab miniMAL modula2 nasm nim objc objpascal ocaml perl perl6 php picolisp pike plpgsql \
plsql powershell prolog ps purs python python.2 r racket rexx rpython ruby ruby.2 rust scala scheme skew sml \
swift swift3 swift4 swift5 tcl ts vala vb vhdl vimscript wasm wren yorick xslt zig

Expand Down Expand Up @@ -117,6 +119,7 @@ clojure_STEP_TO_PROG = $(clojure_STEP_TO_PROG_$(clojure_MODE))
coffee_STEP_TO_PROG = impls/coffee/$($(1)).coffee
common-lisp_STEP_TO_PROG = impls/common-lisp/$($(1))
cpp_STEP_TO_PROG = impls/cpp/$($(1))
cpp.2_STEP_TO_PROG = impls/cpp.2/$($(1))
crystal_STEP_TO_PROG = impls/crystal/$($(1))
cs_STEP_TO_PROG = impls/cs/$($(1)).exe
d_STEP_TO_PROG = impls/d/$($(1))
Expand Down Expand Up @@ -153,6 +156,7 @@ make_STEP_TO_PROG = impls/make/$($(1)).mk
mal_STEP_TO_PROG = impls/mal/$($(1)).mal
matlab_STEP_TO_PROG = impls/matlab/$($(1)).m
miniMAL_STEP_TO_PROG = impls/miniMAL/$($(1)).json
modula2_STEP_TO_PROG = impls/modula2/$($(1)).mod
nasm_STEP_TO_PROG = impls/nasm/$($(1))
nim_STEP_TO_PROG = impls/nim/$($(1))
objc_STEP_TO_PROG = impls/objc/$($(1))
Expand Down
2 changes: 2 additions & 0 deletions impls/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ package-lock.json
*/mal
*/notes

.vscode

logs
old

Expand Down
5 changes: 5 additions & 0 deletions impls/cpp.2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.deps
*.o
*.a
bin
bin/*
674 changes: 674 additions & 0 deletions impls/cpp.2/LICENSE

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions impls/cpp.2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
CC=g++
FLAGS=-g -Wall -Werror -Wextra
INC=includes/
BIN=bin
LIBS=-lreadline -lgmpxx -lgmp

step0_repl: step0_repl.cpp lineedit
$(CC) $(FLAGS) -I$(INC) $(LIBS) step0_repl.cpp $(BIN)/lineedit.o -o $(BIN)/step0_repl

step1_read_print: step1_read_print.cpp lineedit reader printer types parse_numbers parse_sequences parse_reader_macros
$(CC) $(FLAGS) -I$(INC) $(LIBS) step1_read_print.cpp \
$(BIN)/lineedit.o $(BIN)/reader.o $(BIN)/types.o $(BIN)/printer.o \
$(BIN)/parse_numbers.o $(BIN)/parse_sequences.o $(BIN)/parse_reader_macros.o \
-o $(BIN)/step1_read_print

step2_eval: step2_eval.cpp lineedit reader printer types parse_numbers parse_sequences parse_reader_macros eval env apply core
$(CC) $(FLAGS) -I$(INC) $(LIBS) step2_eval.cpp \
$(BIN)/lineedit.o $(BIN)/reader.o $(BIN)/types.o $(BIN)/printer.o \
$(BIN)/parse_numbers.o $(BIN)/parse_sequences.o $(BIN)/parse_reader_macros.o \
$(BIN)/eval.o $(BIN)/env.o $(BIN)/apply.o $(BIN)/core.o \
-o $(BIN)/step2_eval


step3_env: step3_env.cpp lineedit reader printer types parse_numbers parse_sequences parse_reader_macros eval env apply core
$(CC) $(FLAGS) -I$(INC) $(LIBS) step3_env.cpp \
$(BIN)/lineedit.o $(BIN)/reader.o $(BIN)/types.o $(BIN)/printer.o \
$(BIN)/parse_numbers.o $(BIN)/parse_sequences.o $(BIN)/parse_reader_macros.o \
$(BIN)/eval.o $(BIN)/env.o $(BIN)/apply.o $(BIN)/core.o \
-o $(BIN)/step3_env



step4_if_fn_do: step4_if_fn_do.cpp lineedit reader printer types parse_numbers parse_sequences parse_reader_macros eval env apply core
$(CC) $(FLAGS) -I$(INC) $(LIBS) step4_if_fn_do.cpp \
$(BIN)/lineedit.o $(BIN)/reader.o $(BIN)/types.o $(BIN)/printer.o \
$(BIN)/parse_numbers.o $(BIN)/parse_sequences.o $(BIN)/parse_reader_macros.o \
$(BIN)/eval.o $(BIN)/env.o $(BIN)/apply.o $(BIN)/core.o \
-o $(BIN)/step4_if_fn_do


core: core.cpp types env apply
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c core.cpp -o $(BIN)/core.o

eval: eval.cpp types env apply
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c eval.cpp -o $(BIN)/eval.o

apply: apply.cpp types env
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c apply.cpp -o $(BIN)/apply.o

env: env.cpp types
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c env.cpp -o $(BIN)/env.o


printer: printer.cpp $(INC)/printer.h types
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c printer.cpp -o $(BIN)/printer.o


reader: reader.cpp $(INC)/reader.h lineedit types parse_numbers parse_sequences parse_reader_macros
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c reader.cpp -o $(BIN)/reader.o

parse_reader_macros: parse_reader_macros.cpp $(INC)/parse_reader_macros.h types
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c parse_reader_macros.cpp -o $(BIN)/parse_reader_macros.o

parse_sequences: parse_sequences.cpp $(INC)/parse_sequences.h types
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c parse_sequences.cpp -o $(BIN)/parse_sequences.o

parse_numbers: parse_numbers.cpp $(INC)/parse_numbers.h types
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c parse_numbers.cpp -o $(BIN)/parse_numbers.o

types: types.cpp $(INC)/types.h lineedit
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c types.cpp -o $(BIN)/types.o

lineedit: lineedit.cpp $(INC)/lineedit.h
$(CC) $(FLAGS) -I$(INC) $(LIBS) -c lineedit.cpp -o $(BIN)/lineedit.o
28 changes: 28 additions & 0 deletions impls/cpp.2/apply.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

/* The following code applies the GNU Readline library and the GNU GMP library,
which are licensed under the GPL version 3.0. Please refer to the file
'LICENSE' in the implementation subdirectory.
*/

#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include "types.h"
#include "apply.h"
#include "eval.h"
#include "env.h"


TokenVector apply_fn(EnvPtr fn, TokenVector args)
{
if (fn->type() != ENV_PRIMITIVE && fn->type() != ENV_PROCEDURE)
{
throw new InvalidPrimitiveException();
}
else
{
return fn->apply(args);
}
}