Javascript-Interpreter
用js实现js的解释器。
demo: https://546669204.github.io/javascript-interpreter/
Expression
- ArrayExpression [1,2,3,...]
- AssignmentExpression a = 1
- BinaryExpression a>b
- CallExpression x()
- ConditionalExpression x?a:b
- FunctionExpression var x = function(){}
- LogicalExpression a || b
- MemberExpression a.b.c
- NewExpression new x
- ObjectExpression {a:"1",...}
- SequenceExpression expression1,expression2,...
- ThisExpression this
- UnaryExpression !x/~x/...
- UpdateExpression x++/x--/...
Statement
- BlockStatement {}
- BreakStatement break
- ContinueStatement continue
- DoWhileStatement do while
- EmptyStatement ;
- ExpressionStatement exp;
- ForInStatement for in
- ForStatement for
- FunctionDeclaration function
- IfStatement if else
- LabeledStatement label:
- ReturnStatement return
- SwitchStatement switch
- ThrowStatement throw
- TryStatement try catch
- VariableDeclaration var let const
- WhileStatement while
- WithStatement with
TEST
# 安装依赖
yarn
# 构建成果
yarn build
# 运行jest测试
yarn test
TODO
- 递归转循环
- 效率升级
- jest test262 测试用例
dep
https://github.com/facebook/jest
https://github.com/acornjs/acorn
https://github.com/babel/babel
https://262.ecma-international.org/5.1/#sec-12.1
https://developer.mozilla.org/
https://astexplorer.net/
https://github.com/tc39/test262