All Projects → elvin-du → Tinyscript

elvin-du / Tinyscript

自制的一个编译器, 用于学习,完整实现了词法分析,语法分析,中间代码(SSA)生成,机器码生成,和基于寄存器的虚拟机

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Tinyscript

Umka Lang
Umka: a statically typed embeddable scripting language
Stars: ✭ 308 (+133.33%)
Mutual labels:  compiler, virtual-machine
Pl Compiler Resource
程序语言与编译技术相关资料(持续更新中)
Stars: ✭ 578 (+337.88%)
Mutual labels:  compiler, virtual-machine
Ark
ArkScript is a small, fast, functional and scripting language for C++ projects
Stars: ✭ 312 (+136.36%)
Mutual labels:  compiler, 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,802 (+2022.73%)
Mutual labels:  compiler, virtual-machine
Cymbal
Yet another Rust implementation of the Monkey language from "Writing an Interpreter in Go" and "Writing a Compiler in Go"
Stars: ✭ 49 (-62.88%)
Mutual labels:  compiler, virtual-machine
Never
Never: statically typed, embeddable functional programming language.
Stars: ✭ 248 (+87.88%)
Mutual labels:  compiler, virtual-machine
Ph7
An Embedded Implementation of PHP (C Library)
Stars: ✭ 422 (+219.7%)
Mutual labels:  compiler, virtual-machine
Cub
The Cub Programming Language
Stars: ✭ 198 (+50%)
Mutual labels:  compiler, virtual-machine
The Hack General Purpose Computer
Using HDL, from Boolean algebra and elementary logic gates to building a Central Processing Unit, a memory system, and a hardware platform, leading up to a 16-bit general-purpose computer. Then, implementing the modern software hierarchy designed to enable the translation and execution of object-based, high-level languages on a bare-bone computer hardware platform; Including Virtual machine,Compiler and Operating system.
Stars: ✭ 39 (-70.45%)
Mutual labels:  compiler, virtual-machine
Ring
Innovative and practical general-purpose multi-paradigm language
Stars: ✭ 716 (+442.42%)
Mutual labels:  compiler, virtual-machine
Swift Lispkit
Interpreter framework for Lisp-based extension and scripting languages on macOS and iOS. LispKit is based on the R7RS standard for Scheme. Its compiler generates bytecode for a virtual machine. LispKit is fully implemented in Swift 5.
Stars: ✭ 228 (+72.73%)
Mutual labels:  compiler, virtual-machine
Fanx
A portable programming language
Stars: ✭ 101 (-23.48%)
Mutual labels:  compiler, virtual-machine
Lumen
An alternative BEAM implementation, designed for WebAssembly
Stars: ✭ 2,742 (+1977.27%)
Mutual labels:  compiler, virtual-machine
Smlvm
Smallrepo Virtual Machine
Stars: ✭ 265 (+100.76%)
Mutual labels:  compiler, virtual-machine
Customasm
💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Stars: ✭ 211 (+59.85%)
Mutual labels:  compiler, virtual-machine
V8
The official mirror of the V8 Git repository
Stars: ✭ 18,808 (+14148.48%)
Mutual labels:  compiler, virtual-machine
Corewar
A reproduction of the Core War game. Assembly compiler, Virtual Machine and GUI.
Stars: ✭ 173 (+31.06%)
Mutual labels:  compiler, virtual-machine
Go.vm
A simple virtual machine - compiler & interpreter - written in golang
Stars: ✭ 178 (+34.85%)
Mutual labels:  compiler, virtual-machine
Minic Hosting
A simple stack-based virtual machine that runs C in the browser.
Stars: ✭ 628 (+375.76%)
Mutual labels:  compiler, virtual-machine
Selfie
An educational software system of a tiny self-compiling C compiler, a tiny self-executing RISC-V emulator, and a tiny self-hosting RISC-V hypervisor.
Stars: ✭ 1,318 (+898.48%)
Mutual labels:  compiler, virtual-machine

tinyscript

整个项目包括三个东西:

  1. 创建了一个自己的语言
  2. 编译器
  3. 虚拟机

golang实现的一个编译器,用来编译一个自己创建的语言(用来玩的),最后写了一个自定义虚拟机用来运行自定义语言。

语言介绍

为了跨平台(其实是为了方便开发 ^ ^),所以这个语言没有静态编译成硬件指令集,最后的机器码是我自己的定义的,和MIPS类似的(其实就是一个mips子集)虚拟指令集。为了运行这些指令集,我写了一个虚拟机。

语言和golang和javascript类似,实现了函数,类型声明,函数调用等最基本的一些语言元素,没有实现类,结构体,接口等复杂数据结构。 下面是用这个语言编程的例子:

func fact(int n)  int {
    if(n == 0) {
        return 1
    }
    return fact(n-1) * n
}
func main() void {
    return fact(2)
}

每个函数都实现了相应的UnitTest,单元测试真香~

声明:

工程思路不是我自己想出来的,来自于慕课网《大学计算机必修课新讲--编译原理+操作系统+图形学》这个课程。 理论主要是看《龙书》的一部分,《自己动手写编译器,连接器》和bilibili上的中科大华保健老师的《编译原理》和哈尔滨工业大学的《编译原理》课程的一部分。

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].