2 IO Rule Processing for the moogle/kupo languages
3 Copyright (C) 2002,2001 Justin David Smith, Caltech
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 open Moogle_mlp_pattern
21 module Prog
= Moogle_prog_type
25 Emits a single rule. The result is an expression which will process
26 a_match and evaluate the rule's contents if successful; on failure,
27 the e_fail expression will be evaluated. This is the body of one of
28 the process_rules functions. *)
29 let mlp_of_rule rule a_match e_fail
=
30 (* Determine if the output pattern interns new symbols;
31 also, get the output clause restriction (if any). *)
32 let out_uses_new = rule
.Prog.rule_output
.Prog.opat_new
<> [] in
33 let out_clause = rule
.Prog.rule_output
.Prog.opat_clause
in
35 (* Build the output expression. *)
36 let rule_name = rule
.Prog.rule_name in
37 let rule_input = rule
.Prog.rule_input in
38 let rule_output = rule
.Prog.rule_output in
39 let e_result = mlp_of_output_pattern
rule_name rule_input rule_output in
41 (* Build the match expressions(s). The output expression is
42 embedded in the match expression. The first list of insts
43 is passed into the top of the match. *)
44 let e_match = mlp_of_match_pattern
rule_name out_uses_new out_clause rule_input a_match
e_result e_fail
in