-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.mli
56 lines (45 loc) · 1.45 KB
/
command.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(** This module represents abstract commands, as well as handles the parsing of
string information from the user into moves in a Risk game. *)
(** Record of data associated with attacking *)
type attack_phrase =
{
from_trr_name: string;
to_trr_name: string
}
(** Record of data associated with place *)
type place_phrase =
{
count: int;
trr_name: string
}
(** Record of data associated with fortify *)
type fortify_phrase =
{
count: int;
from_trr_name: string;
to_trr_name: string
}
(** Raised when a malformed command is encountered *)
exception Malformed of string
(** Raised when an empty command is encountered *)
exception Empty of string
(** Raised when the user inputs a negative value in command *)
exception Negative_int of string
(** The type [command] represents a player command *)
type command =
| Attack of attack_phrase
| Place of place_phrase
| Fortify of fortify_phrase
| Next
| Quit
(** [parse str] parses a player's input into a [command] *)
val parse : string -> command
(** [parse_attack] given a token list [tokens], it will return an
[attack_phrase] command *)
val parse_attack : string list -> attack_phrase
(** [parse_place] given a token list [tokens], it will return a
[place_phrase] command *)
val parse_place : string list -> place_phrase
(** [parse_fortify] given a token list [tokens], it will return a
[fortify_phrase] command *)
val parse_fortify : string list -> fortify_phrase