diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-07-18 07:45:58 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-07-18 07:45:58 +0100 |
commit | 8bb321f8b032dfaeffbe3d1b8dfeb215c12d3642 (patch) | |
tree | c53977d1284347bb1d5963ddb4dc7723c40c6e55 /TODO.md | |
download | micro-lang-8bb321f8b032dfaeffbe3d1b8dfeb215c12d3642.tar.gz micro-lang-8bb321f8b032dfaeffbe3d1b8dfeb215c12d3642.zip |
First public release
Diffstat (limited to 'TODO.md')
-rw-r--r-- | TODO.md | 90 |
1 files changed, 90 insertions, 0 deletions
@@ -0,0 +1,90 @@ +# Numeric types + +Instead of "number", integer: + + * i8, i16: signed + * u8, u16: unsigned + +Operations: + + * x.lo and x.hi are r/w properties to get/set low/high bytes in 16-bit numbers + * i8(x), u8(x), i16(x), u16(x) for conversions (there are no implicit conversions) + +Consequences: + + * array index is either u8 or u16 + +# Strings + +Strings are zero ended arrays of u8 that can be represented as a literal using double quotes. + +```micro +// 6 characters plus a 0 at the end +var s [7]u8 = "string"; + +// change value; length <= array size +s = "value"; + +s = "another"; +// error: string is too long for [7]u8 +``` + +Notes: + + * "xxx" + 0 to initialize an array of u8 + * can be used to change the value + * the string can be shorter than the array space, but length + 1 must fit in the array + +The interpreter built-in `println` will print literals as strings, but in order to output an array of u8 as a string, use `str` property: + +The following escape sequences are supported in both strings and character literals: + + * In string literals `\"` for a double quote. + * In character literals `\'` for a single quote. + * `\n` for end of line. + * `\t` for tab. + * `\x00` for a 2 digits hex number (8-bit). + * `\\` for the backslash itself. + +```micro +// the array is initialized to zeroes +var s [10]u8; + +s[0] = 'H'; +s[1] = 'e'; +s[2] = 'l'; +s[3] = 'l'; +s[4] = 'o'; + +println(s.str); +// output: Hello +``` + +# Constants and expression evaluation + +The parser should resolve most constants and expression evaluation. + +e.g. `a = 1 + 2` -> `a = 3` + +Constant as literal replacement (constants MUST be literals after expression evaluation). + +Built-in `len` should be resolved at parsing time (applies to array size and that is static). + +# Remove closures + + * why: they are dynamic + * can we have a limited closure? + +# Directives + +Include a file in current source and it will interpreted / compiled. + +```micro +include "file.micro" +``` + +Include a binary file as an expression list to initialize an array. + +```micro +var arr [64]number = incbin "file.micro"; +``` |