Lol lang is a basic stack-based interpreted language with its syntax inspired from assembly.
- Currently works only with integers
- supports the following features
- Refer the
examples
folder for code examples
Feature | Description |
---|---|
PUSH | Push to the stack |
POP | Pop from the stack |
ADD | add last 2 values from the stack |
SUB | subtracts last 2 values from the stack |
prints things to the screen | |
READ | read input from the user |
JUMP.EQ.0 | jump if top of the stack is zero |
JUMP.GT.0 | jump if the top of the stack is greater than zero |
HALT | marks the end of the program |
# download the binary release from the releases page
# or just clone the repo and build the project
# build the project
make build
# execute your lol program
bin/lol <file_name>.lol
as given in the examples
folder
# example.lol
PRINT "hello world"
HALT
# result
hello world
# example.lol
PRINT "enter first number"
READ
PRINT "enter second number"
READ
SUB
JUMP.EQ.0 L1
PRINT "not equal"
HALT
L1:
PRINT "equal"
HALT
# result
enter first number
12
enter second number
12
equal
# example.lol
PUSH 232
PUSH 1
ADD
JUMP.EQ.0 L1
LOOP:
PUSH 2
SUB
JUMP.EQ.0 L1
JUMP.GT.0 LOOP
PRINT "even"
HALT
L1:
PRINT "odd"
HALT
# result
even
# example.lol
PUSH 69
JUMP.EQ.0 L2
JUMP.GT.0 L0
PRINT "A"
HALT
L0:
PUSH 3
SUB
JUMP.EQ.0 L1
JUMP.GT.0 L0
PRINT "B"
HALT
L1:
PRINT "C"
HALT
L2:
PRINT "D"
HALT
# result
C