fix(frontends/lean/pp): avoid parentheses around atomic notation
This commit is contained in:
parent
53a64ac767
commit
e2fa981e89
2 changed files with 18 additions and 0 deletions
|
@ -700,9 +700,21 @@ static bool add_extra_space(name const & tk) {
|
||||||
return tk != "," && tk != "(" && tk != ")";
|
return tk != "," && tk != "(" && tk != ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_atomic_notation(notation_entry const & entry) {
|
||||||
|
if (!entry.is_nud())
|
||||||
|
return false;
|
||||||
|
list<notation::transition> const & ts = entry.get_transitions();
|
||||||
|
if (!is_nil(tail(ts)))
|
||||||
|
return false;
|
||||||
|
return head(ts).get_action().kind() == notation::action_kind::Skip;
|
||||||
|
}
|
||||||
|
|
||||||
auto pretty_fn::pp_notation(notation_entry const & entry, buffer<optional<expr>> & args) -> optional<result> {
|
auto pretty_fn::pp_notation(notation_entry const & entry, buffer<optional<expr>> & args) -> optional<result> {
|
||||||
if (entry.is_numeral()) {
|
if (entry.is_numeral()) {
|
||||||
return some(result(format(entry.get_num())));
|
return some(result(format(entry.get_num())));
|
||||||
|
} else if (is_atomic_notation(entry)) {
|
||||||
|
format fmt = format(head(entry.get_transitions()).get_token());
|
||||||
|
return some(result(fmt));
|
||||||
} else {
|
} else {
|
||||||
using notation::transition;
|
using notation::transition;
|
||||||
buffer<transition> ts;
|
buffer<transition> ts;
|
||||||
|
|
6
tests/lean/run/atomic_notation.lean
Normal file
6
tests/lean/run/atomic_notation.lean
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import logic data.num
|
||||||
|
open num
|
||||||
|
constant f : num → num
|
||||||
|
notation `o`:1 := 10
|
||||||
|
check o + 1
|
||||||
|
check f o + o + o
|
Loading…
Reference in a new issue