1 #ifndef interface_to_the_scanner_h
2 #define interface_to_the_scanner_h
4 #include <AD/generic/generic.h>
8 /////////////////////////////////////////////////////////////////////////////
9 // An environment of pattern variables is implemented as a pair of
10 // stacks, one caching the current set of bindings and one registering
11 // the lexical scope boundaries.
12 /////////////////////////////////////////////////////////////////////////////
15 PatternVarEnv(const PatternVarEnv
&); // no copy constructor
16 void operator = (const PatternVarEnv
&); // no assignment
20 //////////////////////////////////////////////////////////////////////////
21 // The environment is implemented as two stacks, one storing
22 // the bindings and the other storing the highwater mark of each scope.
23 //////////////////////////////////////////////////////////////////////////
25 class PatternVarEnv_Impl
* impl
;
29 //////////////////////////////////////////////////////////////////////////
30 // Constructor and destructor
31 //////////////////////////////////////////////////////////////////////////
32 PatternVarEnv (int max_size
= 256, int max_levels
= 256);
35 //////////////////////////////////////////////////////////////////////////
36 // Add binding and lookup binding
37 //////////////////////////////////////////////////////////////////////////
38 Exp
add( Id
, // name of pattern variable
39 Exp
, // binding expression
40 Ty
, // type of pattern variable
41 Polarity
= ISpositive
// polarity of the pattern
43 Exp
lookup(Id
, Bool
* = 0); // lookup old binding, returns NIL if not found.
44 // returns true as second argument iff the
45 // binding is from the current scope.
46 Exp
guard (); // current guard expression
47 Exp
guard (Exp
); // current guard expression
49 Bool
separate_guard ();
51 //////////////////////////////////////////////////////////////////////////
52 // Enter and leave scope.
53 // As a default, we allow only linear patterns.
54 //////////////////////////////////////////////////////////////////////////
55 void new_scope( Bool linear_patterns
= true, // enters new scope
56 Bool separate_guard
= false, // separate the guard
57 Bool treegrammar
= false ); // tree grammar mode
58 void old_scope(); // returns to old scope
61 extern PatternVarEnv pv_env
;