Commit | Line | Data |
---|---|---|
42198578 AC |
1 | (* HCoop Domtool (http://hcoop.sourceforge.net/) |
2 | * Copyright (c) 2006, Adam Chlipala | |
3 | * | |
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. | |
8 | * | |
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. | |
13 | * | |
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. | |
17 | *) | |
18 | ||
19 | (* Configuration language abstract syntax *) | |
20 | ||
21 | structure Ast = struct | |
22 | ||
23 | open DataStructures | |
24 | ||
25 | (* A description of a predicate on configuration block stacks *) | |
26 | datatype context' = | |
27 | CRoot | |
28 | (* The stack is empty. *) | |
29 | | CConst of string | |
30 | (* The given context name is on top of the stack. *) | |
31 | | CPrefix of context | |
32 | (* Some prefix of the stack matches the context. *) | |
33 | | CNot of context | |
34 | (* The context does not match. *) | |
35 | | CAnd of context * context | |
36 | (* Both contexts match. *) | |
37 | withtype context = context' * position | |
38 | ||
39 | datatype typ' = | |
40 | TBase of string | |
41 | (* Base type *) | |
42 | | TList of typ | |
43 | (* SML 'a list *) | |
44 | | TArrow of typ * typ | |
45 | (* SML -> *) | |
46 | | TAction of context * record * record | |
47 | (* An action that: | |
48 | * - Is valid in the given context | |
49 | * - Expects an environment compatible with the first record | |
50 | * - Modifies it according to the second record *) | |
51 | withtype typ = typ' * position | |
52 | and record = typ StringMap.map | |
53 | ||
54 | datatype exp' = | |
55 | EInt of int | |
56 | (* Constant integer *) | |
57 | | EString of string | |
58 | (* Constant string *) | |
59 | | EList of exp list | |
60 | (* Basic list constructor *) | |
61 | ||
62 | | ELam of string * typ * exp | |
63 | (* Function abstraction *) | |
64 | | EApp of exp * exp | |
65 | (* Function application *) | |
66 | ||
67 | | ESet of string * exp | |
68 | (* Set an environment variable *) | |
69 | | ESeq of exp list | |
70 | (* Monad sequencer; execute a number of commands in order *) | |
71 | | ELocal of exp | |
72 | (* Local execution; execute the action and then restore the previous | |
73 | * environment. *) | |
74 | withtype exp = exp' * position | |
75 | ||
76 | ||
77 | end |