Skip to content

CoderParth/EG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EG

Eg is an interpreter for a custom language, built for my own educational
purposes, written in go, without using any external library.

At this stage, eg supports variable assignments, numbers, strings, booleans,
for loops, if/else statements, functions, recursion, and basic cli IO. The syntax
of eg is similar to the syntax of Python and Lua.

Below are some examples of the language. Full examples can be found at
/examples directory of this project.

All files for eg ends with a .eg extension.

Hello World

print("Hello, World!")

Input

name = input("What's your name? ")
print(name)

Comment

// This is a comment. 

Assignment

// Below are some variable assignment examples. 
x = 10
ft = 5.44
x = x + 1
y = x + 5
z = "Hello"
t = true 
f = false

For Loops

Only one way to do a loop in eg.

for<condition> do
<for block goes here> 
end

Example:

i = 0
for i < 10 do 
print(i)
i = i + 1
end

If/Else Conditionals

Below is an example of if/else statement. Examples for nested loops,
and nested if/else conditionals are present in the /examples directory.

x = 10
if x > 5 then
    print("x is greater than 5")
else
    print("x is 5 or less")
end

Functions

fn greet(name)
    print(name)
    return name
end

result = greet("World")

Recursion

fn recurse(a)
	if a == 100 then 
        return a 
        end
return recurse(a+1) 
end

ans = recurse(3) 
print(ans)
// prints 100

About

An interpreter for my custom language.

Topics

Resources

Stars

Watchers

Forks

Languages