Giter Club home page Giter Club logo

runjs's Introduction

RunJS JavaScript Engine

1. Introduction

RunJS is a small JavaScript engine written in JavaScript, no external dependency.

It includes a set of classic JavaScript features in reference to the ECMA-262 Language Specification.

Online Demo

2. Usage

main.js provides a run function that accepts JavaScript source code as an argument.

You can import run anywhere and execute it.

3. Specifications

3.1 Language support

  • Primitive data types and object
  • Arithmetic and logical operations
  • Conditional and iteration statements
  • Function and scope

3.2 Standard library

// Similar to console.log()
log(...args);

4. Internals

4.1 Lexer

Implemented lexical analysis using regular expressions.

4.2 Parser

Implemented syntax analysis from scratch according to LL algorithm, and construct AST.

4.3 Runtime

Implemented a set of runtime infrastructure:

  • LanguageTypes
    • NumberType (represented as Float64Array)
    • StringType (represented as Uint16Array)
    • BooleanType
    • ObjectType
    • UndefinedType
    • NullType
  • Realm
    • The log function is registered here
  • SpecificationTypes
    • CompletionRecord
    • LexicalEnvironment
    • Reference
  • ExecutionContext

4.4 Evaluator

When a new instance of the JavaScript engine is created, Realm will be created, ExecutionContextStack will be initialized, AST will be traversed and interpreted.

runjs's People

Contributors

devlzl avatar

Watchers

 avatar

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.