minor fixes etc
This commit is contained in:
parent
c506fdd966
commit
2a877a22e4
@ -33,7 +33,6 @@ type function_command =
|
|||||||
| Call
|
| Call
|
||||||
|
|
||||||
type expr =
|
type expr =
|
||||||
| Comment of string
|
|
||||||
| ArithmeticCommand of arithmetic_command
|
| ArithmeticCommand of arithmetic_command
|
||||||
| MemoryAccessCommand of memory_command * memory_segment * int
|
| MemoryAccessCommand of memory_command * memory_segment * int
|
||||||
| ProgramFlowCommand of branching_command * string
|
| ProgramFlowCommand of branching_command * string
|
||||||
|
@ -17,7 +17,7 @@ let id = (alphabets | numbers | colon | period | underscore)+
|
|||||||
rule read =
|
rule read =
|
||||||
parse
|
parse
|
||||||
| white { read lexbuf }
|
| white { read lexbuf }
|
||||||
| comment as c { COMMENT (c) }
|
| comment { read lexbuf }
|
||||||
| "add" { ADD }
|
| "add" { ADD }
|
||||||
| "sub" { SUB }
|
| "sub" { SUB }
|
||||||
| "neg" { NEG }
|
| "neg" { NEG }
|
||||||
|
@ -21,7 +21,6 @@ open Ast
|
|||||||
|
|
||||||
%token <int> ADDRESS
|
%token <int> ADDRESS
|
||||||
%token <string> ID
|
%token <string> ID
|
||||||
%token <string> COMMENT
|
|
||||||
%token EOF
|
%token EOF
|
||||||
|
|
||||||
%start <Ast.expr> prog
|
%start <Ast.expr> prog
|
||||||
@ -34,8 +33,6 @@ prog:
|
|||||||
;
|
;
|
||||||
|
|
||||||
expr:
|
expr:
|
||||||
| c = COMMENT { Comment c }
|
|
||||||
| e = expr; COMMENT { e }
|
|
||||||
| e = arithmetic { e }
|
| e = arithmetic { e }
|
||||||
| e = memoryaccess { e }
|
| e = memoryaccess { e }
|
||||||
| e = programflow { e }
|
| e = programflow { e }
|
||||||
|
@ -13,8 +13,8 @@ let translate class_name lines : string list =
|
|||||||
lines
|
lines
|
||||||
|> List.map ~f:parse
|
|> List.map ~f:parse
|
||||||
|> List.bind ~f:(function
|
|> List.bind ~f:(function
|
||||||
| ArithmeticCommand a
|
| ArithmeticCommand command
|
||||||
-> Arithmetic.translate a
|
-> Arithmetic.translate command
|
||||||
| MemoryAccessCommand (command, segment, offset)
|
| MemoryAccessCommand (command, segment, offset)
|
||||||
-> Memoryaccess.translate command segment offset class_name
|
-> Memoryaccess.translate command segment offset class_name
|
||||||
| ProgramFlowCommand (command, name)
|
| ProgramFlowCommand (command, name)
|
||||||
@ -23,5 +23,4 @@ let translate class_name lines : string list =
|
|||||||
-> Functioncall.translate command name arg
|
-> Functioncall.translate command name arg
|
||||||
| Return
|
| Return
|
||||||
-> Return.translate
|
-> Return.translate
|
||||||
| Comment _ -> []
|
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user