an attempt at making a compiler in rust!
Future "Valid Syntax", negative whitespace significant indentation!
hhh {
eee {
aaa {
ddd {
aaa }
ccc }
hhh }
eee }
- variables WITH DATA TYPES
- operations: (boolean, logical//bitwise, binary)
- control flow branches: (if/else)
- loops: (while/for)
- types
- functions: (recursion << should be free?)
- array
- user defined struct
-
if
- rework lexer to handle multi-symbol keywords (i.e "==" or "<=")
- parse boolean comparison
- else & else if parsing
- code generation
- invert 'jump' conditions
- unsigned vs signed comparison (diff jump instructions) (no types, all signed)
- binary expr conditions
- conditional expr, either has explicity bool comparison or implicit, expr = lhs: (lhs > 0)
- cmp reg1, reg2 ; compare arguments
- set(EQUIVALENCE e.g e, le) al; sets register 'al' (8 bit) to 1,0 depending on cmp flag
- movzx output_reg, al ; Move Zero Xtend. copies 'al' into 'output_reg' && zero init reg1 bits.
- types of scope
- inherits variables from parent scope (if, else if, else)
- doesn't (new function, UNLESS class, inherits 'self')
-
(kinda done) split 'TokenKind': 'Symbol' .. 'LogicalOp' .. 'BinaryOp' .. etc
-
comments
-
re-design multi-symbol in Lexer: match against longest multi-symbol to shortest, until finds match (or illegal token.)
-
update grammar to match code.
-
variable reassignment (mutability)
-
Operators
- modulus '%' op
- Associativity
- binary
- logical
- i.e: if (5) | 5 != 0 so -> if (true)
- i.e: if (!5) | 5 == 0 so -> if (false)
- eval expr, jump if zero. << un-optimal, uses 'al' reg when not necessary
- bitwise
- unary
- LogicalNot
- BitwiseNot
-
dynamically place variables on stack if they are(nt) used immediately.
- on expr generation.
-
Testing infrastructure.
-
data types
- bools: al register (8 bit)
- u8: al
- u16: ax
- u32: eax
- u64: rax
-
functions
- return type
- arguments
- body
- program entry point ("main")
-
Implement C equivalent operators:
- comma: ','
- assignment: '=' | '+=' | '/=' | ..
- modulus: %
- logical not: !
- unary minus: i.e -10
- function call: '()'
- array subscript: '[]'
- struct member: '.' | '->'
- Increment/Decrement (OPTIONAL)
- cast: (type)
-
(Joke mode:) negative whitespace significance, the most nested piece of code has 0 indentations, everything out has an indentation.
- compiler error on uppercase