Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 94 lines (75 sloc) 2.842 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (** Generic preprocessor *)
19
20 (**
21 File syntax (quick summary):
22 #<Debug> / #<Else> / #<End>
23 Filter according to PPDEBUG mode (-d switch)
24 #<If:VAR TEST> / #<Else> / #<End>
25 Do a run-time check on environment variable VAR (applying function
26 TEST on its value if TEST is present). Disabled in release mode (-r
27 switch). If #<Else> is absent, unit is assumed.
28 If TEST is used, the character \$ can be used as the ppdebug module
29 prefix ($\{debugmodule\}.).
30 #<Ifstatic:VAR REGEXP> / #<Else> / #<End>
31 Do a static check at compile-time on the value of environment
32 variable VAR.
33 #<Debugvar:VAR>
34 Define VAR as the default to test in following #<If>/#<Ifstatic> tests.
35
36 Invocation: $0 [-d] [-r] [file]
37 -d enable debug sections
38 -r release mode: comment out dynamic environment checks
39 file file to parse, by default stdin
40
41 The output is put to stdout
42 *)
43
44 (** {6 Environment} *)
45
46 (** Type of an preprocessor environment. *)
47 type env
48
49 (** Empty preprocessor environment. *)
50 val empty_env : env
51
52 (** [add_env name value] add binding [name] -> [value] on [env]. *)
53 val add_env : string -> string -> env -> env
54
55 (** Fill the preprocessor environment with the system environment. *)
56 val fill_with_sysenv : env -> env
57
58 (** {6 Options}
59 Not stable...
60 *)
61 (** Type of preprocessor options. *)
62 type options = {
63 env : env; (** Preprocessor environment *)
64 output_suffix : string option (**If set, write to files, adding a suffix to each file name*);
65 force_static : bool; (** Force all if to be static *)
66 }
67
68 (**
69 Default options :
70 - force_static = false
71 *)
72 val default_options : env -> options
73
74 (** {6 Preprocessing} *)
75
76 (** Some description of a langage (Not stable...) *)
77 type lang_description = {
78 open_com : string; (** Open a comment *)
79 close_com : string; (** Close a comment *)
80 open_block : string; (** Open a block *)
81 close_block : string; (** Close a block *)
82 debug_module : string; (** The debug module *)
83 }
84
85 val process : lang_description -> options -> string -> string
86
87 (** {6 Executable} *)
88 (** A module for easy executable making. *)
89 module Exe :
90 sig
91 (** Run a preprocessor according to the given language description. *)
92 val run : lang_description -> unit
93 end
Something went wrong with that request. Please try again.