Skip to content

Commit

Permalink
Revert and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ajreynol committed Jan 31, 2024
1 parent 3ea1dc9 commit 62249bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
29 changes: 19 additions & 10 deletions src/expr_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,28 @@ Expr ExprParser::parseExpr()
// will parse a tuple term that stands for a symbolic bound
// variable list. We do this because there are no terms that
// begin ((... currently allowed in this parser.
if (d_lex.peekToken()==Token::LPAREN &&
d_lex.peekToken()==Token::LPAREN)
tok = d_lex.nextToken();
if (tok==Token::LPAREN)
{
nscopes = 1;
bool isLookup = !d_state.getOptions().d_binderFresh;
d_state.pushScope();
std::vector<Expr> vs = parseAndBindSortedVarList(isLookup);
if (vs.empty())
tok = d_lex.peekToken();
d_lex.reinsertToken(Token::LPAREN);
if (tok==Token::LPAREN)
{
d_lex.parseError("Expected non-empty sorted variable list");
nscopes = 1;
bool isLookup = !d_state.getOptions().d_binderFresh;
d_state.pushScope();
std::vector<Expr> vs = parseAndBindSortedVarList(isLookup);
if (vs.empty())
{
d_lex.parseError("Expected non-empty sorted variable list");
}
Expr vl = d_state.mkBinderList(v.getValue(), vs);
args.push_back(vl);
}
Expr vl = d_state.mkBinderList(v.getValue(), vs);
args.push_back(vl);
}
else
{
d_lex.reinsertToken(tok);
}
}
pstack.emplace_back(ParseCtx::NEXT_ARG, nscopes, args);
Expand Down
7 changes: 5 additions & 2 deletions src/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,16 @@ Token Lexer::nextToken()
{
return nextTokenInternal();
}
Token t = d_peeked[0];
d_peeked.erase(d_peeked.begin());
Token t = d_peeked.back();
d_peeked.pop_back();
return t;
}

Token Lexer::peekToken()
{
// since d_peeked is first in, last out, we should not peek more than once
// or the order is swapped.
Assert(d_peeked.empty());
// parse next token
Token t = nextTokenInternal();
// reinsert it immediately
Expand Down

0 comments on commit 62249bf

Please sign in to comment.