Skip to content

Commit ee7cd58

Browse files
committed
VB.Net: port of C# version.
1 parent c3b508a commit ee7cd58

23 files changed

+4537
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ rust/mal
3333
rust/Cargo.lock
3434
rust/.cargo
3535
r/lib
36+
vb/*.exe
37+
vb/*.dll

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PYTHON = python
1111
#
1212

1313
IMPLS = bash c clojure coffee cs go java js make mal perl php ps \
14-
python r ruby rust
14+
python r ruby rust vb
1515

1616
step0 = step0_repl
1717
step1 = step1_read_print
@@ -65,6 +65,7 @@ python_STEP_TO_PROG = python/$($(1)).py
6565
r_STEP_TO_PROG = r/$($(1)).r
6666
ruby_STEP_TO_PROG = ruby/$($(1)).rb
6767
rust_STEP_TO_PROG = rust/target/$($(1))
68+
vb_STEP_TO_PROG = vb/$($(1)).exe
6869

6970

7071
bash_RUNSTEP = bash ../$(2) $(3)
@@ -84,10 +85,12 @@ python_RUNSTEP = $(PYTHON) ../$(2) $(3)
8485
r_RUNSTEP = Rscript ../$(2) $(3)
8586
ruby_RUNSTEP = ruby ../$(2) $(3)
8687
rust_RUNSTEP = ../$(2) $(3)
88+
vb_RUNSTEP = mono ../$(2) --raw $(3)
8789

8890
# Extra options to pass to runtest.py
8991
cs_TEST_OPTS = --redirect
9092
mal_TEST_OPTS = --start-timeout 60 --test-timeout 120
93+
vb_TEST_OPTS = --redirect
9194

9295

9396
# Derived lists

README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Description
44

55
Mal is an interpreter for a subset of the Clojure programming
6-
language. Mal is implemented from scratch in 17 different languages:
6+
language. Mal is implemented from scratch in 18 different languages:
77

88
* Bash shell
99
* C
@@ -22,6 +22,7 @@ language. Mal is implemented from scratch in 17 different languages:
2222
* R
2323
* Ruby
2424
* Rust
25+
* Visual Basic.NET
2526

2627

2728
Mal is also a learning tool. Each implementation of mal is separated
@@ -78,7 +79,7 @@ required to build and run the C# implementation.
7879
```
7980
cd cs
8081
make
81-
mono ./stepX_YYY
82+
mono ./stepX_YYY.exe
8283
```
8384

8485

@@ -213,6 +214,20 @@ cargo build
213214
./target/stepX_YYY
214215
```
215216

217+
### Visual Basic.NET ###
218+
219+
The VB.NET implementation of mal has been tested on Linux using the Mono
220+
VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are
221+
required to build and run the VB.NET implementation.
222+
223+
```
224+
cd vb
225+
make
226+
mono ./stepX_YYY.exe
227+
```
228+
229+
230+
216231
## Running tests
217232

218233
The are nearly 400 generic Mal tests (for all implementations) in the

mal/core.mal

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
["nil?" nil?]
55
["true?" true?]
66
["false?" false?]
7+
["symbol" symbol]
78
["symbol?" symbol?]
89

910
["pr-str" pr-str]

vb/Makefile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#####################
2+
3+
DEBUG =
4+
5+
TESTS =
6+
7+
SOURCES_BASE = readline.vb types.vb reader.vb printer.vb
8+
SOURCES_LISP = env.vb core.vb stepA_interop.vb
9+
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
10+
11+
#####################
12+
13+
SRCS = step0_repl.vb step1_read_print.vb step2_eval.vb \
14+
step3_env.vb step4_if_fn_do.vb step5_tco.vb step6_file.vb \
15+
step7_quote.vb step8_macros.vb step9_try.vb stepA_interop.vb
16+
17+
LIB_CS_SRCS = getline.cs
18+
LIB_VB_SRCS = $(filter-out step%,$(filter %.vb,$(SOURCES)))
19+
20+
FLAGS = $(if $(strip $(DEBUG)),-debug:full,)
21+
22+
#####################
23+
24+
all: mal.exe $(patsubst %.vb,%.exe,$(SRCS))
25+
26+
mal.exe: $(patsubst %.vb,%.exe,$(word $(words $(SOURCES)),$(SOURCES)))
27+
cp $< $@
28+
29+
mal_cs.dll: $(LIB_CS_SRCS)
30+
mcs $(FLAGS) -target:library $+ -out:$@
31+
32+
mal_vb.dll: mal_cs.dll $(LIB_VB_SRCS)
33+
vbnc $(FLAGS) -target:library -r:mal_cs.dll $(LIB_VB_SRCS) -out:$@
34+
35+
%.exe: %.vb mal_vb.dll
36+
vbnc $(FLAGS) -r:mal_vb.dll -r:mal_cs.dll $<
37+
38+
clean:
39+
rm -f *.dll *.exe *.mdb
40+
41+
.PHONY: stats tests $(TESTS)
42+
43+
stats: $(SOURCES)
44+
@wc $^
45+
stats-lisp: $(SOURCES_LISP)
46+
@wc $^
47+
48+
tests: $(TESTS)
49+
50+
$(TESTS):
51+
@echo "Running $@"; \
52+
./$@ || exit 1; \

0 commit comments

Comments
 (0)