00001 00002 #ifndef __PATTERNMATCHER__ 00003 #define __PATTERNMATCHER__ 00004 00005 using namespace std; 00006 #include <vector> 00007 #include "tlib.hh" 00008 00009 struct Automaton; 00010 00011 /* Create a pattern matching automaton from the given list of rules. */ 00012 00013 Automaton *make_pattern_matcher(Tree R); 00014 00015 /* Apply the pattern matcher to a single argument, starting from a given state 00016 s. Returns the resulting state, modifies the variable bindings E 00017 accordingly, and sets C to the resulting closure if a final state is 00018 reached. Result will be -1 to indicate a matching failure, and C will be 00019 set to nil if no final state has been reached yet. */ 00020 00021 int apply_pattern_matcher(Automaton *A, // automaton 00022 int s, // start state 00023 Tree X, // arg to be matched 00024 Tree& C, // output closure (if any) 00025 vector<Tree>& E); // modified output environments 00026 00027 #endif