minor fixes etc
This commit is contained in:
parent
c506fdd966
commit
2a877a22e4
@ -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
|
||||
|
@ -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 }
|
||||
|
@ -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 }
|
||||
|
@ -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 _ -> []
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user