Giter Club home page Giter Club logo

gojo's Introduction

gojo

Go javascript engine.

go run main.go

Use environment variables to configure the engine.

  • GOJO_INPUT_FILE - Set file path to use it as input (default=input_program.js).
  • GOJO_VERBOSE - Set to true to enable verbose logging.
  • GOJO_MEGA_VERBOSE - Set to true to enable EVEN MORE logging.
  • GOJO_TEST - Set to true to run tests only.

Checkpoints

Yo! This is for learning purposes and not intended to ever be finished.

  • Lexer (FSM): Meh compliance with the ECMAScript spec.
  • Parser (Recursive Descent):
    • Variables
    • Literals: Integers Booleans Strings
    • Binary expressions
    • Grouped expressions
    • If/Else statements
    • Basic Function declarations
    • Block statements
    • While statements
  • Interpreter (& Go Runtime):
    • Sets variable declarations of above types
    • Evaluates Simple Binary expressions (+, -, *, /)
    • Call expressions and translates the following to go runtime:
      • console.log, Math.sqrt, Math.pow, typeof

Parts by example:

For the code var x = 1 + 1;

  1. Lexer: Produces a stream of tokens var, x, =, 1, +, 1, ;
  2. Parser: Produces an AST Program -> Statements[] -> VariableDeclaration(x = BinaryExpression(1 + 1))
  3. Interpreter: Process the AST and stores the value in the environment x = 2

img.png

References

gojo's People

Contributors

gitpaulo 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.