Giter Site home page Giter Site logo

pikachuhy / pscm Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 2.0 533 KB

a scheme language implementation

Home Page: https://pscm.dev

License: MIT License

CMake 2.21% C++ 77.25% C 0.84% HTML 2.41% Lua 0.60% Starlark 4.43% Scheme 10.54% Java 0.28% Objective-C 0.60% Objective-C++ 0.07% Shell 0.01% Python 0.77%
guile r5rs scheme

pscm's People

Contributors

charonxin avatar jingkaimori avatar pikachuhy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pscm's Issues

[wasm] bus error

(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

Usage of variadic macros is imcompatiable with msvc

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

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.

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Can't build

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

环境:

  • ubuntu 22.04
  • cmake 3.27.4
  • clang version 16.0.6
  • ninja version 1.10.1

日志:

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)

无法生效。。。

pscm development plan

Feature

  • r4rs support
  • Unicode support
  • Virtual Machine
  • AOT
  • JIT

Tool && Ecosystem

  • pscm build system
  • pscm language server
  • pscm debugger

Application

  • support Vau
  • support TeXmacs

Release

  • v0.2.0 almost r4rs support
  • v0.3.0 run Vau success
  • v0.4.0 unicode support
  • v0.5.0 JIT support
  • v0.6.0 language server support

[Feature Request] Unicode support for string

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

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.

Reproduction way

THIS IS A FEATURE REQUEST AND PROPOSAL.

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

A lot of error in clang-16 using cmake

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"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.