xo-reader: misc bugfixes + logging [wip, utests not passing]
This commit is contained in:
parent
22d4c6c601
commit
ac4ee7d6b8
14 changed files with 175 additions and 17 deletions
|
|
@ -56,6 +56,11 @@ namespace xo {
|
|||
n_defexprstatetype,
|
||||
};
|
||||
|
||||
extern const char * defexprstatetype_descr(defexprstatetype x);
|
||||
|
||||
std::ostream &
|
||||
operator<<(std::ostream & os, defexprstatetype x);
|
||||
|
||||
/** @class define_xs
|
||||
* @brief state to provide parsing of a define-expression
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -65,7 +65,10 @@ namespace xo {
|
|||
|
||||
inline std::ostream &
|
||||
operator<< (std::ostream & os, const envframestack * x) {
|
||||
x->print(os);
|
||||
if (x)
|
||||
x->print(os);
|
||||
else
|
||||
os << "nullptr";
|
||||
return os;
|
||||
}
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -189,6 +189,15 @@ namespace xo {
|
|||
x.print(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
inline std::ostream &
|
||||
operator<< (std::ostream & os, const exprstate * x) {
|
||||
if (x)
|
||||
x->print(os);
|
||||
else
|
||||
os << "nullptr";
|
||||
return os;
|
||||
};
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "exprstate.hpp"
|
||||
#include "xo/indentlog/print/vector.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,15 @@ namespace xo {
|
|||
n_parenexprstatetype,
|
||||
};
|
||||
|
||||
extern const char *
|
||||
parenexprstatetype_descr(parenexprstatetype x);
|
||||
|
||||
inline std::ostream &
|
||||
operator<< (std::ostream & os, parenexprstatetype x) {
|
||||
os << parenexprstatetype_descr(x);
|
||||
return os;
|
||||
}
|
||||
|
||||
/** @class paren_xs
|
||||
* @brief state machine for handling parentheses in expressions
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ namespace xo {
|
|||
public:
|
||||
using Expression = xo::ast::Expression;
|
||||
using Variable = xo::ast::Variable;
|
||||
using token_type = token<char>;
|
||||
|
||||
public:
|
||||
parserstatemachine(exprstatestack * p_stack,
|
||||
|
|
@ -42,6 +43,18 @@ namespace xo {
|
|||
void push_envframe(envframe x);
|
||||
void pop_envframe();
|
||||
|
||||
// ----- parsing outputs -----
|
||||
|
||||
void on_symbol(const std::string & symbol);
|
||||
|
||||
// ---- parsing inputs -----
|
||||
|
||||
void on_leftbrace_token(const token_type & tk);
|
||||
void on_rightbrace_token(const token_type & tk);
|
||||
|
||||
/** write human-readable representation on @p os **/
|
||||
void print(std::ostream & os) const;
|
||||
|
||||
public:
|
||||
/** stack of incomplete parser work.
|
||||
* generally speaking, push when to start new work for nested content;
|
||||
|
|
@ -55,6 +68,12 @@ namespace xo {
|
|||
**/
|
||||
rp<Expression> * p_emit_expr_;
|
||||
};
|
||||
|
||||
inline std::ostream &
|
||||
operator<<(std::ostream & os, const parserstatemachine & x) {
|
||||
x.print(os);
|
||||
return os;
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue