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