Skip to content

Commit 1b35416

Browse files
authored
Merge pull request #363 from yamacir-kit/letrec-syntax
Letrec syntax
2 parents ff7eaca + d05c742 commit 1b35416

Some content is hidden

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

43 files changed

+768
-567
lines changed

CMakeLists.txt

+5-13
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_B
3030

3131
# ---- Configure ---------------------------------------------------------------
3232

33-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/configure/README.md)
34-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/README.md
35-
${CMAKE_CURRENT_SOURCE_DIR}/README.md)
36-
endif()
37-
38-
string(TIMESTAMP ${PROJECT_NAME}_BUILD_DATE "%Y/%m/%d-%H:%M:%S")
39-
4033
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
4134
execute_process(COMMAND git rev-parse HEAD
4235
COMMAND tr -d "\n"
@@ -52,10 +45,8 @@ else()
5245
set(${PROJECT_NAME}_BYTE_ORDER "little-endian")
5346
endif()
5447

55-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/configure/version.cpp)
56-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/version.cpp
57-
${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/version.cpp)
58-
endif()
48+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/version.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/version.cpp)
49+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/README.md ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
5950

6051
# ---- Convert Basis-Library Sources to Binary ---------------------------------
6152

@@ -99,8 +90,8 @@ target_link_libraries(kernel PRIVATE stdc++fs
9990

10091
set_target_properties(
10192
kernel PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename libkernel => libmeevax
102-
VERSION ${PROJECT_VERSION}
103-
SOVERSION ${PROJECT_VERSION_MAJOR})
93+
VERSION ${PROJECT_VERSION}
94+
SOVERSION ${PROJECT_VERSION_MAJOR})
10495

10596
# ---- Target shell ------------------------------------------------------------
10697

@@ -176,6 +167,7 @@ check(chibi-basic)
176167
check(er-macro-transformer)
177168
check(internal-definition)
178169
check(let-syntax)
170+
check(letrec-syntax)
179171
check(low-level-macro-facility)
180172
check(numerical-operations)
181173
check(r4rs)

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax
100100

101101
| Target Name | Description
102102
|:-------------------|:--
103-
| `all` (default) | Build shared-library `libmeevax.0.3.727.so` and executable `meevax`.
103+
| `all` (default) | Build shared-library `libmeevax.0.3.773.so` and executable `meevax`.
104104
| `test` | Test executable `meevax`.
105-
| `package` | Generate debian package `meevax_0.3.727_amd64.deb`.
105+
| `package` | Generate debian package `meevax_0.3.773_amd64.deb`.
106106
| `install` | Copy files into `/usr/local` __(1)__.
107107
| `install.deb` | `all` + `package` + `sudo apt install <meevax>.deb`
108108
| `safe-install.deb` | `all` + `test` + `package` + `sudo apt install <meevax>.deb`
@@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's
117117
## Usage
118118

