diff --git a/ground_ast.py b/ground_ast.py index db0ef7d..aebdfa8 100644 --- a/ground_ast.py +++ b/ground_ast.py @@ -25,6 +25,8 @@ class IntNode: value: float def __repr__(self): return "Int" + def __str__(self): + return str(self.value) @dataclass class FloatNode: value: float diff --git a/out b/out index 5e5360f..12f9193 100644 Binary files a/out and b/out differ diff --git a/out.asm b/out.asm index 5836c5e..886c93b 100644 --- a/out.asm +++ b/out.asm @@ -1,29 +1,67 @@ ; ~~~ Auto generated by the GroundPY compiler for Linux x86_64 targets. ~~~ section .data -.LC0: db "Hello, World!", 10, 0 +.LC0: db "123", 0 .LC1: equ $ - .LC0 +.LC2: db "", 10, "WE CAN PRINT FUCKING NUMBERS AND SHITT", 10, 0 +.LC3: equ $ - .LC2 +.LC4: db "LESS GOOOOO", 10, 0 +.LC5: equ $ - .LC4 +.LC6: db "this was printed using a variable!!!!!", 10, 0 +.LC7: equ $ - .LC6 +.LC8: db "", 10, 0 +.LC9: equ $ - .LC8 section .text global _start _start: - ; InstructionNode(instruction='set', parent=RootNode(statements=[..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, String]) - lea rax, [.LC0] - push rax - mov rax, .LC1 - push rax - ; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Int]) - mov rax, 123 - push rax - ; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), ..., InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariableReference]) - mov rsi, [rsp + 16] - mov rdx, [rsp + 8] + ; InstructionNode(instruction='stdout', parent=RootNode(statements=[..., InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[Int]) + mov rsi, .LC0 + mov rdx, .LC1 mov rax, 1 mov rdi, 1 syscall - ; InstructionNode(instruction='end', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), ...]), arguments=[VariableReference]) + ; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[String]) + mov rsi, .LC2 + mov rdx, .LC3 + mov rax, 1 + mov rdi, 1 + syscall + ; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), ..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[String]) + mov rsi, .LC4 + mov rdx, .LC5 + mov rax, 1 + mov rdi, 1 + syscall + ; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[VariablePointer, String]) + lea rax, [.LC6] + push rax + mov rax, .LC7 + push rax + ; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), ..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[VariableReference]) + mov rsi, [rsp + 8] + mov rdx, [rsp + 0] + mov rax, 1 + mov rdi, 1 + syscall + ; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[VariablePointer, Int]) + mov rax, 123 + push rax + ; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[VariableReference]) + mov rsi, [rsp + 0] + mov rdx, [rsp + -8] + mov rax, 1 + mov rdi, 1 + syscall + ; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), ..., InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[String]) + mov rsi, .LC8 + mov rdx, .LC9 + mov rax, 1 + mov rdi, 1 + syscall + ; InstructionNode(instruction='end', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), ...]), arguments=[Int]) mov rax, 60 - mov rdi, [rsp + 0] + mov rdi, 0 syscall \ No newline at end of file diff --git a/test2.grnd b/test2.grnd index 2907825..9ccfc3a 100644 --- a/test2.grnd +++ b/test2.grnd @@ -1,4 +1,9 @@ -set &x "Hello, World!\n" -set &y 123 +stdout 123 +stdout "\nWE CAN PRINT FUCKING NUMBERS AND SHITT\n" +stdout "LESS GOOOOO\n" +set &x "this was printed using a variable!!!!!\n" stdout $x -end $y \ No newline at end of file +set &y 123 +stdout $y +stdout "\n" +end 0 \ No newline at end of file