Skip to content

Commit

Permalink
Merge pull request #461 from yamacir-kit/release-candidate
Browse files Browse the repository at this point in the history
Release candidate
  • Loading branch information
yamacir-kit authored Oct 1, 2023
2 parents 0818cfa + 4a196dc commit 0a079aa
Show file tree
Hide file tree
Showing 61 changed files with 37,662 additions and 2,481 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
src/kernel/basis.cpp
include/meevax/basis
include/meevax/unicode
src/kernel/version.cpp
71 changes: 44 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ project(meevax DESCRIPTION "A programmable programming language"
LANGUAGES CXX
VERSION ${CURRENT_VERSION})

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_VERBOSE_MAKEFILE OFF)
include(GNUInstallDirs)

string(JOIN " " AGGRESSIVE_OPTIMIZATION_OPTIONS
# "-flto" # This optimization causes a SEGV when compiling with Clang 10.
Expand All @@ -23,17 +19,18 @@ string(JOIN " " AGGRESSIVE_OPTIMIZATION_OPTIONS
# "-mtune=native"
)

# NOTE: The `-gdwarf-4` option is set due to the following issues with Clang 14 and Valgrind versions below 3.20: https://bugzilla.mozilla.org/show_bug.cgi?id=1758782
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -gdwarf-4")
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_DEBUG "-Og -gdwarf-4") # NOTE: The `-gdwarf-4` option is set due to the following issues with Clang 14 and Valgrind versions below 3.20: https://bugzilla.mozilla.org/show_bug.cgi?id=1758782
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gdwarf-4 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${AGGRESSIVE_OPTIMIZATION_OPTIONS}")

include(GNUInstallDirs)

set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gdwarf-4 -DNDEBUG")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
set(CMAKE_VERBOSE_MAKEFILE OFF)

# ---- Configure ---------------------------------------------------------------

Expand All @@ -47,27 +44,28 @@ else()
set(${PROJECT_NAME}_BYTE_ORDER "little-endian")
endif()

file(READ ${CMAKE_CURRENT_SOURCE_DIR}/configure/help.txt ${PROJECT_NAME}_HELP_UNCONFIGURED)
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/script/unicode.sh --digit-value OUTPUT_VARIABLE ${PROJECT_NAME}_UNICODE_DIGIT_VALUE)
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/script/unicode.sh --downcase OUTPUT_VARIABLE ${PROJECT_NAME}_UNICODE_DOWNCASE)
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/script/unicode.sh --property OUTPUT_VARIABLE ${PROJECT_NAME}_UNICODE_PROPERTY)
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/script/unicode.sh --upcase OUTPUT_VARIABLE ${PROJECT_NAME}_UNICODE_UPCASE)

execute_process(
COMMAND head -c -1 ${CMAKE_CURRENT_SOURCE_DIR}/configure/help.txt
OUTPUT_VARIABLE ${PROJECT_NAME}_HELP)

string(CONFIGURE ${${PROJECT_NAME}_HELP_UNCONFIGURED} ${PROJECT_NAME}_HELP)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/unicode/digit_value.hpp "${${PROJECT_NAME}_UNICODE_DIGIT_VALUE}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/unicode/downcase.hpp "${${PROJECT_NAME}_UNICODE_DOWNCASE}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/unicode/property.hpp "${${PROJECT_NAME}_UNICODE_PROPERTY}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/unicode/upcase.hpp "${${PROJECT_NAME}_UNICODE_UPCASE}")

string(TOLOWER ${CMAKE_SYSTEM_NAME} ${PROJECT_NAME}_SYSTEM_NAME)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/version.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/version.cpp)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/README.md ${CMAKE_CURRENT_SOURCE_DIR}/README.md)

file(GLOB ${PROJECT_NAME}_BASIS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/basis/*.ss)

foreach(EACH IN LISTS ${PROJECT_NAME}_BASIS_SOURCES)
get_filename_component(FILENAME ${EACH} NAME)
file(READ ${EACH} ${PROJECT_NAME}_BASIS_${FILENAME})
endforeach()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/basis.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/basis.cpp)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/version.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/version.cpp)

# ---- Target kernel -----------------------------------------------------------

add_library(kernel SHARED "")
add_library(kernel SHARED)

add_library(${PROJECT_NAME}::kernel ALIAS kernel)

Expand All @@ -87,9 +85,27 @@ set_target_properties(kernel PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename lib
SOVERSION ${PROJECT_VERSION_MAJOR}
LINK_FLAGS_RELEASE -s)

# ---- Target format -----------------------------------------------------------

add_executable(format)

target_sources(format PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/format.cpp)

target_link_libraries(format PRIVATE kernel)

# ---- Target basis ------------------------------------------------------------

add_custom_target(basis
DEPENDS format
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/basis/configure.cmake)

# ---- Target shell ------------------------------------------------------------

add_executable(shell ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)
add_executable(shell)

add_dependencies(shell basis)

target_sources(shell PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)

target_link_libraries(shell PRIVATE kernel)

Expand Down Expand Up @@ -169,6 +185,7 @@ file(GLOB ${PROJECT_NAME}_TEST_CPP ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp)
foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_CPP)
get_filename_component(FILENAME ${EACH} NAME_WE)
add_executable(assert-${FILENAME} ${EACH})
add_dependencies(assert-${FILENAME} basis)
target_link_libraries(assert-${FILENAME} PRIVATE kernel)
add_test(NAME assert-${FILENAME}
COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND}
Expand All @@ -184,4 +201,4 @@ add_custom_target(develop
COMMAND ${CMAKE_MAKE_PROGRAM} -j${${PROJECT_NAME}_NPROC}
COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS=-j${${PROJECT_NAME}_NPROC}
COMMAND ${CMAKE_MAKE_PROGRAM} package
COMMAND sudo apt install ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION}_amd64.deb)
COMMAND sudo dpkg -i ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION}_amd64.deb)
112 changes: 71 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,60 @@
<p align="center">
<img src="https://github.com/yamacir-kit/meevax/wiki/svg/meevax-logo.v9.png" alt="Meevax Lisp System"/>
<br/>
<img src="https://github.com/yamacir-kit/meevax/wiki/svg/description.png" alt="A programmable programming lanugage."/>
</p>

## Overview

> 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.
> <div align="right">
> Revised<sup>7</sup> Report on the Algorithmic Language Scheme [1]
> </div>
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.
> <div align="right">Revised<sup>7</sup> Report on the Algorithmic Language Scheme</div>
Meevax is an implementation of Lisp-1 programming language, supporting the
latest [Scheme](http://www.scheme-reports.org/) language standard and some
[SRFI](https://srfi.schemers.org/)s (SRFI; Scheme requests for implementation).
This implementation is focused on integration with modern C++ and practicality:
it not only works as an interpreter with support for the latest Scheme
standard, but also provides a flexible Lisp-1 kernel as a C++ library. The
library is installed as a CMake package for [easy
linking](./example/CMakeLists.txt), and [any C++ classes can be used from
Lisp-1 scripts](./example/example.ss) [via simple stubs](example/example.cpp).

However, as the major version indicates, this implementation is still in its
infancy. Its performance is significantly inferior to that of common Scheme
implementations. For example, in a microbenchmark comparison with Chibi Scheme,
which can be embedded into C, Meevax takes more than 40x longer to compute than
Chibi Scheme. We will try to improve the performance in future development, but
we do not recommend using Meevax for anything other than toy programs, at least
at this time.

### Releases

Latest release is [here](https://github.com/yamacir-kit/meevax/releases).

### Features

- Architecture - SECD machine.
- Modern C++ compatible dynamic typing - Meevax provides RTTI-based language
runtime library.
- Traditional SECD machine [[Landin 1964](#Landin-1964)].
- Low-level hygienic macro system, known as *syntactic closures* [[Bawden and
Rees 1988](#Bawden-and-Rees-1988); [Hanson 1991](#Hanson-1991)] and *explicit
renaming* [[Clinger 1991](#Clinger-1991)]. For these, the well-known macro
transformers `sc-macro-transformer`, `rsc-macro-transformer`, and
`er-macro-transformer` from the library [`(meevax
macro-transformer)`](./basis/meevax.ss) are provided. Note that these are
non-Scheme standards.
- C++ friendly precise garbage collection [[Kempf 2001a](#Kempf-2001a); [Kempf
2001b](#Kempf-2001b)]

### Standards

Subset of R7RS-small.
Meevax can be used as an interpreter that supports the Scheme standard specified by the following report:

- Revised<sup>4</sup> Report on the Algorithmic Language Scheme (R4RS) [[Clinger and Rees 1991a](#Clinger-and-Rees-1991a)]
- Revised<sup>5</sup> Report on the Algorithmic Language Scheme (R5RS) [[Kelsey, Clinger and Rees 1998](#Kelsey-Clinger-and-Rees-1998)]
- Revised<sup>7</sup> Report on the Algorithmic Language Scheme (R7RS) [[Shinn, Cowan and Glecker 2013](#Shinn-Cowan-and-Glecker-2013)]

Procedures for each standard are provided by the following R7RS-style libraries:

| Language | Library name |
|:--------:|--------------|
| R4RS | [`(scheme r4rs)`](./basis/r4rs.ss)
| R5RS | [`(scheme r5rs)`](./basis/r5rs.ss)
| R7RS | [`(scheme base)`](./basis/r7rs.ss) [`(scheme case-lambda)`](./basis/r7rs.ss) [`(scheme char)`](./basis/r7rs.ss) [`(scheme complex)`](./basis/r7rs.ss) [`(scheme cxr)`](./basis/r7rs.ss) [`(scheme eval)`](./basis/r7rs.ss) [`(scheme file)`](./basis/r7rs.ss) [`(scheme inexact)`](./basis/r7rs.ss) [`(scheme lazy)`](./basis/r7rs.ss) [`(scheme load)`](./basis/r7rs.ss) [`(scheme process-context)`](./basis/r7rs.ss) [`(scheme read)`](./basis/r7rs.ss) [`(scheme repl)`](./basis/r7rs.ss) [`(scheme time)`](./basis/r7rs.ss) [`(scheme write)`](./basis/r7rs.ss) [`(scheme r5rs)`](./basis/r5rs.ss)

### SRFIs

Expand Down Expand Up @@ -74,7 +99,7 @@ Subset of R7RS-small.
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.4.779_amd64.deb
sudo apt install build/meevax_0.5.0_amd64.deb
```

or
Expand Down Expand Up @@ -104,29 +129,26 @@ sudo rm -rf /usr/local/share/meevax

### CMake targets

| Target Name | Description
|-----------------|-------------
| `all` (default) | Build shared-library `libmeevax.0.4.779.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.4.779_amd64.deb`
| `install` | Copy files into `/usr/local` directly
| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.0.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.0_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage

```
Meevax Lisp 0.4.779
Usage:
meevax [option...] [file...]
meevax [OPTION...] [FILE...]
Options:
-e, --evaluate=<string> read and evaluate <string> on interaction-environment
-h, --help display this help and exit
-i, --interactive enter an interactive session
-l, --load=<file> load <file> into interaction-environment
-v, --version display version information and exit
-w, --write=<string> same as `(write (read <string>))`
-e, --evaluate=STRING read and evaluate STRING on interaction-environment
-h, --help display this help and exit
-i, --interactive enter an interactive session
-l, --load=FILE load FILE into interaction-environment
-v, --version display version information and exit
-w, --write=STRING same as `(write (read STRING))`
```

## License
Expand All @@ -135,10 +157,18 @@ See [LICENSE](./LICENSE).

## References

- [1] A.shinn, J.Cowan, A. A. Greckler, editors, "[Revised<sup>7</sup> Report on the Algorithmic Language Scheme](https://bitbucket.org/cowan/r7rs/raw/tip/rnrs/r7rs.pdf)", Technical report, 2013.

### Resources

* [Chibi-Scheme](https://github.com/ashinn/chibi-scheme)
* [SECDR-Scheme](http://www.maroon.dti.ne.jp/nagar17/mulasame/)
* [TinyScheme](http://tinyscheme.sourceforge.net/)
| Authors | Year | Title | Journal Title / Publisher | Pages |
|-------------------------------------------------------------------------------------------------------|:----:|-------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|----------------|
| <a id="McCarthy-1960" ></a> John McCarthy | 1960 | [Recursive functions of symbolic expressions and their computation by machine, Part I](https://dl.acm.org/doi/10.1145/367177.367199) | [Communications of the ACM, Volume 3, Issue 4](https://dl.acm.org/toc/cacm/1960/3/4) | 184&#x2011;195 |
| <a id="Landin-1964" ></a> P. J. Landin | 1964 | [The Mechanical Evaluation of Expressions](https://academic.oup.com/comjnl/article/6/4/308/375725) | [The Computor Journal, Volume 6, Issue 4](https://academic.oup.com/comjnl/issue/6/4) | 308&#x2011;320 |
| <a id="Henderson-1980" ></a> Peter Henderson | 1980 | [Functional Programming: Application and Implementation](https://archive.org/details/functionalprogra0000hend/mode/2up) | Prentice Hall | |
| <a id="Bawden-and-Rees-1988" ></a> Alan Bawden and Jonathan Rees | 1988 | [Syntactic Closures](https://dl.acm.org/doi/10.1145/62678.62687) | [LFP '88: Proceedings of the 1988 ACM Conference on LISP and Functional Programming](https://dl.acm.org/doi/proceedings/10.1145/62678) | 86&#x2011;95 |
| <a id="Clinger-and-Rees-1991a" ></a> William Clinger and Jonathan Rees (Editors) | 1991 | [Revised<sup>4</sup> Report on the Algorithmic Language Scheme](https://dl.acm.org/doi/10.1145/382130.382133) | [ACM SIGPLAN LISP Pointers, Volume IV, Issue 3](https://dl.acm.org/toc/sigplan-lisppointers/1991/IV/3) | 1&#x2011;55 |
| <a id="Hanson-1991" ></a> Chris Hanson | 1991 | [A Syntactic Closures Macro Facility](https://dl.acm.org/doi/10.1145/1317265.1317267) | [ACM SIGPLAN LISP Pointers, Volume IV, Issue 4](https://dl.acm.org/toc/sigplan-lisppointers/1991/IV/4) | 9&#x2011;16 |
| <a id="Clinger-1991" ></a> William Clinger | 1991 | [Hygienic Macros Through Explicit Renaming](https://dl.acm.org/doi/10.1145/1317265.1317269) | [ACM SIGPLAN LISP Pointers, Volume IV, Issue 4](https://dl.acm.org/toc/sigplan-lisppointers/1991/IV/4) | 25&#x2011;28 |
| <a id="Clinger-and-Rees-1991b" ></a> William Clinger and Jonathan Rees | 1991 | [Macros That Work](https://dl.acm.org/doi/10.1145/99583.99607) | [POPL '91: Proceedings of the 18th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages](https://dl.acm.org/doi/proceedings/10.1145/99583) | 155&#x2011;162 |
| <a id="Kelsey-Clinger-and-Rees-1998"></a> Rechard Kelsey, William Clinger and Jonathan Rees (Editors) | 1998 | [Revised<sup>5</sup> Report on the Algorithmic Language Scheme](https://dl.acm.org/doi/10.1145/290229.290234) | [ACM SIGPLAN Notices, Volume 33, Issue 9](https://dl.acm.org/toc/sigplan/1998/33/9) | 26&#x2011;76 |
| <a id="Kempf-2001a" ></a> William E. Kempf | 2001 | [A garbage collection framework for C++](https://www.codeproject.com/Articles/912/A-garbage-collection-framework-for-C) | https://www.codeproject.com/Articles/912/A-garbage-collection-framework-for-C | |
| <a id="Kempf-2001b" ></a> William E. Kempf | 2001 | [A garbage collection framework for C++ - Part II](https://www.codeproject.com/Articles/938/A-garbage-collection-framework-for-C-Part-II) | https://www.codeproject.com/Articles/938/A-garbage-collection-framework-for-C-Part-II | |
| <a id="Adams-and-Dybvig-2008" ></a> Michael D. Adams and R. Kent Dybvig | 2008 | [Efficient Nondestructive Equality Checking for Trees and Graphs](https://dl.acm.org/doi/10.1145/1411204.1411230) | [ICFP '08: Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming](https://dl.acm.org/doi/proceedings/10.1145/1411204) | 179&#x2011;188 |
| <a id="Shinn-Cowan-and-Glecker-2013"></a> Alex Shinn, John Cowan and Arthur A. Gleckler (Editors) | 2013 | [Revised<sup>7</sup> Report on the Algorithmic Language Scheme](https://standards.scheme.org/official/r7rs.pdf) | http://www.scheme-reports.org/ | |
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.779
0.5.0
17 changes: 17 additions & 0 deletions basis/configure.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
execute_process(
COMMAND git rev-parse --show-toplevel
COMMAND tr -d "\n"
OUTPUT_VARIABLE TOPLEVEL)

file(GLOB ${PROJECT_NAME}_BASIS_SOURCES ${TOPLEVEL}/basis/*.ss)

foreach(EACH IN LISTS ${PROJECT_NAME}_BASIS_SOURCES)
get_filename_component(FILENAME ${EACH} NAME)
execute_process(
COMMAND ${TOPLEVEL}/build/bin/format ${EACH}
OUTPUT_VARIABLE CONFIGURED_${FILENAME})
endforeach()

configure_file(
${TOPLEVEL}/configure/basis.hpp
${TOPLEVEL}/include/meevax/basis/scheme.hpp)
Loading

0 comments on commit 0a079aa

Please sign in to comment.