119119
```
120-
Meevax Lisp System, version 0.3.727
120+
Meevax Lisp System, version 0.3.773
121121
122122
Usage: meevax [OPTION...] [FILE...]
123123

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.727
1+
0.3.773

basis/overture.ss

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
(define fork/csc fork-with-current-syntactic-continuation)
66

7+
(define import
8+
(fork/csc
9+
(lambda (import . import-sets)
10+
(list quote (cons 'import import-sets)))))
11+
712
(define define-syntax
813
(fork/csc
914
(lambda (define-syntax keyword . transformer)
@@ -21,16 +26,10 @@
2126
(define (current-environment-specifier)
2227
(fork/csc identity))
2328

24-
(define (current-evaluator)
25-
((lambda (e)
26-
(lambda (x)
27-
(eval x e)))
28-
(current-environment-specifier)))
29-
3029
(define (er-macro-transformer transform)
3130
(fork/csc
3231
(lambda form
33-
(transform form (current-evaluator) free-identifier=?))))
32+
(transform form (lambda (x) (eval x (car form))) free-identifier=?))))
3433

3534
(define (unspecified) (if #f #f))
3635

basis/r7rs.ss

+53-39
Original file line numberDiff line numberDiff line change
@@ -111,45 +111,59 @@
111111
...
112112
(let () body1 body2 ...)))))
113113

114-
(define-syntax let-values
115-
(syntax-rules ()
116-
((let-values (binding ...) body0 body1 ...)
117-
(let-values "bind"
118-
(binding ...) () (begin body0 body1 ...)))
119-
((let-values "bind" () tmps body)
120-
(let tmps body))
121-
((let-values "bind" ((b0 e0)
122-
binding ...) tmps body)
123-
(let-values "mktmp" b0 e0 ()
124-
(binding ...) tmps body))
125-
((let-values "mktmp" () e0 args
126-
bindings tmps body)
127-
(call-with-values
128-
(lambda () e0)
129-
(lambda args
130-
(let-values "bind"
131-
bindings tmps body))))
132-
((let-values "mktmp" (a . b) e0 (arg ...)
133-
bindings (tmp ...) body)
134-
(let-values "mktmp" b e0 (arg ... x)
135-
bindings (tmp ... (a x)) body))
136-
((let-values "mktmp" a e0 (arg ...)
137-
bindings (tmp ...) body)
138-
(call-with-values
139-
(lambda () e0)
140-
(lambda (arg ... . x)
141-
(let-values "bind"
142-
bindings (tmp ... (a x)) body))))))
143-
144-
(define-syntax let*-values
145-
(syntax-rules ()
146-
((let*-values () body0 body1 ...)
147-
(let () body0 body1 ...))
148-
((let*-values (binding0 binding1 ...)
149-
body0 body1 ...)
150-
(let-values (binding0)
151-
(let*-values (binding1 ...)
152-
body0 body1 ...)))))
114+
; (define-syntax let-values
115+
; (syntax-rules ()
116+
; ((let-values (binding ...) body0 body1 ...)
117+
; (let-values "bind"
118+
; (binding ...) () (begin body0 body1 ...)))
119+
; ((let-values "bind" () tmps body)
120+
; (let tmps body))
121+
; ((let-values "bind" ((b0 e0)
122+
; binding ...) tmps body)
123+
; (let-values "mktmp" b0 e0 ()
124+
; (binding ...) tmps body))
125+
; ((let-values "mktmp" () e0 args
126+
; bindings tmps body)
127+
; (call-with-values
128+
; (lambda () e0)
129+
; (lambda args
130+
; (let-values "bind"
131+
; bindings tmps body))))
132+
; ((let-values "mktmp" (a . b) e0 (arg ...)
133+
; bindings (tmp ...) body)
134+
; (let-values "mktmp" b e0 (arg ... x)
135+
; bindings (tmp ... (a x)) body))
136+
; ((let-values "mktmp" a e0 (arg ...)
137+
; bindings (tmp ...) body)
138+
; (call-with-values
139+
; (lambda () e0)
140+
; (lambda (arg ... . x)
141+
; (let-values "bind"
142+
; bindings (tmp ... (a x)) body))))))
143+
144+
(define-syntax (let-values bindings . body)
145+
(if (null? bindings)
146+
(list let '() . body)
147+
(list call-with-values
148+
(list lambda () (cadar bindings))
149+
(list lambda (caar bindings)
150+
(list let-values (cdr bindings) . body)))))
151+
152+
; (define-syntax let*-values
153+
; (syntax-rules ()
154+
; ((let*-values () body0 body1 ...)
155+
; (let () body0 body1 ...))
156+
; ((let*-values (binding0 binding1 ...)
157+
; body0 body1 ...)
158+
; (let-values (binding0)
159+
; (let*-values (binding1 ...)
160+
; body0 body1 ...)))))
161+
162+
(define-syntax (let*-values bindings . body)
163+
(if (null? bindings)
164+
(list let '() . body)
165+
(list let-values (list (car bindings))
166+
(list let*-values (cdr bindings) . body))))
153167

154168
; ---- 4.2.3. Sequencing -------------------------------------------------------
155169

configure/version.cpp

+1-13
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ inline namespace kernel
5959
auto features() -> const_reference
6060
{
6161
let static const features = list(
62-
// STANDARD FEATURE IDENTIFIERS
6362
make<symbol>("r4rs"),
6463
make<symbol>("exact-closed"),
6564
// make<symbol>("exact-complex"),
@@ -72,18 +71,7 @@ inline namespace kernel
7271
// TODO C memory model flags.
7372
make<symbol>("${${PROJECT_NAME}_BYTE_ORDER}"),
7473
make<symbol>("${PROJECT_NAME}"), // The name of this implementation.
75-
make<symbol>("${PROJECT_NAME}-${PROJECT_VERSION}"), // The name and version of this implementation.
76-
77-
// SUPPORTED SRFIS
78-
make<symbol>("srfi-5"),
79-
make<symbol>("srfi-6"),
80-
make<symbol>("srfi-8"),
81-
make<symbol>("srfi-10"),
82-
make<symbol>("srfi-62"),
83-
make<symbol>("srfi-87"),
84-
85-
// SUPPORTED OPTIMIZATIONS
86-
make<symbol>("tail-call-optimization")
74+
make<symbol>("${PROJECT_NAME}-${PROJECT_VERSION}") // The name and version of this implementation.
8775
);
8876

8977
return features;

include/meevax/iostream/write.hpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2018-2021 Tatsuya Yamasaki.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#ifndef INCLUDED_MEEVAX_IOSTREAM_WRITE_HPP
18+
#define INCLUDED_MEEVAX_IOSTREAM_WRITE_HPP
19+
20+
#include <iostream>
21+
22+
namespace meevax
23+
{
24+
inline namespace iostream
25+
{
26+
struct write
27+
{
28+
template <typename... Ts>
29+
constexpr auto operator ()(std::ostream & os, Ts&&... xs) const -> std::ostream &
30+
{
31+
return (os << ... << xs);
32+
}
33+
};
34+
} // namespace iostream
35+
} // namespace meevax
36+
37+
#endif // INCLUDED_MEEVAX_IOSTREAM_WRITE_HPP

include/meevax/kernel/closure.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ inline namespace kernel
2727
: public virtual pair
2828
{
2929
using pair::pair;
30+
31+
auto c() const -> const_reference;
32+
33+
auto e() const -> const_reference;
3034
};
3135

3236
auto operator <<(std::ostream &, closure const&) -> std::ostream &;

include/meevax/kernel/configurator.hpp

+1-20
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ inline namespace kernel
140140
std::make_pair("version", [this](auto&&...) -> object
141141
{
142142
display_version();
143-
print();
144-
display_license();
145143
throw exit_status::success;
146144
}),
147145
}
@@ -269,24 +267,7 @@ inline namespace kernel
269267

270268
auto display_version() const -> void
271269
{
272-
print("Meevax Lisp System, version ", version());
273-
}
274-
275-
auto display_license() const -> void
276-
{
277-
print(" Copyright 2018-2021 Tatsuya Yamasaki.");
278-
print();
279-
print(" Licensed under the Apache License, Version 2.0 (the \"License\");");
280-
print(" you may not use this file except in compliance with the License.");
281-
print(" You may obtain a copy of the License at");
282-
print();
283-
print(" http://www.apache.org/licenses/LICENSE-2.0");
284-
print();
285-
print(" Unless required by applicable law or agreed to in writing, software");
286-
print(" distributed under the License is distributed on an \"AS IS\" BASIS,");
287-
print(" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
288-
print(" See the License for the specific language governing permissions and");
289-
print(" limitations under the License.");
270+
print("Meevax Lisp ", version());
290271
}
291272

292273
auto display_help() const -> void

include/meevax/kernel/environment.hpp

+10-26
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,9 @@ inline namespace kernel
3232
, public reader <environment>
3333
, public writer <environment>
3434
{
35-
/* ---- NOTE ---------------------------------------------------------------
36-
*
37-
* If this class is constructed as make<environment>(...) then the
38-
* heterogeneous::binder will have forwarded all constructor arguments to
39-
* the virtual base class pair in advance, and this constructor will be
40-
* called without any arguments.
41-
*
42-
* (See the heterogeneous::binder::binder for details)
43-
*
44-
* ---------------------------------------------------------------------- */
4535
using pair::pair;
4636

4737
public:
48-
let datum = unit;
49-
5038
using configurator::is_debug_mode;
5139
using configurator::is_trace_mode;
5240
using configurator::is_verbose_mode;
@@ -68,10 +56,6 @@ inline namespace kernel
6856

6957
auto operator [](std::string const&) -> const_reference;
7058

71-
auto build(continuation const&) -> void; // NOTE: Only fork() may call this function.
72-
73-
auto current_expression() const -> const_reference;
74-
7559
auto define(const_reference, const_reference) -> const_reference;
7660

7761
auto define(std::string const&, const_reference) -> const_reference;
@@ -82,36 +66,36 @@ inline namespace kernel
8266
return define(intern(name), make<T>(name, std::forward<decltype(xs)>(xs)...));
8367
}
8468

85-
auto dynamic_environment() const -> const_reference;
86-
8769
auto evaluate(const_reference) -> object;
8870

8971
auto execute() -> object;
9072

91-
auto form() noexcept -> reference;
92-
auto form() const noexcept -> const_reference;
73+
auto global() noexcept -> reference;
9374

94-
auto global() noexcept -> reference;
9575
auto global() const noexcept -> const_reference;
9676

97-
auto import() -> void;
98-
9977
template <typename T>
10078
auto import(T) -> void;
10179

80+
auto import() -> void;
81+
10282
auto load(std::string const&) -> object;
10383

10484
auto load(const_reference) -> object;
10585

106-
auto macroexpand(const_reference, const_reference) -> object;
86+
auto rename(const_reference) -> const_reference;
87+
88+
auto rename(const_reference, const_reference) -> object;
10789

108-
auto rename(const_reference) -> const_reference;
10990
auto rename(const_reference) const -> const_reference;
91+
92+
auto rename(const_reference, const_reference) const -> object;
11093
};
11194

11295
auto operator >>(std::istream &, environment &) -> std::istream &;
11396

114-
auto operator <<(std::ostream &, environment &) -> std::ostream &;
97+
auto operator <<(std::ostream &, environment &) -> std::ostream &;
98+
11599
auto operator <<(std::ostream &, environment const&) -> std::ostream &;
116100

117101
extern template class configurator<environment>;

0 commit comments

Comments
 (0)