initial
[prop.git] / include / AD / automata / ll1gen.h
blob017a5e1e0247c93e0c36f4f4f995422c5a022ffc
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 LL1_parser_generator_h
26 #define LL1_parser_generator_h
29 // Class |LL1| represents a parser generated by a LL(1) grammar.
30 // The algorithm used is the one described in \cite{FL-1988}.
33 #include <iostream.h> // Standard C++ I/O stream
34 #include <AD/automata/grammar.h> // Canonical parser grammar
35 #include <AD/automata/sparsdfa.h> // Compressed sparse dfa
37 class LL1Gen : protected SparseDFA {
39 LL1Gen(const LL1Gen&); // no copy constructor
40 void operator = (const LL1Gen&); // no assignment
42 protected:
44 ///////////////////////////////////////////////////////////////////////////
45 // Import and inherit some types
46 ///////////////////////////////////////////////////////////////////////////
47 typedef Grammar::NonTerminal NonTerminal;
48 typedef Grammar::Terminal Terminal;
49 typedef Grammar::Action Action;
50 typedef Grammar::Production Production;
52 typedef SparseDFA Super;
53 typedef Super::State State;
54 typedef Super::Offset Offset;
55 typedef Super::Symbol Symbol;
56 typedef Super::Rule Rule;
58 public:
60 ///////////////////////////////////////////////////////////////////////////
61 // Constructor and destructor
62 ///////////////////////////////////////////////////////////////////////////
63 LL1Gen();
64 ~LL1Gen();
66 ///////////////////////////////////////////////////////////////////////////
67 // Compilation and code emission
68 ///////////////////////////////////////////////////////////////////////////
69 virtual void compile (const Grammar& G);
70 virtual ostream& gen_code (ostream&, const char []) const;
73 #endif