minor fixes etc

This commit is contained in:
Konarak 2024-09-20 14:20:09 -04:00
parent c506fdd966
commit 2a877a22e4
Signed by: konarak
GPG Key ID: DE5E99432B548849
4 changed files with 3 additions and 8 deletions

View File

@ -33,7 +33,6 @@ type function_command =
| Call
type expr =
| Comment of string
| ArithmeticCommand of arithmetic_command
| MemoryAccessCommand of memory_command * memory_segment * int
| ProgramFlowCommand of branching_command * string

View File

@ -17,7 +17,7 @@ let id = (alphabets | numbers | colon | period | underscore)+
rule read =
parse
| white { read lexbuf }
| comment as c { COMMENT (c) }
| comment { read lexbuf }
| "add" { ADD }
| "sub" { SUB }
| "neg" { NEG }

View File

@ -21,7 +21,6 @@ open Ast
%token <int> ADDRESS
%token <string> ID
%token <string> COMMENT
%token EOF
%start <Ast.expr> prog
@ -34,8 +33,6 @@ prog:
;
expr:
| c = COMMENT { Comment c }
| e = expr; COMMENT { e }
| e = arithmetic { e }
| e = memoryaccess { e }
| e = programflow { e }

View File

@ -13,8 +13,8 @@ let translate class_name lines : string list =
lines
|> List.map ~f:parse
|> List.bind ~f:(function
| ArithmeticCommand a
-> Arithmetic.translate a
| ArithmeticCommand command
-> Arithmetic.translate command
| MemoryAccessCommand (command, segment, offset)
-> Memoryaccess.translate command segment offset class_name
| ProgramFlowCommand (command, name)
@ -23,5 +23,4 @@ let translate class_name lines : string list =
-> Functioncall.translate command name arg
| Return
-> Return.translate
| Comment _ -> []
)