All Projects → bd4sur → Animach

bd4sur / Animach

Licence: MIT license
Scheme语言实现和运行时环境 / A Scheme runtime & implementation

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
scheme
763 projects
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to Animach

clox
A virtual machine and a tree-walk interpreter for the Lox programming language in C89 🌀
Stars: ✭ 38 (-15.56%)
Mutual labels:  vm, interpreter, virtual-machine
RISVM
A low overhead, embeddable bytecode virtual machine in C++
Stars: ✭ 21 (-53.33%)
Mutual labels:  vm, interpreter, virtual-machine
Tagha
Minimal, low-level, fast, and self-contained register-based bytecode virtual machine/runtime environment.
Stars: ✭ 101 (+124.44%)
Mutual labels:  vm, interpreter, virtual-machine
Quickjs
The official repo is at bellard/quickjs.
Stars: ✭ 1,429 (+3075.56%)
Mutual labels:  vm, interpreter, virtual-machine
RSqueak
A Squeak/Smalltalk VM written in RPython.
Stars: ✭ 78 (+73.33%)
Mutual labels:  vm, interpreter, virtual-machine
lunatic
lunatic: a toy lua interpreter
Stars: ✭ 16 (-64.44%)
Mutual labels:  interpreter, virtual-machine
JSchemeMin
A small scheme implementation in java
Stars: ✭ 22 (-51.11%)
Mutual labels:  interpreter, scheme-interpreter
AlchemyVM
WebAssembly Virtual Machine Built In Elixir
Stars: ✭ 184 (+308.89%)
Mutual labels:  vm, interpreter
c8c
The chip8 compiler, assembler, and virtual machine
Stars: ✭ 110 (+144.44%)
Mutual labels:  vm, virtual-machine
ciao
Ciao is a modern Prolog implementation that builds up from a logic-based simple kernel designed to be portable, extensible, and modular.
Stars: ✭ 190 (+322.22%)
Mutual labels:  interpreter, virtual-machine
compiler-tutorial
Incremental Compiler paper by Abdulaziz Ghuloum, using Chez scheme, Nasm, x86_64 for OSX
Stars: ✭ 41 (-8.89%)
Mutual labels:  scheme-interpreter, scheme-compiler
butterfly
Butterfly connects Virtual Machines and control their traffic flow
Stars: ✭ 48 (+6.67%)
Mutual labels:  vm, virtual-machine
embed
An embeddable, tiny Forth interpreter with metacompiler.
Stars: ✭ 80 (+77.78%)
Mutual labels:  interpreter, virtual-machine
specter
a (tiny) VM project built with Go
Stars: ✭ 57 (+26.67%)
Mutual labels:  vm, virtual-machine
quickjs-build
Build for QuickJS JavaScript Engine
Stars: ✭ 25 (-44.44%)
Mutual labels:  vm, interpreter
Laythe
A gradually typed language originally based on the crafting interpreters series
Stars: ✭ 58 (+28.89%)
Mutual labels:  interpreter, virtual-machine
openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,973 (+6506.67%)
Mutual labels:  interpreter, virtual-machine
minima
A fast, byte-code interpreted language
Stars: ✭ 43 (-4.44%)
Mutual labels:  interpreter, virtual-machine
thislang
A subset of javascript implemented in that subset of javascript. Yes, it can run itself.
Stars: ✭ 31 (-31.11%)
Mutual labels:  interpreter, virtual-machine
clover2
Clover2 can be used as shell. The completion is powerfull like IDE. Also clover2 is a Ruby-like compiler language with static type like Java. This is high performnace. Please see the wiki for details
Stars: ✭ 100 (+122.22%)
Mutual labels:  interpreter, virtual-machine

Animach / 灵机

版本 0.1.0

Animach是一款Scheme语言实现,能够将Scheme编译为中间语言代码,并且在虚拟机上执行中间语言代码。Animach基于Node.js开发,你可以使用JavaScript或者TypeScript编写“本地函数库”,以扩展Animach的功能。

使用方法

依赖项:

  • Node.js v10+

执行以下命令,以启动Animach。

node ./source/animach.js [Options] [Path]

启动选项:

  • repl或留空:REPL(交互式解释器)
  • run [Path]:执行[Path]处的Scheme源代码。
  • test:执行测试用例。
  • debug:启动调试服务器。

系统架构

System Architecture

特性

