Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/546669204/javascript-interpreter
用js实现js的解释器。
https://github.com/546669204/javascript-interpreter
ast interpreter javascript
Last synced: 12 days ago
JSON representation
用js实现js的解释器。
- Host: GitHub
- URL: https://github.com/546669204/javascript-interpreter
- Owner: 546669204
- License: apache-2.0
- Created: 2021-09-12T07:21:32.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-14T02:30:49.000Z (over 3 years ago)
- Last Synced: 2024-11-07T11:23:55.173Z (2 months ago)
- Topics: ast, interpreter, javascript
- Language: TypeScript
- Homepage:
- Size: 146 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Javascript-Interpreter
用js实现js的解释器。demo: https://546669204.github.io/javascript-interpreter/
### Expression
* [x] ArrayExpression [1,2,3,...]
* [x] AssignmentExpression a = 1
* [x] BinaryExpression a>b
* [x] CallExpression x()
* [x] ConditionalExpression x?a:b
* [x] FunctionExpression var x = function(){}
* [x] LogicalExpression a || b
* [x] MemberExpression a.b.c
* [x] NewExpression new x
* [x] ObjectExpression {a:"1",...}
* [x] SequenceExpression expression1,expression2,...
* [x] ThisExpression this
* [x] UnaryExpression !x/~x/...
* [x] UpdateExpression x++/x--/...### Statement
* [x] BlockStatement {}
* [x] BreakStatement break
* [x] ContinueStatement continue
* [x] DoWhileStatement do while
* [x] EmptyStatement ;
* [x] ExpressionStatement exp;
* [x] ForInStatement for in
* [x] ForStatement for
* [x] FunctionDeclaration function
* [x] IfStatement if else
* [x] LabeledStatement label:
* [x] ReturnStatement return
* [x] SwitchStatement switch
* [x] ThrowStatement throw
* [x] TryStatement try catch
* [x] VariableDeclaration var let const
* [x] WhileStatement while
* [x] WithStatement with### TEST
```sh
# 安装依赖
yarn
# 构建成果
yarn build
# 运行jest测试
yarn test
```### TODO
* [ ] 递归转循环
* [ ] 效率升级
* [x] jest test262 测试用例### dep
https://github.com/facebook/jest
https://github.com/acornjs/acorn
https://github.com/babel/babelhttps://262.ecma-international.org/5.1/#sec-12.1
https://developer.mozilla.org/
https://astexplorer.net/
https://github.com/tc39/test262