GitPaulo / gojo

Go javascript engine 🔧

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gojo

Go javascript engine-o.

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_REPL_MODE - Set to true to enable REPL mode.

Tests

To run lexer, parser and interpreter tests:

go test ./...

Checkpoints

Yo! This is a for fun project and not intended to ever be finished. o7

The goal is to have a resonably fast and correct javascript engine for the core features of the language only.

Checkout the TODO.md.

Parts by example:

For the code var x = 1 + 1;

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

img.png

References

About

Go javascript engine 🔧

License:MIT License


Languages

Language:Go 97.4%Language:JavaScript 2.6%