Git Product home page Git Product logo

go-interpreter's Introduction

Interpreter implemented in Go

Study on interpreters, featuring a complete dynamically-typed language. This work is based on the book Writing An Interpreter In Go, by Thorsten Ball. The project is fully unit-tested.

Structure of the project

  • /ast All available data structures representing the evaluated program
  • /evaluator Navigates through the AST in order to evaluate its nodes
  • /lexer Produces tokens from chars, it is responsible of syntax checking
  • /object Data structures representing the execution results of the AST by the evaluator
  • /parser The role of the parser is to produce an AST of the program from tokens
  • /repl Read-Eval-Print Loop, which enables direct development in this language
  • /token Base representation of the code: a collection of tokens

Execution flow of the interpreter:

string =[lexer]=> []token =[parser]=> ast =[evaluator]=> stream of objects

List of additional features to implement

Lexer

  • Support UNICODE + UFT8 encoding instead of only ASCII. This requires switching from byte to rune reading
  • Allow integers as part of a variable or function name (but only if not solely composed of int chars)
  • Support ++, --, +=, -=, *=, /=, %=
  • Support modulo
  • Allow ternary operators

Parser

  • indicate source line and col when reporting errors (impacts lexer)
  • Support else if(...)

go-interpreter's People

Contributors

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