diff --git a/compiler/backend/lib/ast.ml b/compiler/backend/lib/ast.ml index b6b71ef..0b7d7b4 100644 --- a/compiler/backend/lib/ast.ml +++ b/compiler/backend/lib/ast.ml @@ -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 diff --git a/compiler/backend/lib/lexer.mll b/compiler/backend/lib/lexer.mll index 728f6f6..f48d700 100644 --- a/compiler/backend/lib/lexer.mll +++ b/compiler/backend/lib/lexer.mll @@ -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 } diff --git a/compiler/backend/lib/parser.mly b/compiler/backend/lib/parser.mly index 9571196..02fe556 100644 --- a/compiler/backend/lib/parser.mly +++ b/compiler/backend/lib/parser.mly @@ -21,7 +21,6 @@ open Ast %token ADDRESS %token ID -%token COMMENT %token EOF %start prog @@ -34,8 +33,6 @@ prog: ; expr: - | c = COMMENT { Comment c } - | e = expr; COMMENT { e } | e = arithmetic { e } | e = memoryaccess { e } | e = programflow { e } diff --git a/compiler/backend/lib/translate.ml b/compiler/backend/lib/translate.ml index a14fd84..1cc9ca6 100644 --- a/compiler/backend/lib/translate.ml +++ b/compiler/backend/lib/translate.ml @@ -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 _ -> [] )