分享

Scirpus(Cirru -> ES6 AST) 

 quasiceo 2018-01-19

编程语言的执行

解释执行 https://github.com/coffee-js/languages/wiki/简化的解释器入门和编程语言了解
Machine Code http://en./wiki/Compiled_language

中间语言

JVM http://en./wiki/List_of_JVM_languages
CLI http://en./wiki/List_of_CLI_languages
Parrot http://trac./parrot/wiki/Languages
JavaScript https://github.com/jashkenas/coffeescript/wiki/List-of-languages-that-...
LLVM(个人收集) http://segmentfault.com/a/1190000002639770


解释执行

代码 -> 语法树 -> 遍历语法树

(define a 1)
(print a)
(define (f a)
  (set a (+ a 1)))
  (return a)
(print (f a))

解析成 JSON:

[
  ["define", "a", "1"],
  ["print", "a"],
  ["define",
    ["f", "a"],
    ["set", "a", ["+", "a", "1"]],
    ["return", "a"]
  ],
  ["print", ["f", "a"]]
]

递归执行过程: eval(ast, env)


编译执行

类似解释执行, 但是输出结果是代码
对比生成 HTML, 动态生成 DOM, 静态编译 js 模版

Assembly
JVM Bytecode
LLVM IR (Intermediate Representation) http://www./llvm/#llvm-introduction
Parrot VM
JavaScript
C


Cirru

直接生成(编辑)语法树, 没有明确语法

Parser: https://github.com/Cirru/cirru-parser
Editor: https://github.com/Cirru/cirru-editor
Writer: http://github.com/Cirru/cirru-writer

https://github.com/Cirru/cirru-mustache
https://github.com/Cirru/cirru-html
https://github.com/Cirru/cirru-html-js
https://github.com/Cirru/cirru-json
https://github.com/Cirru/cirru-script


CirruScript

用 Cirru 语法生成 JavaScript

http://repo./script/index.html
https://github.com/Cirru/script-console

--- JavaScript as IR

Mozilla JavaScript AST

https://github.com/estree/estree/blob/master/spec.md
https:///constellation/escodegen-and-esmangle-using-moz...
http:///demo/parse.html

CoffeeScript2 -> CoffeeScript AST -> JavaScript AST -> JavaScript


Scirpus: Cirru -> ES6

Cirru AST -> ES6 AST -> ES5 AST -> JavaScript

https://github.com/babel/babel

如果觉得我的文章对你有用,请随意赞赏

你可能感兴趣的文章

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多