1 //////////////////////////////////////////////////////////////////////////////
4 // ADLib, Prop and their related set of tools and documentation are in the
5 // public domain. The author(s) of this software reserve no copyrights on
6 // the source code and any code generated using the tools. You are encouraged
7 // to use ADLib and Prop to develop software, in both academic and commercial
8 // settings, and are free to incorporate any part of ADLib and Prop into
11 // Although you are under no obligation to do so, we strongly recommend that
12 // you give away all software developed using our tools.
14 // We also ask that credit be given to us when ADLib and/or Prop are used in
15 // your programs, and that this notice be preserved intact in all the source
18 // This software is still under development and we welcome any suggestions
19 // and help from the users.
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef first_set_with_k_lookaheads_computation_h
26 #define first_set_with_k_lookaheads_computation_h
28 #include <AD/automata/follow.h>
30 class FirstSet_k
: public FollowSet
{
32 FirstSet_k(const FirstSet_k
&); // no copy constructor
33 void operator = (const FirstSet_k
&); // no assignment
37 ///////////////////////////////////////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////////////
40 typedef FollowSet Super
;
41 typedef Super::Symbol Symbol
;
42 typedef Super::Terminal Terminal
;
43 typedef Super::NonTerminal NonTerminal
;
44 typedef Super::Production Production
;
45 typedef Super::ProductionList ProductionList
;
49 ///////////////////////////////////////////////////////////////////////////
51 ///////////////////////////////////////////////////////////////////////////
52 int K
; // the current number of lookaheads
53 int max_K
; // the maximum number of lookaheads
54 BitSet
*** first_set_k
;
58 ///////////////////////////////////////////////////////////////////////////
59 // Constructor and destructors
60 ///////////////////////////////////////////////////////////////////////////
61 FirstSet_k(const Grammar
&, Mem
&);
64 ///////////////////////////////////////////////////////////////////////////
66 ///////////////////////////////////////////////////////////////////////////
67 virtual void compute_sets(int k
, int max_k
);
69 ///////////////////////////////////////////////////////////////////////////
71 ///////////////////////////////////////////////////////////////////////////
72 inline int k() const { return K
; }
73 inline int max_k() const { return max_K
; }
74 inline const BitSet
& first (int k
, NonTerminal A
) const
75 { return *first_set_k
[k
][A
]; }
77 Bool
first (int k
, BitSet
&, Production
) const;
78 Bool
first (int k
, BitSet
&, Production
, Bool
&) const;