Scheme语言特性

  • 支持Scheme核心子集,包括作为值的函数、词法作用域和列表操作。
  • 支持一等续延(continuation)和call/cc
  • 暂不支持卫生宏和模式匹配。
  • 支持模块化开发,可检测并管理模块间依赖关系。

运行时系统

  • Scheme代码将被编译为中间语言代码,在基于栈的虚拟机上运行。
  • 基于标记-清除算法的垃圾回收。
  • 支持虚拟机层次上的多进程。支持“端口”机制以实现进程间通信。

标准库和可扩展性

  • 通过模块机制,提供基本的函数库,称为标准库。
  • 提供类似于JNI的本地接口机制,可以使用TypeScript/JavaScript编写供Scheme代码调用的Native库,实现Animach与宿主环境(Node.js)的互操作,例如文件读写、网络收发等。
  • 不打算完全严格遵守R5RS标准,将按个人需要实现若干标准库函数。

计划实现的特性和功能

Features Priority Status
可视化调试工具 ★★★ 开发中
卫生宏和模式匹配 ★★★ 研究中
字符串模板和正则表达式 ★★★ 开发中
完善设计文档和用户手册 ★★☆ 开发中
数值类型塔(数学库) ★★☆ 计划中
Canvas/SVG图形库 ★★☆ 计划中
RnRS尽量兼容 ★☆☆ 研究中
持续集成和自动化测试 ★☆☆ 计划中
较高级的编译优化 ★☆☆ 计划中
用C语言重构VM ★☆☆ 开发中
自动CPST&自动柯里化 ★☆☆ 计划中
类型系统 ★☆☆ 计划中

开发目标

  • 通过持续改进,打造成一套个人自用的脚本工具。
  • 学习研究目的。

示例

词法作用域

(define free 100)

(define foo
  (lambda () free))

(define bar
  (lambda (free)
    (foo)))

(display (bar 200))
;; 输出100,而不是200

函数作为一等公民

(define eval
  (lambda (f a b)
    (f a b)))

(display (eval * 30 40)) ; 1200
(display (eval (lambda (x y) (/ (+ x y) 2)) 30 40)) ; 35

列表操作

(define hello '(hello aurora scheme))

(define iterate
  (lambda (lst)
    (if (null? lst)
        #f
        {
            (display (car lst))
            (iterate (cdr lst))
        })))

(iterate hello) ; hello aurora scheme

续延和call/cc

;; Yin-yang puzzle
;; see https://en.wikipedia.org/wiki/Call-with-current-continuation

(((lambda (x) (begin (display "@") x)) (call/cc (lambda (k) k)))
 ((lambda (x) (begin (display "*") x)) (call/cc (lambda (k) k))))

; @*@**@***@**** ...

更多测试用例,请参考/testcase

形式语法(BNF表示)

    <SourceCode> ::= (lambda () <TERM>*) CRLF
          <Term> ::= <SList> | <Lambda> | <Quote> | <Unquote> | <Quasiquote> | <Symbol>
         <SList> ::= ( <SListSeq> )
      <SListSeq> ::= <Term> <SListSeq> | ε
        <Lambda> ::= ( lambda <ArgList> <Body> )
       <ArgList> ::= ( <ArgListSeq> )
    <ArgListSeq> ::= <ArgSymbol> <ArgListSeq> | ε
     <ArgSymbol> ::= <Symbol>
          <Body> ::= <BodyTerm> <Body_>
         <Body_> ::= <BodyTerm> <Body_> | ε
      <BodyTerm> ::= <Term>
         <Quote> ::= ' <QuoteTerm> | ( quote <QuoteTerm> )
       <Unquote> ::= , <UnquoteTerm> | ( unquote <QuoteTerm> )
    <Quasiquote> ::= ` <QuasiquoteTerm> | ( quasiquote <QuoteTerm> )
     <QuoteTerm> ::= <Term>
   <UnquoteTerm> ::= <Term>
<QuasiquoteTerm> ::= <Term>
        <Symbol> ::= SYMBOL

关于名称

Animach,是自创的合成词,由拉丁语词汇Anima“灵魂”和Machina“机器”缩合而成,寓意“有灵魂的机器”。汉语名称为“灵机”,从“灵机一动”而来,也暗示本系统与图灵机的计算能力等价。

权利声明 / Licence

版权所有 © 2019~2022 BD4SUR,保留所有权利。

采用MIT协议授权。

本系统为个人以学习和自用目的所创作的作品。作者不对此系统的质量作任何承诺,不保证提供任何形式的解释、维护或支持,也不为任何人使用此系统所造成的任何正面的或负面的后果负责。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].