initial
[prop.git] / include / AD / automata / llkgen.h
blobbfeee402cc80dd182c1fc30f86485f0c08877950
1 //////////////////////////////////////////////////////////////////////////////
2 // NOTICE:
3 //
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
9 // your programs.
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
16 // code.
18 // This software is still under development and we welcome any suggestions
19 // and help from the users.
21 // Allen Leung
22 // 1994
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef LL_k_parser_generator_h
26 #define LL_k_parser_generator_h
28 #include <iostream.h>
29 #include <AD/automata/grammar.h>
30 #include <AD/automata/sparsdfa.h>
32 //////////////////////////////////////////////////////////////////////////////
33 // LL(k) parser generator class. The algorithm we use is described in
34 // Terrance Parr's thesis on (you guess it) LL(k) parser generation.
35 //////////////////////////////////////////////////////////////////////////////
36 class LLkGen : protected SparseDFA {
38 LLkGen(const LLkGen&); // no copy constructor
39 void operator = (const LLkGen&); // no assignment
41 public:
43 ///////////////////////////////////////////////////////////////////////////
44 // Inherit some types
45 ///////////////////////////////////////////////////////////////////////////
46 typedef SparseDFA Super;
47 typedef Super::State State;
48 typedef Super::Rule Rule;
49 typedef Super::Symbol Symbol;
51 public:
53 ///////////////////////////////////////////////////////////////////////////
54 // Constructor and destructor
55 ///////////////////////////////////////////////////////////////////////////
56 LLkGen();
57 LLkGen(const Grammar&);
58 ~LLkGen();
60 ///////////////////////////////////////////////////////////////////////////
61 // Compilation and code generation
62 ///////////////////////////////////////////////////////////////////////////
63 virtual void compile (const Grammar&);
64 virtual ostream& gen_code(ostream&, const char []) const;
67 #endif