Giter Club home page Giter Club logo

eva-interpreter-js's Introduction

This is the source code for Eva-lang interpreter implemention step by step. It comes from the online course of 'Essential of Interpreter'.

  • Examples for Eva lang
// Eva
(+ 10 20)
(* 10 30)
(var x 10)
(print x)  // 10

(begin
    (var x 20)
    (print x)  // 20
)
(print x)  // 10
(set foo 10)
(print x)  // 20

(if (> x 1)
    (set y 10)
    (set y 20)
)

(switch ((> x 1) 100)
            ((= x 1) 200)
            (else 0)
)

(for (var x 10)
        (> x 0)
        (-- x)
        (print x)
)
  • Gramma of Eva lang
Exp ::= Number
        | String
        | [+ Exp, Exp]
        ...
        | [var name, Exp]
        | [set name, Exp]
        | name
        ...
        | [begin Exp...]
        ;
(switch (<cond1> <block1>)
            (<cond2> <block2>)
            ...
            (else <alternate>)
)

implementions: transformation

(if <cond1>
    <block1>
    ...
    (if <condN>
        <blockN>
        <alternate>
    )
)
  • for loops
(for <init>
      <condition>
      <modifier>
      <exp>
)

(begin
    <init>
    (while <condition>
            (begin
                <exp>
                <modifier>
            )
    )
)

eva-interpreter-js's People

Contributors

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