Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

ckafrouni/eva-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

eva-interpreter

πŸ’ƒ Eva - Building an interpreter from scratch

Multi-paradigm interpretter written in python.

This language was designed from Eva.

Example OO program with inheritance.

(class Point nil
  (begin
    (def constructor (self x y)
      (begin
        (set (prop self x) x)
        (set (prop self y) y)
      ))	

    (def calc (self)
      (+ (prop self x) (prop self y)))
  ))

(class ThreeD Point
  (begin
    (def constructor (self x y z)
      (begin
        ((prop (super ThreeD) constructor) self x y)
        (set (prop self z) z)))

    (def calc (self)
      (+ 
        ((prop (super ThreeD) calc) self)
        (prop self z)))))

(var t (new ThreeD 1 2 7))

((prop t calc) t)

Grammar:

Exp 
	: NUMBER
	| STRING
	| ['begin', Exp...]
	| ['var', NAME, Exp]
	| ['set', NAME, Exp]
	| ['if', Exp, Exp, Exp]
	| ['while', Exp, Exp]
	| NAME
	| [NAME, Exp...] # Function call
	;

Reserved keywords:

keyword
begin
var
set
if
while
for
switch
def
lambda
class
super
new
prop

About

πŸ’ƒ Eva - Building an interpreter from scratch

Resources

Stars

Watchers

Forks

Contributors

Languages