Coder Social home page Coder Social logo

blog's People

Contributors

iffyyy avatar

Watchers

 avatar

blog's Issues

关于编译你想了解的工作方式the-super-tiny-compiler

编译器babel的重要性想必不用多说了,本文从**极小型编译器the-super-tiny-compiler**的源码开始,带你了解编译器的工作方式(源码大概只有两百多行)

  •              LISP                      C
    
  • 2 + 2 (add 2 2) add(2, 2)
  • 4 - 2 (subtract 4 2) subtract(4, 2)
  • 2 + (4 - 2) (add 2 (subtract 4 2)) add(2, subtract(4, 2))
    如上所示,该编译器的主要作用是将上面类似lisp的语言编译成类似c的语言。这种转换对于我们来说很简单,但是如何让计算机理解呢?

大多数编译器的工作主要经**过三个步骤:

  • 解析:将原始代码转化成更加抽象的代码表示形式(可以称为中间代码)
  • 转换:用这种抽象的表示来完成编译器想做的操作
  • 生成代码:把这种抽象的表示生成目标代码**

解析

转换

生成代码

参考链接:https://github.com/jamiebuilds/the-super-tiny-compiler

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.