Yalul born with purpose of bring be simple and have a fun while studying programming languages.
This is not a language for production systems, but a language to help everyone that wants to learn how a programming language works behind scenes in a fun way.
[x] Basic structure
[x] Lexer
[x] Parser
[x] Tokens/AST Printers
[x] Interpreter
[] Documentation (WIP)
Yalul has a built-in print statement to help you while developing:
print("Hello Yalul")Yalul has five basic value types, boolean, float, integer, null, and string:
The most basic data type, integer represent any integer number:
Yalul v0.0.1 > 42
=> 42Floats are floating point numbers, using dots:
Yalul v0.0.1 > 3.18
=> 3.18Strings represents any text, and on Yalul strings are represented around ONLY double quotes:
Yalul v0.0.1 > "Hello World"
=> "Hello World"Booleans as you may imagine, represents true and false:
Yalul v0.0.1 > true
=> true
Yalul v0.0.1 > false
=> falseAnd unfortunately Yalul has its dark side (among many others), yes we have Null types to represent the absence of any information.
Yalul v0.0.1 > null
=> nullYalul has basic math operations +, -, * and /. It has basic comparison operators too, >, <, <=, >=, ==:
Yalul v0.0.1 > 1 + 1
=> 2
Yalul v0.0.1 > 1 - 1
=> 0
Yalul v0.0.1 > 2 * 2
=> 4
Yalul v0.0.1 > 4 / 2
=> 2.0
Yalul v0.0.1 > 2 > 1
=> true
Yalul v0.0.1 > 2 < 1
=> false
Yalul v0.0.1 > 1 <= 1
=> true
Yalul v0.0.1 > 1 >= 1
=> true
Yalul v0.0.1 > 1 == 1
=> trueTo declare your variable its easy, just use def keyword, pass a name and any expression as value.
def name = "otavio"
And feel free to redefine your variable:
name = "Valadares"
To loop yalul have a while statement, that will execute a given block till the given condition is true:
def counter = 0
while(counter < 10) {
print(counter)
counter = counter + 1
}To control your flow, yalul provides a basic if/else structure:
if (42 > 41) {
print("If block")
} else {
print("Else block")
}To create functions and call it its easy too, yalul provides a nice syntax for it:
func sum(a b) {
return a + b
}
def result = sum(41, 1)
print(result)Clone yalul repository:
git clone https://github.com/ovaladares/yalul.git
pip install -r requirements.txt
Go to yalul root folder and run:
PYTHONPATH=$PATHONPATH:`pwd` bin/yalulExample passing a file
PYTHONPATH=$PATHONPATH:`pwd` bin/yalul yalul_test.yalulYou can add your folder path to your PYTHONPATH instead of set it everytime.
Clone yalul repository:
git clone https://github.com/ovaladares/yalul.git
Run
docker build . -t yalul
docker run -v "$PWD":/usr/src/app -w /usr/src/app yalul bin/yalul
Example passing a file
docker run -v "$PWD":/usr/src/app -w /usr/src/app yalul bin/yalul yalul_test.yalulClone yalul repository:
git clone https://github.com/ovaladares/yalul.git
pip install -r requirements.txt
Access:
My Computer > Properties > Advanced System Settings > Environment Variables
Create a new environment variable with name PYTHONPATH and select yalul directory.
Open CMD, go yo your yalul folder and run:
python bin\yalul
Example passing a file
python bin\yalul yalul_test.yalulYalul REPL is simple and intuitive, just start it without passing any file as argument, and REPL will start:
Yalul has a buil-in tool to render its lex tokens generated by our code. Just use the flag --render-lex-tokens.
Considering the file named yalul_test.yalul containing the fallowing code:
1 + 1Run bin/yalul --render-lex-tokens yalul_test.yalul (Unix example), and the fallowing image will be generated:
All generated images will be placed inside yalul-renders/ folder that it will create as pdf files.
Pay attention, this tool need graphviz installed, you need to install it to use. You can find the install instructions here. Graphviz are known to have PATH problems on windows, if you are using it, manually add it to yourrr PATH.
Yalul has a built-in tool to render its AST, available out of box. To use just use the flag --render-ast while executing a file.
Considering the a file named yalul_test.yalul containing the fallowing code:
func sum(a b) {
return a + b
}Run bin/yalul --render-ast yalul_test.yalul (Unix example), and the fallowing image will be generated:
All generated images will be placed inside yalul-renders/ folder that it will create as pdf files.
Pay attention, this tool need graphviz installed, you need to install it to use. You can find the install instructions here. Graphviz are known to have PATH problems on windows, if you are using it, manually add it to yourrr PATH.
Yalul uses pytest as its test framework. To run it, just type:
PYTHONPATH=$PATHONPATH:`pwd` pytestYalul uses flake8 as python linter. By default we run the fallowing line while developing:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics


