Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontends/lean/parser): start positions of trailing parser (NuD) nodes #785

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/frontends/lean/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,14 +1425,15 @@ static pair<notation::transition, parse_table> const * get_non_skip(list<pair<no
expr parser::parse_notation(parse_table t, expr * left) {
check_system("parse_notation");
lean_assert(curr() == token_kind::Keyword);
auto p = pos();
auto cur_pos = pos();
auto p = left ? expr_ast(*left).m_start : cur_pos;
Copy link
Member

@eric-wieser eric-wieser Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this change; I'm probably blind, but it appears that nothing uses p below any more?

auto first_token = get_token_info().value();
auto check_break = [&]() {
try {
check_break_at_pos(break_at_pos_exception::token_context::notation);
} catch (break_at_pos_exception & e) {
// info is stored at position of first notation token
e.m_token_info.m_pos = p;
e.m_token_info.m_pos = cur_pos;
throw;
}
};
Expand Down Expand Up @@ -1542,7 +1543,7 @@ expr parser::parse_notation(parse_table t, expr * left) {
break;
}
case notation::action_kind::Ext:
args.push_back(a.get_parse_fn()(*this, args.size(), args.data(), p));
args.push_back(a.get_parse_fn()(*this, args.size(), args.data(), cur_pos));
ast_ids.push_back(get_id(args.back()));
kinds.push_back(a.kind());
break;
Expand All @@ -1555,8 +1556,8 @@ expr parser::parse_notation(parse_table t, expr * left) {
// TODO(gabriel): search children of t for accepting states
sstream msg;
msg << "invalid expression";
if (p != pos()) {
msg << " starting at " << p.first << ":" << p.second;
if (cur_pos != pos()) {
msg << " starting at " << cur_pos.first << ":" << cur_pos.second;
}
return parser_error_or_expr({msg, pos()});
}
Expand Down