simple.cc - generated code example
[prop.git] / include / AD / automata / iolexerbuf.h
blob54b8aa34a8ec298f80ef25ced852143fbb19d413
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 welcomed 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(read crave for)
19 // any suggestions and help from the users.
21 // Allen Leung (leunga@cs.nyu.edu)
22 // 1994-1995
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef iostream_lexer_buffer_h
26 #define iostream_lexer_buffer_h
28 #include <AD/automata/lexerbuf.h> // lexer buffer
29 #include <iostream>
31 //////////////////////////////////////////////////////////////////////////////
32 // IOstream based lexer buffers.
33 //////////////////////////////////////////////////////////////////////////////
34 class IOLexerBuffer : public LexerBuffer {
35 public:
36 ///////////////////////////////////////////////////////////////////////////
37 // Type definitions
38 ///////////////////////////////////////////////////////////////////////////
39 typedef LexerBuffer Super;
40 typedef Super::Symbol Symbol;
41 typedef Super::State State;
42 typedef Super::Offset Offset;
43 typedef Super::Rule Rule;
45 protected:
46 ///////////////////////////////////////////////////////////////////////////
47 // Internal buffer and other members
48 ///////////////////////////////////////////////////////////////////////////
49 size_t buffer_size; // size of the buffer
50 std::istream * input; // input stream
52 public:
53 ///////////////////////////////////////////////////////////////////////////
54 // Constructor and destructor
55 ///////////////////////////////////////////////////////////////////////////
56 IOLexerBuffer();
57 IOLexerBuffer(std::istream&);
58 virtual ~IOLexerBuffer();
60 ///////////////////////////////////////////////////////////////////////////
61 // Mutators
62 ///////////////////////////////////////////////////////////////////////////
63 virtual void set_stream (std::istream&);
65 protected:
66 ///////////////////////////////////////////////////////////////////////////
67 // Default method for filling the buffer.
68 // This should be redefined in derive classes
69 ///////////////////////////////////////////////////////////////////////////
70 virtual size_t fill_buffer();
71 virtual size_t read_buffer(char *, size_t);
72 void allocate_buffer(size_t);
75 #endif