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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
module GF.Devel.Options where
import System.Console.GetOpt
{-
Usage: gfc [OPTIONS] [FILE [...]]
How each FILE is handled depends on the file name suffix:
.gf Normal or old GF source, will be compiled.
.gfc Compiled GF source, will be loaded as is.
.gfe Example-based GF source, will be converted to .gf and compiled.
.ebnf Extended BNF format, will be converted to .gf and compiled.
.cf Context-free (BNF) format, will be converted to .gf and compiled.
If multiple FILES are given, they must be normal GF source, .gfc or .gfe files.
For the other input formats, only one file can be given.
== Compilation mode ==
-E
Stop after preprocessing (with --preproc).
-C
Stop after converting to .gf (for .gfe, .ebnf and .cf).
-c
Stop after generating .gfc (do not link).
== Help and verbosity options ==
-V, --version
Display GF version
-v N
Set verbosity
-q
Same as -v 0
-v
Same as -v 3
-?, -h, --help
Show help message
--cpu
Show compilation CPU time statistics
== GFC file handling ==
--gfc-dir=DIR
Directory to put .gfc files in.
--no-emit-gfc
Do not create .gfc files.
--emit-gfc
Create .gfc files (default)
== Output options ==
-f, --output-format=FORMAT
Output format. FORMAT can be one of:
Multiple concrete: gfcc (default), gar, js, ...
Single concrete only: cf, bnf, lbnf, gsl, srgs_xml, srgs_abnf, ...
Abstract only: haskell, ...
-o FILE
Save output in FILE. Default is out.X, where X depends on the value of -f.
== Finding libaries ==
-i DIR
Add DIR to the library search path.
--path=DIR:DIR:...
Set the library search path.
--package=PACKAGE
Get libraries from PACKAGE. FIXME: not sure about how this should work.
== Recompilation checking ==
--src, --force-recomp
Always recompile from source, i.e. disable recompilation checking.
== Preprocessing ==
--preproc=COMMAND
Use COMMAND to preprocess input files.
== Optimization ==
-O OPTIMIZATION
Perform the named optimization.
Available optimizations: share, parametrize, values, all, none, subs
The default is share for concrete, none for resource modules.
Several -O flags can be given.
== Probabilistic grammars ==
--prob
Read probabilities from "--# prob" pragmas.
== Grammar flags ==
--startcat=CAT
Use CAT at the start category in the generated grammar.
--language=LANG
Set the speech language flag to LANG in the generated grammar.
-}
data Phase = Preproc | Convert | Compile | Link
data Options = Options {
optStopAfterPhase :: Phase,
optVerbosity :: Int,
optShowCPUTime :: Bool
}
defaultOptions :: Options
defaultOptions = Options {
optStopAfterPhase = Link,
optVerbosity = 1,
optShowCPUTime = False
}
optDescr :: [OptDescr (Options -> Options)]
optDescr =
[
Option ['E'] [] (phase Preproc) "Stop after preprocessing (with --preproc)"
]
where phase p = NoArg (\o -> o { optStopAfterPhase = p })
|