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 LL_k_parser_generator_h
26 #define LL_k_parser_generator_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
43 ///////////////////////////////////////////////////////////////////////////
45 ///////////////////////////////////////////////////////////////////////////
46 typedef SparseDFA Super
;
47 typedef Super::State State
;
48 typedef Super::Rule Rule
;
49 typedef Super::Symbol Symbol
;
53 ///////////////////////////////////////////////////////////////////////////
54 // Constructor and destructor
55 ///////////////////////////////////////////////////////////////////////////
57 LLkGen(const Grammar
&);
60 ///////////////////////////////////////////////////////////////////////////
61 // Compilation and code generation
62 ///////////////////////////////////////////////////////////////////////////
63 virtual void compile (const Grammar
&);
64 virtual std::ostream
& gen_code(std::ostream
&, const char []) const;