blob: 355ada6ec9e9115d315ae808db2cb5da27b94ff1 (
plain)
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
57
58
59
60
61
62
63
64
65
66
67
|
// ####################################################################
/// This module is intended to store and handle configuration options
///
/// author: Aleksandar Milicevic (t-alekm@microsoft.com)
// ####################################################################
module Options
open Utils
type Config = {
inputFilename: string;
methodToSynth: string;
verifySolutions: bool;
}
let defaultConfig: Config = {
inputFilename = "";
methodToSynth = "*";
verifySolutions = true;
}
let mutable CONFIG = defaultConfig
exception InvalidCmdLineArg of string
exception InvalidCmdLineOption of string
let ParseCmdLineArgs args =
let __StripSwitches str =
match str with
| Prefix "--" x
| Prefix "-" x
| Prefix "/" x -> x
| _ -> str
let __Split (str: string) =
let stripped = __StripSwitches str
if stripped = str then
("",str)
else
let splits = stripped.Split([| ':' |])
if splits.Length > 2 then raise (InvalidCmdLineOption("more than 2 colons in " + str))
if splits.Length = 2 then
let opt = splits.[0]
let value = splits.[1]
(opt,value)
else
let x = __StripSwitches splits.[0]
(x, "")
let rec __Parse args cfg =
match args with
| fs :: rest ->
let opt,value = __Split fs
match opt with
| "method" ->
if value = "" then raise (InvalidCmdLineArg("Must provide method name"))
__Parse rest { cfg with methodToSynth = value }
| "verifySol" ->
__Parse rest { cfg with verifySolutions = true }
| "" ->
__Parse rest { cfg with inputFilename = value }
| _ ->
raise (InvalidCmdLineOption("Unknown option: " + opt))
| [] -> cfg
CONFIG <- __Parse args defaultConfig
|