Skip to content

Commit 2e9e845

Browse files
authored
Merge pull request #446 from yamacir-kit/release-candidate
Release candidate
2 parents 828dc59 + 35abe15 commit 2e9e845

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2357
-1792
lines changed

.github/workflows/build.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
- uses: actions/checkout@v3
2020
- run: ./script/setup.sh --all
2121
- run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }}
22-
- run: cmake --build build --target safe-install.deb
22+
- run: cmake --build build --target develop
2323
- run: cmake -B example/build -S example -DCMAKE_BUILD_TYPE=${{ matrix.configuration }}
24-
- run: cmake --build example/build --target demo
24+
- run: cmake --build example/build --target develop

CMakeLists.txt

+19-25
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_B
3939

4040
# ---- Configure ---------------------------------------------------------------
4141

42-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
43-
execute_process(COMMAND git rev-parse HEAD
44-
COMMAND tr -d "\n"
45-
OUTPUT_VARIABLE ${PROJECT_NAME}_VERSION_EXACT)
46-
else()
47-
set(${PROJECT_NAME}_VERSION_EXACT "")
48-
endif()
49-
5042
include(TestBigEndian)
5143

5244
TEST_BIG_ENDIAN(IS_BIG_ENDIAN) # Use CMAKE_CXX_BYTE_ORDER if CMake >= 3.20
@@ -87,8 +79,7 @@ target_include_directories(kernel PUBLIC
8779
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
8880
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
8981

90-
target_link_libraries(kernel PRIVATE stdc++fs
91-
PRIVATE ${CMAKE_DL_LIBS}
82+
target_link_libraries(kernel PRIVATE ${CMAKE_DL_LIBS}
9283
PUBLIC gmp)
9384

9485
set_target_properties(kernel PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename libkernel => libmeevax
@@ -156,15 +147,20 @@ include(CPack)
156147

157148
enable_testing()
158149

150+
find_program(${PROJECT_NAME}_MEMORY_CHECK_COMMAND valgrind)
151+
152+
set(${PROJECT_NAME}_MEMORY_CHECK_COMMAND_OPTIONS --error-exitcode=1 # = EXIT_FAILURE)
153+
--leak-check=full
154+
--quiet
155+
--show-leak-kinds=all)
156+
159157
file(GLOB ${PROJECT_NAME}_TEST_SS ${CMAKE_CURRENT_SOURCE_DIR}/test/*.ss)
160158

161159
foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_SS)
162160
get_filename_component(FILENAME ${EACH} NAME_WE)
163161
add_test(NAME ${FILENAME}
164-
COMMAND valgrind --error-exitcode=1 # = EXIT_FAILURE
165-
--leak-check=full
166-
--quiet
167-
--show-leak-kinds=all
162+
COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND}
163+
${${PROJECT_NAME}_MEMORY_CHECK_COMMAND_OPTIONS}
168164
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meevax
169165
${EACH})
170166
endforeach()
@@ -176,24 +172,22 @@ foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_CPP)
176172
add_executable(assert-${FILENAME} ${EACH})
177173
target_link_libraries(assert-${FILENAME} PRIVATE kernel)
178174
add_test(NAME assert-${FILENAME}
179-
COMMAND valgrind --error-exitcode=1 # = EXIT_FAILURE
180-
--leak-check=full
181-
--quiet
182-
--show-leak-kinds=all
175+
COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND}
176+
${${PROJECT_NAME}_MEMORY_CHECK_COMMAND_OPTIONS}
183177
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assert-${FILENAME})
184178
endforeach()
185179

186180
# ---- Additional Targets ------------------------------------------------------
187181

188-
execute_process(COMMAND nproc OUTPUT_VARIABLE NPROC)
182+
execute_process(COMMAND nproc OUTPUT_VARIABLE ${PROJECT_NAME}_NPROC)
189183

190184
add_custom_target(install.deb
191-
COMMAND make -j ${NPROC}
192-
COMMAND ${CMAKE_CPACK_COMMAND}
185+
COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NPROC}
186+
COMMAND ${CMAKE_MAKE_PROGRAM} package
193187
COMMAND sudo apt install ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION}_amd64.deb)
194188

195-
add_custom_target(safe-install.deb
196-
COMMAND make -j ${NPROC}
197-
COMMAND ${CMAKE_CTEST_COMMAND} -j ${NPROC}
198-
COMMAND ${CMAKE_CPACK_COMMAND}
189+
add_custom_target(develop
190+
COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NPROC}
191+
COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NPROC}
192+
COMMAND ${CMAKE_MAKE_PROGRAM} package
199193
COMMAND sudo apt install ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION}_amd64.deb)

README.md

+53-43
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,37 @@
33
<br/>
44
<img src="https://github.com/yamacir-kit/meevax/wiki/svg/description.png" alt="A programmable programming lanugage."/>
55
</p>
6-
<hr color=#c1ab05/>
6+
<hr/>
77
<p align="center">
88
<img src="https://github.com/yamacir-kit/meevax/actions/workflows/build.yaml/badge.svg"/>
99
<img src="https://github.com/yamacir-kit/meevax/actions/workflows/release.yaml/badge.svg"/>
1010
</p>
1111
<p align="center">
12-
<b><a href="#Overview" >Overview</a></b> &nbsp;|&nbsp;
13-
<b><a href="#Requirements">Requirements</a></b> &nbsp;|&nbsp;
14-
<b><a href="#Installation">Installation</a></b> &nbsp;|&nbsp;
15-
<b><a href="#Usage">Usage</a></b> &nbsp;|&nbsp;
16-
<b><a href="#License">License</a></b> &nbsp;|&nbsp;
17-
<b><a href="#References">References</a></b>
12+
<b>
13+
<a href="#Overview">Overview</a>
14+
</b>
15+
&nbsp;|&nbsp;
16+
<b>
17+
<a href="#Installation">Installation</a>
18+
</b>
19+
&nbsp;|&nbsp;
20+
<b>
21+
<a href="#Usage">Usage</a>
22+
</b>
23+
&nbsp;|&nbsp;
24+
<b>
25+
<a href="#License">License</a>
26+
</b>
27+
&nbsp;|&nbsp;
28+
<b>
29+
<a href="#References">References</a>
30+
</b>
1831
</p>
1932

2033
## Overview
2134

2235
> Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary.
23-
> <div align="right">
24-
> Revised<sup>7</sup> Report on the Algorithmic Language Scheme [1]
25-
> </div>
36+
> <div align="right">Revised<sup>7</sup> Report on the Algorithmic Language Scheme [1]</div>
2637
2738
Meevax is an implementation of Lisp-1 programming language, supporting subset of the [Scheme](http://www.scheme-reports.org/) (R7RS) and [SRFI](https://srfi.schemers.org/)s.
2839

@@ -45,76 +56,81 @@ Subset of R7RS-small.
4556
|--------------------------------------------------------:|:-------------------------------------------------------|:------------------------------------------------------|:------------------|
4657
| [ 1](https://srfi.schemers.org/srfi-1/srfi-1.html) | List Library | [`(srfi 1)`](./basis/srfi-1.ss) | |
4758
| [ 6](https://srfi.schemers.org/srfi-6/srfi-6.html) | Basic String Ports | [`(srfi 6)`](./basis/srfi-6.ss) | R7RS 6.13 |
59+
| [ 4](https://srfi.schemers.org/srfi-4/srfi-4.html) | Homogeneous numeric vector datatypes | [`(srfi 4)`](./basis/srfi-4.ss) | R7RS 6.9 |
4860
| [ 8](https://srfi.schemers.org/srfi-8/srfi-8.html) | receive: Binding to multiple values | [`(srfi 8)`](./basis/srfi-8.ss) | |
4961
| [ 9](https://srfi.schemers.org/srfi-9/srfi-9.html) | Defining Record Types | [`(srfi 9)`](./basis/srfi-9.ss) | R7RS 5.5 |
5062
| [ 10](https://srfi.schemers.org/srfi-10/srfi-10.html) | #, external form | | |
5163
| [ 11](https://srfi.schemers.org/srfi-11/srfi-11.html) | Syntax for receiving multiple values | [`(srfi 11)`](./basis/srfi-11.ss) | R7RS 4.2.2 |
5264
| [ 23](https://srfi.schemers.org/srfi-23/srfi-23.html) | Error reporting mechanism | [`(srfi 23)`](./basis/srfi-23.ss) | R7RS 6.11 |
5365
| [ 30](https://srfi.schemers.org/srfi-30/srfi-30.html) | Nested Multi-line Comments | | R7RS 2.2 |
66+
| [ 31](https://srfi.schemers.org/srfi-31/srfi-31.html) | A special form rec for recursive evaluation | [`(srfi 31)`](./basis/srfi-31.ss) | |
5467
| [ 34](https://srfi.schemers.org/srfi-34/srfi-34.html) | Exception Handling for Programs | [`(srfi 34)`](./basis/srfi-34.ss) | R7RS 6.11 |
5568
| [ 38](https://srfi.schemers.org/srfi-38/srfi-38.html) | External Representation for Data With Shared Structure | [`(srfi 38)`](./basis/srfi-38.ss) | R7RS 6.13.3 |
5669
| [ 39](https://srfi.schemers.org/srfi-39/srfi-39.html) | Parameter objects | [`(srfi 39)`](./basis/srfi-39.ss) | R7RS 4.2.6 |
5770
| [ 45](https://srfi.schemers.org/srfi-45/srfi-45.html) | Primitives for Expressing Iterative Lazy Algorithms | [`(srfi 45)`](./basis/srfi-45.ss) | R7RS 4.2.5 |
5871
| [ 62](https://srfi.schemers.org/srfi-62/srfi-62.html) | S-expression comments | | R7RS 2.2 |
5972
| [ 78](https://srfi.schemers.org/srfi-78/srfi-78.html) | Lightweight testing | [`(srfi 78)`](./basis/srfi-78.ss) | Except `check-ec` |
6073
| [ 87](https://srfi.schemers.org/srfi-87/srfi-87.html) | => in case clauses | | R7RS 4.2.1 |
74+
| [ 98](https://srfi.schemers.org/srfi-98/srfi-98.html) | An interface to access environment variables | [`(srfi 98)`](./basis/srfi-98.ss) | R7RS 6.14 |
6175
| [149](https://srfi.schemers.org/srfi-149/srfi-149.html) | Basic syntax-rules template extensions | [`(srfi 149)`](./basis/srfi-149.ss) | R7RS 4.3.2 |
62-
| [211](https://srfi.schemers.org/srfi-211/srfi-211.html) | Scheme Macro Libraries | [`(srfi 211 explicit-renaming)`](./basis/srfi-211.ss) | |
6376

64-
## Requirements
77+
## Installation
6578

66-
### Software
79+
### Requirements
6780

6881
- [GCC](https://gcc.gnu.org/) (>= 9.4.0) or [Clang](https://clang.llvm.org/) (>= 11.0.0)
6982
- [CMake](https://cmake.org/) (>= 3.16.3)
7083
- [GNU Make](http://savannah.gnu.org/projects/make)
7184
- [GNU Binutils](https://www.gnu.org/software/binutils/)
7285
- [GNU Multiple Precision Arithmetic Library (GMP)](https://gmplib.org/)
7386

74-
To install the above software, it is easy to use the following script.
87+
### Install
7588

7689
``` bash
77-
$ ./script/setup.sh
90+
cmake -B build -DCMAKE_BUILD_TYPE=Release
91+
cd build
92+
make install.deb
7893
```
7994

80-
## Installation
81-
82-
### Install
95+
or
8396

8497
``` bash
85-
$ cmake -B build -DCMAKE_BUILD_TYPE=Release
86-
$ cd build
87-
$ make install.deb
98+
cmake -B build -DCMAKE_BUILD_TYPE=Release
99+
cd build
100+
make install
88101
```
89102

90103
### Uninstall
91104

105+
If you installed with `make install.deb`,
106+
92107
``` bash
93-
$ sudo apt remove meevax
108+
sudo apt remove meevax
109+
```
110+
111+
or if you installed with `make install`,
112+
113+
``` bash
114+
sudo rm -rf /usr/local/bin/meevax
115+
sudo rm -rf /usr/local/include/meevax
116+
sudo rm -rf /usr/local/lib/libmeevax*
117+
sudo rm -rf /usr/local/share/meevax
94118
```
95119

96120
### CMake targets
97121

98122
| Target Name | Description
99123
|--------------------|---
100-
| `all` (default) | Build shared-library `libmeevax.0.4.597.so` and executable `meevax`.
101-
| `test` | Test executable `meevax`.
102-
| `package` | Generate debian package `meevax_0.4.597_amd64.deb`.
103-
| `install` | Copy files into `/usr/local` __(1)__.
124+
| `all` (default) | Build shared-library `libmeevax.0.4.653.so` and executable `meevax`
125+
| `test` | Test executable `meevax`
126+
| `package` | Generate debian package `meevax_0.4.653_amd64.deb`
127+
| `install` | Copy files into `/usr/local`
104128
| `install.deb` | `all` + `package` + `sudo apt install <meevax>.deb`
105-
| `safe-install.deb` | `all` + `test` + `package` + `sudo apt install <meevax>.deb`
106-
107-
__(1)__ Meevax installed by `make install` cannot be uninstalled by the system's package manager (for example, `apt remove meevax`). You need to manually delete the following files to uninstall:
108-
109-
- `/usr/local/bin/meevax`
110-
- `/usr/local/include/meevax`
111-
- `/usr/local/lib/libmeevax*`
112-
- `/usr/local/share/meevax`
113129

114130
## Usage
115131

116132
```
117-
Meevax Lisp 0.4.597
133+
Meevax Lisp 0.4.653
118134
119135
Usage:
120136
meevax [option...] [file...]
@@ -129,13 +145,6 @@ Options:
129145
130146
```
131147

132-
| Example | Effects |
133-
|:-------------------------------------------|:--|
134-
| `$ meevax -i` | Start interactive session. You can exit the session by input `(exit)` or Ctrl+C or Ctrl+D.
135-
| `$ meevax foo.ss` | Evaluate a script `foo.ss`. |
136-
| `$ meevax -e '(+ 1 2 3)'` | Display `6`.
137-
| `$ meevax -e "(define home \"$HOME\")" -i` | Define value of shell-environment variable `$HOME` as string typed Scheme variable `home`, and then start interactive session on environment includes the variable `home`.
138-
139148
## License
140149

141150
See [LICENSE](./LICENSE).
@@ -146,5 +155,6 @@ See [LICENSE](./LICENSE).
146155

147156
### Resources
148157

149-
* [TinyScheme](http://tinyscheme.sourceforge.net/)
158+
* [Chibi-Scheme](https://github.com/ashinn/chibi-scheme)
150159
* [SECDR-Scheme](http://www.maroon.dti.ne.jp/nagar17/mulasame/)
160+
* [TinyScheme](http://tinyscheme.sourceforge.net/)

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.597
1+
0.4.653

basis/meevax.ss

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
(define-library (meevax macro-transformer)
2+
(import (only (meevax comparator) eq? eqv?)
3+
(only (meevax core) begin define if lambda quote set!)
4+
(only (meevax list) null?)
5+
(only (meevax macro) identifier? syntactic-closure? make-syntactic-closure)
6+
(only (meevax pair) cons car cdr caar cdar))
7+
8+
(export make-syntactic-closure
9+
identifier?
10+
identifier=?
11+
sc-macro-transformer
12+
rsc-macro-transformer
13+
er-macro-transformer)
14+
15+
(begin (define (sc-macro-transformer f)
16+
(lambda (form use-env mac-env)
17+
(make-syntactic-closure mac-env '() (f form use-env))))
18+
19+
(define (rsc-macro-transformer f)
20+
(lambda (form use-env mac-env)
21+
(make-syntactic-closure use-env '() (f form mac-env))))
22+
23+
(define (assq x alist)
24+
(if (null? alist)
25+
#f
26+
(if (eq? x (caar alist))
27+
(car alist)
28+
(assq x (cdr alist)))))
29+
30+
(define (identifier=? environment1 identifier1
31+
environment2 identifier2)
32+
(eqv? (if (syntactic-closure? identifier1) identifier1 (make-syntactic-closure environment1 '() identifier1))
33+
(if (syntactic-closure? identifier2) identifier2 (make-syntactic-closure environment2 '() identifier2))))
34+
35+
(define (er-macro-transformer f)
36+
(lambda (form use-env mac-env)
37+
(define cache '())
38+
(f form
39+
(lambda (x)
40+
((lambda (pare)
41+
(if pare
42+
(cdr pare)
43+
(begin (set! cache (cons (cons x (make-syntactic-closure mac-env '() x))
44+
cache))
45+
(cdar cache))))
46+
(assq x cache)))
47+
(lambda (x y)
48+
(identifier=? use-env x use-env y)))))))
49+
50+
(define-library (meevax continuation)
51+
(import (only (meevax context) emergency-exit)
52+
(only (meevax comparator) eq?)
53+
(only (meevax core) begin call-with-current-continuation! current define if install lambda)
54+
(only (meevax pair) caar car cdar cdr cons pair?)
55+
(only (meevax list) null?))
56+
57+
(export call-with-current-continuation dynamic-wind exit)
58+
59+
(begin (define (current-dynamic-extents)
60+
(current 0))
61+
62+
(define (install-dynamic-extents! extents)
63+
(install 0 extents))
64+
65+
(define (dynamic-wind before thunk after) ; https://www.cs.hmc.edu/~fleck/envision/scheme48/meeting/node7.html
66+
(before)
67+
(install-dynamic-extents! (cons (cons before after)
68+
(current-dynamic-extents)))
69+
((lambda (result) ; TODO let-values
70+
(install-dynamic-extents! (cdr (current-dynamic-extents)))
71+
(after)
72+
result) ; TODO (apply values result)
73+
(thunk)))
74+
75+
(define (call-with-current-continuation procedure)
76+
(define (windup! from to)
77+
(install-dynamic-extents! from)
78+
(if (eq? from to)
79+
#t
80+
(if (null? from)
81+
(begin (windup! from (cdr to))
82+
((caar to)))
83+
(if (null? to)
84+
(begin ((cdar from))
85+
(windup! (cdr from) to))
86+
(begin ((cdar from))
87+
(windup! (cdr from)
88+
(cdr to))
89+
((caar to))))))
90+
(install-dynamic-extents! to))
91+
((lambda (dynamic-extents)
92+
(call-with-current-continuation!
93+
(lambda (continue)
94+
(procedure (lambda (x)
95+
(windup! (current-dynamic-extents) dynamic-extents)
96+
(continue x))))))
97+
(current-dynamic-extents)))
98+
99+
(define (exit . xs)
100+
(letrec ((for-each (lambda (f x)
101+
(if (pair? x)
102+
(begin (f (car x))
103+
(for-each f (cdr x)))))))
104+
(for-each (lambda (before/after)
105+
((cdr before/after)))
106+
(current-dynamic-extents))
107+
(emergency-exit . xs)))))

0 commit comments

Comments
 (0)