1 Star 0 Fork 2

NULL/JavaScript-compiler

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
opcodeCompiler.ts 645 Bytes
Copy Edit Raw Blame History
jacksplwxy authored 2020-04-28 17:57 +08:00 . 增加中间码和目标代码
import { Parser } from '../parser/parser'
import { OpcodeCompiler } from '../opcodeCompiler/opcodeCompiler'
const sourceCode = `
function febonacci(n) {
if(n == 1 || n == 2) {
return n
}
return febonacci(n-1) + febonacci(n-2)
}
print( febonacci(5) )
`
const parser = new Parser()
const ast = parser.parse(sourceCode)
console.log('-----AST------')
ast.print()
console.log('-----SYMBOL TABLE--------')
ast.lexicalScope.print()
console.log('-----IR------')
ast.gen()
ast.ilGen.print()
const compiler = new OpcodeCompiler()
compiler.parse(ast.ilGen.toText(), ast.lexicalScope.toJSON())
console.log('-----OPcode------')
compiler.print()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/delete_user/JavaScript-compiler.git
git@gitee.com:delete_user/JavaScript-compiler.git
delete_user
JavaScript-compiler
JavaScript-compiler
master

Search