No description
|
|
||
|---|---|---|
| .gitignore | ||
| LICENSE | ||
| README.md | ||
ELox
A Lox variant for embedded devices. It's sole purpose is to be a playground to implement an end to end compiler for embedded devices.
Features
ELox omits some features from Lox and borrows some others from C. The feature set is meant to be restrictive to ease implementation.
- Static typing with no type inference.
- Words (
word), and boolean (trueandfalse) types. - Word literals in different formats:
101,0x101,0b101,0o101. - Arithmetic expressions:
+,-,*,<<,>>. - Logical expressions:
&&,||,==,!=,<,<=,>,>=. - Bitwise expressions:
&,|,^. - Stack and global variables:
var myWord word. - Control flow with
if,whileandforwith usual C-like syntax. - Memory regions which can be used to access a group of registers more effectively.
They must be instantiated at a particular address and all elements are words.
mem someRegGroup { reg1 reg2 reg3 } var regs someRegGroup = @0xdfffffff fun main () { regs.reg1 = 0xff var test word = regs.reg2 } - Functions
// This is a comment btw. fun myFunWithReturn(arg1 word, arg2 bool) word { var res word = 0 if (arg2) { res = arg1 } else { res = arg1 * arg1 } } fun myFun(arg1 word, arg2 word) { doSomethingElse(arg1, arg2) }
Notable ommisions are signed integers, heap variables (no malloc implementation yet), arrays, structs and strings. These may be slowly implemented as needs arise.