1 ///////////////////////////////////////////////////////////////////////////////
3 // This file describes the graph rewriting system compiler.
5 ///////////////////////////////////////////////////////////////////////////////
6 #ifndef graph_rewriting_system_compiler_h
7 #define graph_rewriting_system_compiler_h
11 #include "matchcom.ph"
13 ///////////////////////////////////////////////////////////////////////////////
15 // Forward type declarations
17 ///////////////////////////////////////////////////////////////////////////////
18 datatype Pat and Exp and Decl;
20 ///////////////////////////////////////////////////////////////////////////////
22 // Abstract syntax for graph rewriting rules
24 ///////////////////////////////////////////////////////////////////////////////
26 GraphRewritingRule : Loc = // a graph rewriting rule
27 GRSrule { lhs : GRSPat, // antecedent
28 rhs : GRSConclusions // conclusions
31 and GRSPat : Loc = // antecedent of a rule
32 EDGEgpat (Id, List<Pat>) // edge pattern, i.e. pattern on a relation
33 | GUARDgpat (Exp) // guard expressions
34 | NOTgpat (GRSPat) // negation
35 | ANDgpat (GRSPat, GRSPat) // conjunction
36 | ORgpat (GRSPat, GRSPat) // disjunction
37 | FORALLgpat(Id, GRSPat) // universal quantification
39 and GRSConclusion : Loc =
40 ADDEDGEaction (Id, List<Exp>) // add a new edge
41 | DELETEEDGEaction (Id, List<Exp>) // delete an edge
42 | ADDNODEaction (Exp) // add a node
43 | DELETENODEaction (Exp) // delete a node
44 | EMBEDDEDaction (List<Decl>) // any embedded action
46 where type GRSConclusions = List<GRSConclusion>
49 ///////////////////////////////////////////////////////////////////////////////
51 // The interface to the graph rewriting system compiler
53 ///////////////////////////////////////////////////////////////////////////////
54 class GraphRewritingCompiler : virtual public CodeGen,
55 virtual public MatchCompiler
56 { GraphRewritingCompiler(const GraphRewritingCompiler&);
57 void operator = (const GraphRewritingCompiler&);
59 GraphRewritingCompiler();
60 ~GraphRewritingCompiler();
62 void gen_graph_rewriting_system (Id, LabTys, List<GraphRewritingRule>);