Skip to content

RobinLockyer/gojo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Go javascript engine. (someday it will work)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 99.1%
  • JavaScript 0.9%