1 (* HCoop
Domtool (http
://hcoop
.sourceforge
.net
/)
2 * Copyright (c
) 2006, Adam Chlipala
4 * This program is free software
; you can redistribute it
and/or
5 * modify it under the terms
of the GNU General Public License
6 * as published by the Free Software Foundation
; either version
2
7 * of the License
, or (at your option
) any later version
.
9 * This program is distributed
in the hope that it will be useful
,
10 * but WITHOUT ANY WARRANTY
; without even the implied warranty
of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
. See the
12 * GNU General Public License for more details
.
14 * You should have received a copy
of the GNU General Public License
15 * along
with this program
; if not
, write to the Free Software
16 * Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
19 (* Configuration language abstract syntax
*)
21 structure Ast
= struct
25 (* A description
of a predicate on configuration block stacks
*)
28 (* The stack is empty
. *)
30 (* The given pred name is on top
of the stack
. *)
32 (* Some prefix
of the stack matches the pred
. *)
34 (* The pred does not match
. *)
36 (* Both preds match
. *)
37 withtype pred
= pred
' * position
46 | TAction
of pred
* record
* record
48 * - Is valid
in the given pred
49 * - Expects an environment compatible
with the first record
50 * - Modifies it according to the second record
*)
51 | TNested
of pred
* typ
52 (* Allow nested configuration
, in the form
of a function from an action
53 * satisfying the first predicate to an action satisfying the second
and
54 * with the same environment variable IO behavior
. *)
57 (* Marker that something already went wrong
, so don
't generate further
59 | TUnif
of string * typ option ref
60 (* Unification variable to be determined during
type-checking
*)
61 withtype typ
= typ
' * position
62 and record
= typ StringMap
.map
66 (* Constant integer
*)
70 (* Basic list constructor
*)
72 | ELam
of string * typ option
* exp
73 (* Function
abstraction *)
75 (* Variable bound by a function
*)
77 (* Function application
*)
80 (* Do
-nothing action
*)
81 | ESet
of string * exp
82 (* Set an environment variable
*)
83 | EGet
of string * string * exp
84 (* Get an environment variable
*)
86 (* Monad sequencer
; execute a number
of commands
in order
*)
88 (* Local execution
; like ESeq
, but the writes
of the first
89 * action are abandoned
*)
91 (* Apply a TNested to an action
*)
92 withtype exp
= exp
' * position
96 | DExternVal
of string * typ
97 | DVal
of string * typ option
* exp
98 type decl
= decl
' * string option
* position
100 type file
= decl list
* exp option