Code Monkey home page Code Monkey logo

ugo-compiler-book's Introduction

ugo-compiler-book: 从头开发一个迷你Go语言

本书尝试以实现 µGo 编译器为线索,尝试以边学习边完善的自举方式开发一个玩具语言。

µGo 介绍

µGo 是迷你Go语言玩具版本,只保留最基本的int数据类型、变量定义和函数、分支和循环等最基本的特性。µGo 有以下的关键字:varfuncifforreturn。此外有一个int内置的数据类型,func input() int 函数读取一个整数,println(...) 打印函数。

比如计算1到100的和对应以下代码:

func main() {
	var sum int
	for i := 0; i <= 100; i = i+1 {
		sum = sum+1
	}
	println(sum)
}

µGo 的具体定义会根据需要和实现的情况调整,目前可以将其作为Go的最小子集就可。

输出的目标格式

因为是编译器,最终会输出可执行程序。包括以下几种并列的目标:X64汇编、LLVM汇编、WASM文件(后续或许会考虑输出 AArch64 汇编)。

凹坑的起因

  • 因为坑就在那里
  • 不希望被Rxxx语言把脸摁在地上摩擦
  • 凹坑的工具差不多齐全了

ugo-compiler-book's People

Contributors

chai2010 avatar

Watchers

 avatar

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.