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.
print("Hello, World!")
name = input("What's your name? ")
print(name)
// This is a comment.
// Below are some variable assignment examples.
x = 10
ft = 5.44
x = x + 1
y = x + 5
z = "Hello"
t = true
f = false
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
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
fn greet(name)
print(name)
return name
end
result = greet("World")
fn recurse(a)
if a == 100 then
return a
end
return recurse(a+1)
end
ans = recurse(3)
print(ans)
// prints 100