Code Monkey home page Code Monkey logo

js-parser's Introduction

JS 代码解析器

极简版本AST代码解析器,支持的js语法有限,但模块较完整:词法分析、语法分析(生成AST)、生成代码(依赖AST)、执行代码(依赖AST)

  1. 本项目供学习使用,仅实现以下AST类型,(完整的AST类型有哪些?👉 estree
{
  Program: 'Program', // 程序
  VariableDeclaration: 'VariableDeclaration', // 变量声明,可包含多个 VariableDeclarator,如:var a,b;
  VariableDeclarator: 'VariableDeclarator', // 变量声明器
  FunctionDeclaration: 'FunctionDeclaration', // 函数声明
  Identifier: 'Identifier', // 标识符
  NumericLiteral: 'NumericLiteral', // 数字字面量
  StringLiteral: 'StringLiteral', // 字符串字面量
  BlockStatement: 'BlockStatement', // 块级语句
  ExpressionStatement: 'ExpressionStatement', // 表达式语句
  AssignmentExpression: 'AssignmentExpression', // 赋值表达式
  CallExpression: 'CallExpression', // 函数调用表达式
  MemberExpression: 'MemberExpression', // 成员表达式,如:obj.a
};
  1. 模块指引
  1. 执行Demo
node ./demo.js

js-parser's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lippzhang

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.