blob: b011bc1505522b2d035a1900f4ca514640bc26d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#ifndef INC_ParserSharedInputState_hpp__
#define INC_ParserSharedInputState_hpp__
/* ANTLR Translator Generator
* Project led by Terence Parr at http://www.jGuru.com
* Software rights: http://www.antlr.org/license.html
*
* $Id$
*/
#include <antlr/config.hpp>
#include <antlr/TokenBuffer.hpp>
#include <antlr/RefCount.hpp>
#include <string>
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
namespace antlr {
#endif
/** This object contains the data associated with an
* input stream of tokens. Multiple parsers
* share a single ParserSharedInputState to parse
* the same stream of tokens.
*/
class ANTLR_API ParserInputState {
public:
/** Construct a new ParserInputState
* @param in the TokenBuffer to read from. The object is deleted together
* with the ParserInputState object.
*/
ParserInputState( TokenBuffer* in )
: guessing(0)
, filename()
, input(in)
, inputResponsible(true)
{
}
/** Construct a new ParserInputState
* @param in the TokenBuffer to read from.
*/
ParserInputState( TokenBuffer& in )
: guessing(0)
, filename("")
, input(&in)
, inputResponsible(false)
{
}
virtual ~ParserInputState()
{
if (inputResponsible)
delete input;
}
TokenBuffer& getInput( void )
{
return *input;
}
/// Reset the ParserInputState and the underlying TokenBuffer
void reset( void )
{
input->reset();
guessing = 0;
}
public:
/** Are we guessing (guessing>0)? */
int guessing;
/** What file (if known) caused the problem?
* @todo wrap this one..
*/
ANTLR_USE_NAMESPACE(std)string filename;
private:
/** Where to get token objects */
TokenBuffer* input;
/// Do we need to free the TokenBuffer or is it owned by another..
bool inputResponsible;
// we don't want these:
ParserInputState(const ParserInputState&);
ParserInputState& operator=(const ParserInputState&);
};
/// A reference counted ParserInputState
typedef RefCount<ParserInputState> ParserSharedInputState;
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
}
#endif
#endif //INC_ParserSharedInputState_hpp__
|