xo-parser: feat: + parser.has_incomplete_expr()

This commit is contained in:
Roland Conybeare 2024-08-06 09:42:38 -04:00
commit a4848044ea
2 changed files with 11 additions and 0 deletions

View file

@ -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)
**/

View file

@ -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