minor fixes to lib

This commit is contained in:
Konarak 2024-09-14 21:15:51 -04:00
parent b7dee58454
commit c506fdd966
Signed by: konarak
GPG Key ID: DE5E99432B548849
2 changed files with 18 additions and 18 deletions

View File

@ -35,14 +35,11 @@ prog:
expr: expr:
| c = COMMENT { Comment c } | c = COMMENT { Comment c }
| e = arithmetic { e }
| POP; p = pop { p }
| PUSH; p = push { p }
| b = branching { b }
| FUNCTION; f = function_definition { f }
| CALL; c = function_call { c }
| RETURN { Return }
| e = expr; COMMENT { e } | e = expr; COMMENT { e }
| e = arithmetic { e }
| e = memoryaccess { e }
| e = programflow { e }
| e = functioncall { e }
; ;
arithmetic: arithmetic:
@ -57,6 +54,11 @@ arithmetic:
| NOT { ArithmeticCommand Not } | NOT { ArithmeticCommand Not }
; ;
memoryaccess:
| POP; e = pop { e }
| PUSH; e = push { e }
;
pop: pop:
| ARGUMENT; a = ADDRESS { MemoryAccessCommand (Pop, Argument, a) } | ARGUMENT; a = ADDRESS { MemoryAccessCommand (Pop, Argument, a) }
| LOCAL; a = ADDRESS { MemoryAccessCommand (Pop, Local, a) } | LOCAL; a = ADDRESS { MemoryAccessCommand (Pop, Local, a) }
@ -78,16 +80,14 @@ push:
| CONSTANT; a = ADDRESS { MemoryAccessCommand (Push, Constant, a) } | CONSTANT; a = ADDRESS { MemoryAccessCommand (Push, Constant, a) }
; ;
branching: programflow:
| LABEL; i = ID { ProgramFlowCommand (Label, i) } | LABEL; i = ID { ProgramFlowCommand (Label, i) }
| GOTO; i = ID { ProgramFlowCommand (Goto, i) } | GOTO; i = ID { ProgramFlowCommand (Goto, i) }
| IFGOTO; i = ID { ProgramFlowCommand (Ifgoto, i) } | IFGOTO; i = ID { ProgramFlowCommand (Ifgoto, i) }
; ;
function_definition: functioncall:
| i = ID; a = ADDRESS { FunctionCallCommand (Function, i, a) } | FUNCTION; i = ID; a = ADDRESS { FunctionCallCommand (Function, i, a) }
; | CALL; i = ID; a = ADDRESS { FunctionCallCommand (Call, i, a) }
| RETURN { Return }
function_call:
| i = ID; a = ADDRESS { FunctionCallCommand (Call, i, a) }
; ;