42 #ifndef TEUCHOS_READER_HPP
43 #define TEUCHOS_READER_HPP
110 void read_stream(
any& result, std::istream& stream, std::string
const& stream_name_in);
116 void read_string(
any& result, std::string
const&
string, std::string
const& string_name);
122 void read_file(
any& result, std::string
const& file_name);
146 virtual void at_shift(
any& result,
int token, std::string& text);
171 virtual void at_reduce(
any& result,
int production, std::vector<any>& rhs);
176 Parser
const& parser;
177 FiniteAutomaton
const& lexer;
182 std::string lexer_text;
183 std::string line_text;
185 std::size_t last_lexer_accept;
186 std::size_t last_lexer_accept_line;
187 std::size_t last_lexer_accept_column;
188 std::string last_lexer_accept_line_text;
190 std::vector<int> parser_stack;
191 std::vector<any> value_stack;
192 std::vector<any> reduction_rhs;
193 std::string stream_name;
199 std::string indent_text;
200 struct IndentStackEntry {
202 std::size_t start_length;
203 std::size_t end_length;
204 IndentStackEntry(std::size_t l, std::size_t s, std::size_t e);
209 std::vector<IndentStackEntry> indent_stack;
213 std::vector<std::size_t> symbol_indentation_stack;
217 void at_token(std::istream& stream);
218 void indent_mismatch();
219 void at_token_indent(std::istream& stream);
220 void at_lexer_end(std::istream& stream);
221 void backtrack_to_last_accept(std::istream& stream);
222 void reset_lexer_state();
223 void update_position(
char c);
224 void error_print_line(std::istream& is, std::ostream& os);
227 class DebugReader :
public Reader {
230 virtual ~DebugReader() {}
232 virtual void at_shift(any& result,
int token, std::string& text);
233 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.