Introduction to the ELIN Language
ELIN is a stack-oriented, integer-only programming language designed for high-performance execution on low-power hardware (specifically the ESP8266). By using a virtual machine approach, ELIN allows for complex logic to be stored in a compact bytecode format.
Unlike languages like C++ or Python that use registers or named memory for every single intermediate
calculation, a stack-based language uses a "Push/Pop" model. To add two numbers, you push both onto
a "stack" and then call an ADD instruction which consumes them and pushes the result
back.
Basic Syntax
Writing code in ELIN is simple. Every instruction occupies its own line. Comments can be added using the
# or // prefix.
Defining Variables
Variables are created using the let keyword. Once a variable is defined, it can be reused in
any expression.
let int x = 10
let int y = x + 5
let str msg = "Total is: "
print msg
print y
ELIN variables are globally scoped within a single program file and must be defined before they are used in any calculation or print statement.
Mathematics & Expressions
ELIN supports standard mathematical operators with proper order of operations (PEMDAS/BODMAS). This is achieved through an internal Shunting Yard parser.
| Operator | Meaning | Example |
|---|---|---|
+ |
Addition | x + 5 |
- |
Subtraction | x - 5 |
* |
Multiplication | x * 10 |
/ |
Division | x / 2 |
( ) |
Grouping | (1 + 2) * 3 |
If-Else Statements
Conditional logic allows your program to make decisions. ELIN uses a block-based
if...else...end structure.
let int temp = 80
if temp > 100
let str msg = "CRITICAL"
print msg
else
let str msg = "SAFE"
print msg
end
You can nest if statements inside other if or while blocks as
deeply as needed. The compiler tracks block depth automatically.
While Loops
Loops continue as long as the condition evaluates to non-zero (True). Use wend to close the
loop.
let int i = 1
while i <= 10
print i
let int i = i + 1
wend
To prevent infinite loops and system lockups on the ESP8266, ELIN enforces a maximum iteration limit of 999,999,999 cycles for any single loop construct.
Opcode Specification
For those interested in the internal mechanics, here are some of the current instruction set recognized by the ELIN Virtual Machine.
| ID | Mnemonic | Description |
|---|---|---|
| 1 | PUSH | Push value to stack |
| 2 | LOAD | Load variable index to stack |
| 3 | STORE | Store stack top into variable index |
| 8 | Output variable contents to console | |
| 9 | HALT | Immediately stop execution |
| 20 | PUSH_STR | Push pointer to string pool index |
| 16 | JMP | Unconditional jump to address |
| 17 | JZ | Jump to address if stack top is zero |