Skip to content
Snippets Groups Projects
Commit e5e70038 authored by Claire GIROT--PERSON's avatar Claire GIROT--PERSON
Browse files

resolve_pb

parent b3f135ac
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,14 @@ type program = int * command list
(* add here all useful functions and types related to the AST: for instance string_of_ functions *)
let string_of_command = function
| DefineMe -> "to be done"
| Push x -> "Push " ^ string_of_int x
| Pop -> "Pop"
| Swap -> "Swap"
| Add -> "Add"
| Sub -> "Sub"
| Mul -> "Mul"
| Div -> "Div"
| Rem -> "Rem"
let string_of_commands cmds = String.concat " " (List.map string_of_command cmds)
......
......@@ -30,7 +30,7 @@ let step state =
| Rem::_, _::0::_ -> Error("Forbidden operation",state)
(* Valid configurations *)
| (Push x)::q, stack -> Ok (q, x::stack)
| Pop::q, x::stack -> Ok (q, stack)
| Pop::q, _::stack -> Ok (q, stack)
| Swap::q, x::y::stack -> Ok (q, y::x::stack)
| Add::q, x::y::stack -> Ok (q, (x + y)::stack)
| Sub::q, x::y::stack -> Ok (q, (x - y)::stack)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment