10 #ifndef TEUCHOS_READER_HPP
11 #define TEUCHOS_READER_HPP
78 void read_stream(
any& result, std::istream& stream, std::string
const& stream_name_in);
84 void read_string(
any& result, std::string
const&
string, std::string
const& string_name);
90 void read_file(
any& result, std::string
const& file_name);
114 virtual void at_shift(
any& result,
int token, std::string& text);
139 virtual void at_reduce(
any& result,
int production, std::vector<any>& rhs);
144 Parser
const& parser;
145 FiniteAutomaton
const& lexer;
150 std::string lexer_text;
151 std::string line_text;
153 std::size_t last_lexer_accept;
154 std::size_t last_lexer_accept_line;
155 std::size_t last_lexer_accept_column;
156 std::string last_lexer_accept_line_text;
158 std::vector<int> parser_stack;
159 std::vector<any> value_stack;
160 std::vector<any> reduction_rhs;
161 std::string stream_name;
167 std::string indent_text;
168 struct IndentStackEntry {
170 std::size_t start_length;
171 std::size_t end_length;
172 IndentStackEntry(std::size_t l, std::size_t s, std::size_t e);
177 std::vector<IndentStackEntry> indent_stack;
181 std::vector<std::size_t> symbol_indentation_stack;
185 void at_token(std::istream& stream);
186 void indent_mismatch();
187 void at_token_indent(std::istream& stream);
188 void at_lexer_end(std::istream& stream);
189 void backtrack_to_last_accept(std::istream& stream);
190 void reset_lexer_state();
191 void update_position(
char c);
192 void error_print_line(std::istream& is, std::ostream& os);
195 class DebugReader :
public Reader {
198 virtual ~DebugReader() {}
200 virtual void at_shift(any& result,
int token, std::string& text);
201 virtual void at_reduce(any& result,
int token, std::vector<any>& rhs);
Reader(ReaderTablesPtr tables_in)
Constructor: accepts an RCP to ReaderTables.
Modified boost::any class for holding a templated value.
void read_file(any &result, std::string const &file_name)
A convenience method for reading a file.
void read_string(any &result, std::string const &string, std::string const &string_name)
A convenience method for reading a string.
Modified boost::any class, which is a container for a templated value.
virtual ~Reader()
Virtual destructor, allows polymorphism.
The main class for users to read text using TeuchosParser.
Declares Teuchos::ReaderTables.
virtual void at_reduce(any &result, int production, std::vector< any > &rhs)
User-overridable REDUCE (production) method.
virtual void at_shift(any &result, int token, std::string &text)
User-overridable SHIFT (token) method.
RCP< const ReaderTables > ReaderTablesPtr
an RCP to a const ReaderTables
void read_stream(any &result, std::istream &stream, std::string const &stream_name_in)
The main method for reading a stream of text.