27 bool contains_special_symbols = ((c ==
'-') || isdigit(c));
29 for(std::string::const_iterator i=s.begin(); !contains_special_symbols && i!=s.end(); ++i)
31 if (*i==
'\\' || *i==
'"' || *i==
'(' || *i==
')' || *i==
'[' || *i==
']' || *i==
',' || *i==
' ' || *i==
'\n' || *i==
'\t' || *i==
'\r')
33 contains_special_symbols=
true;
37 if (contains_special_symbols)
41 for(std::string::const_iterator i=s.begin(); i!=s.end(); ++i)
104 catch (std::runtime_error& e)
123 m_stream << atermpp::down_cast<aterm_int>(t).value();
129 const aterm_list& list = down_cast<aterm_list>(t);
132 if (it!=list.
begin())
154 for (std::size_t i = 1; i < appl.
function().arity(); i++)
203 std::array<char, 32> number;
204 auto it = number.
begin();
221 return aterm_int(
static_cast<std::size_t
>(atol(number.data())));
244 throw std::runtime_error(std::string(
"Missing ") + end +
" while parsing a list term");
258 s <<
"Error occurred at line " <<
m_line <<
", col " <<
m_column <<
" near: ";
277 catch (std::ios::failure&)
304 throw std::runtime_error(
"Premature end of file while parsing.");
307 while (isspace(
character) && skip_whitespace);
382 std::stringstream ss(s);
An integer term stores a single std::size_t value. It carries no arguments.
aterm_transformer * m_transformer
const_iterator end() const
Returns a const_iterator pointing past the last argument.
const_iterator begin() const
Returns an iterator pointing to the first argument.
const function_symbol & function() const
Returns the function symbol belonging to an aterm.
std::size_t arity() const
Return the arity (number of arguments) of the function symbol (function_symbol).
const std::string & name() const
Return the name of the function_symbol.
size_type size() const
Returns the size of the term_list.
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
Reads terms in textual format from an input stream.
std::size_t m_history_limit
Determines the maximum number of characters that are stored.
std::size_t m_column
The column of the current character.
std::deque< char > m_history
Stores the characters that have been read so-far.
std::string print_parse_error_position()
aterm_int parse_aterm_int(int &character)
Parses an std::size_t as an aterm_int.
aterm parse_aterm(int &character)
Parse a term from the input stream and return it.
text_aterm_istream(std::istream &os)
std::string parse_quoted_string(int &character)
Reads a quoted string from the stream.
aterm parse_aterm_appl(const std::string &function_name, int &character)
Parses an "f"(t0, ..., tn) application as an aterm.
int next_char(bool skip_whitespace=true, bool required=false)
aterm_list parse_aterm_list(int &character, char begin, char end)
Parses a list of arguments [...] as terms.
std::string parse_unquoted_string(int &character)
Reads an unquoted string from the stream.
void get(aterm &t) override
Reads an aterm from this stream.
int character
The last character that was read.
std::size_t m_line
The line number of the current character.
Writes terms in textual format to an output stream.
bool m_newline
Indicates that terms are separated by a newline.
void write_term_line(const aterm &term)
Writes a term in textual format on the same line.
void put(const aterm &term) override
Write the given term to the stream.
text_aterm_ostream(std::ostream &os, bool newline=false)
bool type_is_list() const noexcept
Dynamic check whether the term is an aterm_list.
bool type_is_appl() const noexcept
Dynamic check whether the term is an aterm.
bool type_is_int() const noexcept
Dynamic check whether the term is an aterm_int.
const_iterator end() const
const_iterator begin() const
The main namespace for the aterm++ library.
std::ostream & operator<<(std::ostream &out, const atermpp::aterm &t)
Send the term in textual form to the ostream.
static void write_string_with_escape_symbols(const std::string &s, std::ostream &os)
term_list< Term > reverse(const term_list< Term > &l)
Returns the list with the elements in reversed order.
aterm read_term_from_string(const std::string &s)
Reads an aterm from a string. The string can be in either binary or text format.
void write_term_to_text_stream(const aterm &t, std::ostream &os)
Writes term t to a stream in textual format.
void read_term_from_text_stream(std::istream &is, aterm &t)
Reads a term from a stream which contains the term in textual format.