diff --git a/include/xo/parser/parser.hpp b/include/xo/parser/parser.hpp index e4e8943a..deabaab8 100644 --- a/include/xo/parser/parser.hpp +++ b/include/xo/parser/parser.hpp @@ -327,6 +327,12 @@ namespace xo { return exprstatetype::invalid; } + /** true iff parser contains state for an incomplete expression. + * For this to be true, parser must have consumed at least one token + * since end of last toplevel expression + **/ + bool has_incomplete_expr() const; + /** put parser into state for beginning of a translation unit * (i.e. input stream) **/ diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp index 8a60bbbd..71da1798 100644 --- a/src/parser/parser.cpp +++ b/src/parser/parser.cpp @@ -689,6 +689,11 @@ namespace xo { // ----- parser ----- + bool + parser::has_incomplete_expr() const { + return !xs_stack_.empty(); + } + void parser::begin_translation_unit() { xs_stack_.push_exprstate