pikachuhy / pscm Goto Github PK
View Code? Open in Web Editor NEWa scheme language implementation
Home Page: https://pscm.dev
License: MIT License
a scheme language implementation
Home Page: https://pscm.dev
License: MIT License
(letrec ((even?
(lambda (n)
(if (zero? n)
#t
(odd? (- n 1)))))
(odd?
(lambda (n)
(if (zero? n)
#f
(even? (- n 1))))))
(even? 14))
run success
(letrec ((even?
(lambda (n)
(if (zero? n)
#t
(odd? (- n 1)))))
(odd?
(lambda (n)
(if (zero? n)
#f
(even? (- n 1))))))
(even? 15))
run fail with bus error
[1] 17930 bus error node r4rs_test.js
When I compile pscm with msvc, I gathered such warning:
include\pscm/Logger.h(3): error C2010: “.”: 宏参数表中的意外
include\pscm/Logger.h(10): error C2010: “.”: 宏参数表中的意外
include\pscm/Logger.h(11): error C2010: “.”: 宏参数表中的意外
include\pscm/Logger.h(12): error C2010: “.”: 宏参数表中的意外
include\pscm/Logger.h(13): error C2010: “.”: 宏参数表中的意外
include\pscm/Logger.h(14): error C2010: “.”: 宏参数表中的意外
include\pscm/Logger.h(15): error C2010: “.”: 宏参数表中的意外
Reason of compilation failure is that macro definitions at include/pscm/Logger.h
uses non-standard syntax of variadic macro.
I note here some useful references for a scheme interpreter
环境:
日志:
CMake Error at 3rd/CMakeLists.txt:10 (target_sources):
target_sources File set TYPE may only be "HEADERS"
CMake Error at 3rd/CMakeLists.txt:15 (target_sources):
target_sources File set TYPE may only be "HEADERS"
CMake Error at 3rd/CMakeLists.txt:21 (target_sources):
target_sources File set TYPE may only be "HEADERS"
CMake Error at 3rd/CMakeLists.txt:29 (target_sources):
target_sources File set TYPE may only be "HEADERS"
CMake Error at 3rd/CMakeLists.txt:37 (target_sources):
target_sources File set TYPE may only be "HEADERS"
CMake Error at CMakeLists.txt:89 (target_sources):
target_sources File set TYPE may only be "HEADERS"
CMake Error at tool/pscm-build/src/CMakeLists.txt:8 (target_sources):
target_sources File set TYPE may only be "HEADERS"
尝试:https://stackoverflow.com/questions/75444867/cmake-target-sources-file-set-type-may-only-be-headers
option(PSCM_USE_CXX20_MODULES "enable c++20 modules" ON)
无法生效。。。
R7rs suggests that string may contain unicode characters, and builtin method of string such as (string-ci=?)
should handle i18n case mapping. So this interpreter should adjust inner encoding of String
class.
There is several suggestions and requirements for unicode string handling in scheme. R7rs does not require constant complexity of (string-set!)
and (string-ref)
, but requires index of string is index of code point. R7rs and The Scheme Programming Language does not suggest surrogate pairs in java.
Support of unicode string varies between standard library and spdlog. Standard library supports indexing on utf-32, but indexing on utf-8 and utf-16 string in standard library is byte index, rather than code point index. Standard library supports case mapping for unicode also. According to api interface of spdlog, this library may only receive utf-8 encoding message.
So I suggest to use utf-32 as encoding of strings appears in this project. Although utf-32 consumes more memory space, because character in utf-32 occupies 4 bits, it's easier than utf-8 and utf-16 to locate code point by given index.
Another choice is to use utf-8. Utf-8 consumes less space than utf-16 and utf-32, and can be scanned from start to end, therefore can be used to store scheme input code. C++ std lib lack methods to iterate codepoint from utf-8 string.
THIS IS A FEATURE REQUEST AND PROPOSAL.
In file included from /home/charon/pscm/src/Evaluator.cpp:7:
/home/charon/pscm/include/pscm/Logger.h:6:27: error: ‘fmt’ has not been declared
6 | logger_->log(level, fmt::format(format_, ##__VA_ARGS__));
\
| ^~~
/home/charon/pscm/include/pscm/Logger.h:11:34: note: in expansion of macro ‘PSCM_LOGGER_LOG’
11 | #define PSCM_ERROR(format_, ...) PSCM_LOGGER_LOG(logger_, pscm::logger::Logger::Level::ERROR_, format_, ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
/home/charon/pscm/src/Evaluator.cpp:2427:5: note: in expansion of macro ‘PSCM_ERROR’
2427 | PSCM_ERROR("load file {} error", filename);
| ^~~~~~~~~~
/home/charon/pscm/src/Evaluator.cpp: In function ‘pscm::Cell pscm::is_exact(pscm::Cell)’:
/home/charon/pscm/include/pscm/Logger.h:5:34: warning: control reaches end of non-void function [-Wreturn-type]
5 | if (logger_->is_level_enabled(level)) {
\
| ^
/home/charon/pscm/include/pscm/Logger.h:11:34: note: in expansion of macro ‘PSCM_LOGGER_LOG’
11 | #define PSCM_ERROR(format_, ...) PSCM_LOGGER_LOG(logger_, pscm::logger::Logger::Level::ERROR_, format_, ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
/home/charon/pscm/include/pscm/common_def.h:10:3: note: in expansion of macro ‘PSCM_ERROR’
10 | PSCM_ERROR("Exception occurred here: {}", msg);
\
| ^~~~~~~~~~
/home/charon/pscm/src/Evaluator.cpp:815:3: note: in expansion of macro ‘PSCM_THROW_EXCEPTION’
815 | PSCM_THROW_EXCEPTION("Wrong type argument in position 1: " + x.to_string());
| ^~~~~~~~~~~~~~~~~~~~
/home/charon/pscm/src/Evaluator.cpp: In function ‘pscm::Cell pscm::is_inexact(pscm::Cell)’:
/home/charon/pscm/include/pscm/Logger.h:5:34: warning: control reaches end of non-void function [-Wreturn-type]
5 | if (logger_->is_level_enabled(level)) {
\
| ^
/home/charon/pscm/include/pscm/Logger.h:11:34: note: in expansion of macro ‘PSCM_LOGGER_LOG’
11 | #define PSCM_ERROR(format_, ...) PSCM_LOGGER_LOG(logger_, pscm::logger::Logger::Level::ERROR_, format_, ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
/home/charon/pscm/include/pscm/common_def.h:10:3: note: in expansion of macro ‘PSCM_ERROR’
10 | PSCM_ERROR("Exception occurred here: {}", msg);
\
| ^~~~~~~~~~
/home/charon/pscm/src/Evaluator.cpp:828:3: note: in expansion of macro ‘PSCM_THROW_EXCEPTION’
828 | PSCM_THROW_EXCEPTION("Wrong type argument in position 1: " + x.to_string());
| ^~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
run command:
CXX=clang++-16 CC=clang-16 cmake -B build/ -DCMAKE_BUILD_TYPE=Release -G Ninja -DUSE_CCACHE=ON
cmake --build build/ --config Release -j --verbose
firstly i modified some CMakeLists.txt
files, from FILE_SET cxx_modules TYPE CXX_MODULES FILES
to FILE_SET cxx_modules TYPE HEADERS FILES
.
because i face error:
CMake Error at tool/pscm-build/src/CMakeLists.txt:8 (target_sources):
target_sources File set TYPE may only be "HEADERS"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.