File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ IMPL:
112112 # - {IMPL: wasm, wasm_MODE: wace_libc, NO_SELF_HOST_PERF: 1} # Hangs on GH Actions
113113 - {IMPL: wren}
114114 - {IMPL: xslt, NO_SELF_HOST: 1} # step1 fail: "Too many nested template ..."
115+ - {IMPL: yamlscript}
115116 - {IMPL: yorick}
116117 - {IMPL: zig}
117118
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ IMPLS = ada ada.2 awk bash basic bbc-basic c c.2 chuck clojure coffee common-lis
3737 guile hare haskell haxe hy io janet java java-truffle js jq julia kotlin latex3 livescript logo lua make mal \
3838 matlab miniMAL nasm nim objc objpascal ocaml perl perl6 php picolisp pike plpgsql \
3939 plsql powershell prolog ps purs python2 python3 r racket rexx rpython ruby ruby.2 rust scala scheme skew sml \
40- swift swift3 swift4 swift6 tcl ts vala vb vbs vhdl vimscript wasm wren yorick xslt zig
40+ swift swift3 swift4 swift6 tcl ts vala vb vbs vhdl vimscript wasm wren yamlscript yorick xslt zig
4141
4242step5_EXCLUDES += bash # never completes at 10,000
4343step5_EXCLUDES += basic # too slow, and limited to ints of 2^16
@@ -199,6 +199,7 @@ vhdl_STEP_TO_PROG = impls/vhdl/$($(1))
199199vimscript_STEP_TO_PROG = impls/vimscript/$($(1)).vim
200200wasm_STEP_TO_PROG = impls/wasm/$($(1)).wasm
201201wren_STEP_TO_PROG = impls/wren/$($(1)).wren
202+ yamlscript_STEP_TO_PROG = impls/yamlscript/$($(1)).ys
202203yorick_STEP_TO_PROG = impls/yorick/$($(1)).i
203204xslt_STEP_TO_PROG = impls/xslt/$($(1))
204205zig_STEP_TO_PROG = impls/zig/$($(1))
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ FAQ](docs/FAQ.md) where I attempt to answer some common questions.
139139| [ WebAssembly] ( #webassembly-wasm ) (wasm) | [ Joel Martin] ( https://github.com/kanaka ) |
140140| [ Wren] ( #wren ) | [ Dov Murik] ( https://github.com/dubek ) |
141141| [ XSLT] ( #xslt ) | [ Ali MohammadPur] ( https://github.com/alimpfard ) |
142+ | [ YAMLScript] ( #yamlscript ) | [ Ingy döt Net] ( https://github.com/ingydotnet ) |
142143| [ Yorick] ( #yorick ) | [ Dov Murik] ( https://github.com/dubek ) |
143144| [ Zig] ( #zig ) | [ Josh Tobin] ( https://github.com/rjtobin ) |
144145
@@ -1296,6 +1297,20 @@ cd impls/wren
12961297wren ./stepX_YYY.wren
12971298```
12981299
1300+ ### YS (YAMLScript)
1301+
1302+ The YS (YAMLScript) implementation of mal was tested on YS 0.2.3.
1303+
1304+ ```
1305+ cd impls/yamlscript
1306+ make test
1307+ ```
1308+
1309+ The Makefile will install ` ys ` locally so there are no prerequisites.
1310+
1311+ The YS language transpiles to Clojure Lisp and owes its origin to the "mal"
1312+ project!
1313+
12991314### Yorick
13001315
13011316The Yorick implementation of mal was tested on Yorick 2.2.04.
Original file line number Diff line number Diff line change 1+ /.cache /
Original file line number Diff line number Diff line change 1+ M := $(or $(MAKES_REPO_DIR ) ,.cache/makes)
2+ $(shell [ -d $M ] || git clone -q https ://github.com/makeplus/makes $M)
3+ include $M/init.mk
4+ include $M/clean.mk
5+ include $M/ys.mk
6+ include $M/shell.mk
7+
8+ ifndef BASIC
9+ export DEFERRABLE := 1
10+ export OPTIONAL := 1
11+ endif
12+
13+ IMPL := yamlscript
14+
15+ STEPS := $(shell for f in step* ; do echo $${f%% _* }; done)
16+ STEPS := $(STEPS:step%=% )
17+ ALL-TESTS := $(STEPS:%=test-% )
18+
19+ GREP-RESULTS := grep -E '(^TEST RESULTS|: .* tests$$)'
20+
21+ export YSPATH := lib
22+
23+
24+ test :
25+ time $(MAKE ) test-all BASIC=$(BASIC ) | & $(GREP-RESULTS )
26+ echo
27+
28+ test-all : $(ALL-TESTS )
29+
30+ $(ALL-TESTS ) : $(YS )
31+ time $(MAKE ) --no-print-directory -C ../.. \
32+ test^$(IMPL ) ^step$(@:test-%=% ) \
33+ MAL_IMPL=$(IMPL ) \
34+ DEFERRABLE=$(DEFERRABLE ) \
35+ OPTIONAL=$(OPTIONAL ) || \
36+ [[ $@ == test-6 ]]
Original file line number Diff line number Diff line change 1+ !YS-v0
2+ ns: printer
3+
4+ defn pr-str(ast):
5+ cond:
6+ map?(ast):
7+ cond:
8+ ast.list:
9+ "($(joins(ast.list.map(pr-str))))"
10+ ast.vector:
11+ "[$(joins(ast.vector.map(pr-str)))]"
12+ ast.hash-map:
13+ "{$(joins(ast.hash-map.map(pr-str)))}"
14+ ast.quote:
15+ "(quote $(ast.quote:pr-str))"
16+ ast.quasiquote:
17+ "(quasiquote $(ast.quasiquote:pr-str))"
18+ ast.unquote:
19+ "(unquote $(ast.unquote:pr-str))"
20+ ast.splice-unquote:
21+ "(splice-unquote $(ast.splice-unquote:pr-str))"
22+ ast.deref:
23+ "(deref $(ast.deref:pr-str))"
24+ ast.with-meta:
25+ "(with-meta $(ast.with-meta.0:pr-str)
26+ $(ast.with-meta.1:pr-str))"
27+ else: str(ast)
Original file line number Diff line number Diff line change 1+ !YS-v0
2+ ns: reader
3+
4+ tokens =: atom(nil)
5+
6+ re-tokenize =:
7+ qr:: |
8+ (?x)
9+ [\s,]*
10+ (
11+ ~@ |
12+ [\[\]{}()'`~^@] |
13+ "(?:\\.|[^\\"])*"? |
14+ ;.* |
15+ [^\s\[\]{}('"`,;)]*
16+ )
17+
18+ defn read-str(string):
19+ reset tokens: tokenize(string)
20+ read-form:
21+
22+ defn tokenize(string):
23+ remove empty?:
24+ map second:
25+ re-seq re-tokenize: string
26+
27+ defn peek():
28+ =>: tokens.@.first()
29+
30+ defn next():
31+ token =: peek()
32+ reset tokens: rest(tokens.@)
33+ =>: token
34+
35+ defn read-form():
36+ token =: peek()
37+ condp eq token:
38+ '(': read-list('list' ')')
39+ '[': read-list('vector' ']')
40+ '{': read-list('hash-map' '}')
41+ "'": read-quote('quote')
42+ '`': read-quote('quasiquote')
43+ '~': read-quote('unquote')
44+ '~@': read-quote('splice-unquote')
45+ '@': read-quote('deref')
46+ '^': with-meta()
47+ else: read-atom()
48+
49+ defn read-list(type end):
50+ next:
51+ =>::
52+ ! type::
53+ loop list []:
54+ token =: peek()
55+ when-not token:
56+ die: "Reached end of input in 'read_list'"
57+ if token != end:
58+ recur: list.conj(read-form())
59+ else:
60+ next:
61+ =>: list
62+
63+ defn read-quote(type):
64+ next:
65+ hash-map: type read-form()
66+
67+ defn with-meta():
68+ next:
69+ meta =: read-form()
70+ form =: read-form()
71+ hash-map: +
72+ 'with-meta' [form meta]
73+
74+ re-string =: /"((?:\\.|[^\\"])*)"/
75+
76+ defn read-atom():
77+ atom =: next()
78+ cond:
79+ atom =~ /^"/:
80+ when atom !~ re-string:
81+ die: "Reached end of input looking for '\"'"
82+ =>: atom
Original file line number Diff line number Diff line change 1+ !YS-v0
2+ ns: readline
3+
4+ defn readline(prompt):
5+ print: prompt
6+ read-line:
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -eu
4+
5+ exec ys " $( dirname " ${BASH_SOURCE[0]} " ) /${STEP:- stepA_mal} .ys" " $@ "
Original file line number Diff line number Diff line change 1+ !YS-v0
2+ use readline: :all
3+
4+ # read
5+ defn READ(strng):
6+ strng
7+
8+ # eval
9+ defn EVAL(ast):
10+ ast
11+
12+ # print
13+ defn PRINT(exp): exp
14+
15+ # repl
16+ defn rep(strng):
17+ PRINT: EVAL(READ(strng))
18+
19+ # repl loop
20+ defn repl-loop(line):
21+ when line:
22+ when line != '':
23+ say: rep(line)
24+ repl-loop: readline('mal-user> ')
25+
26+ # main
27+ defn main(*): repl-loop('')
You can’t perform that action at this time.
0 commit comments