feat(frontends/lean): change default precedence to 1
This commit is contained in:
parent
e2fa981e89
commit
40fb66bf07
6 changed files with 14 additions and 13 deletions
|
@ -37,9 +37,6 @@ precedence `∘`:60
|
|||
precedence `∘'`:60
|
||||
precedence `on`:1
|
||||
precedence `$`:1
|
||||
precedence `-[`:1
|
||||
precedence `]-`:1
|
||||
precedence `⟨`:1
|
||||
|
||||
infixr ∘ := compose
|
||||
infixr ∘' := dcompose
|
||||
|
|
|
@ -10,7 +10,7 @@ open decidable tactic eq.ops
|
|||
definition ite (c : Prop) [H : decidable c] {A : Type} (t e : A) : A :=
|
||||
decidable.rec_on H (assume Hc, t) (assume Hnc, e)
|
||||
|
||||
notation `if` c `then` t `else` e:45 := ite c t e
|
||||
notation `if` c `then` t:45 `else` e:45 := ite c t e
|
||||
|
||||
theorem if_pos {c : Prop} [H : decidable c] (Hc : c) {A : Type} {t e : A} : (if c then t else e) = t :=
|
||||
decidable.rec
|
||||
|
|
|
@ -130,7 +130,7 @@ static name parse_quoted_symbol_or_token(parser & p, buffer<token_entry> & new_t
|
|||
if (!old_prec || prec != *old_prec)
|
||||
new_tokens.push_back(token_entry(tkcs, prec));
|
||||
} else if (!get_precedence(get_token_table(env), tkcs)) {
|
||||
new_tokens.push_back(token_entry(tkcs, 0));
|
||||
new_tokens.push_back(token_entry(tkcs, LEAN_DEFAULT_PRECEDENCE));
|
||||
}
|
||||
return tk;
|
||||
} else if (p.curr_is_keyword()) {
|
||||
|
@ -253,12 +253,12 @@ static action parse_action(parser & p, name const & prev_token, unsigned default
|
|||
*/
|
||||
static unsigned get_default_prec(optional<parse_table> const & pt, name const & tk) {
|
||||
if (!pt)
|
||||
return 0;
|
||||
return LEAN_DEFAULT_PRECEDENCE;
|
||||
if (auto at = pt->find(tk)) {
|
||||
if (at->first.kind() == notation::action_kind::Expr)
|
||||
return at->first.rbp();
|
||||
}
|
||||
return 0;
|
||||
return LEAN_DEFAULT_PRECEDENCE;
|
||||
}
|
||||
|
||||
static notation_entry parse_notation_core(parser & p, bool overload, buffer<token_entry> & new_tokens) {
|
||||
|
|
|
@ -111,7 +111,7 @@ void init_token_table(token_table & t) {
|
|||
|
||||
auto it3 = aliases;
|
||||
while (it3->first) {
|
||||
t = add_token(t, it3->first, it3->second);
|
||||
t = add_token(t, it3->first, it3->second, 0);
|
||||
it3++;
|
||||
}
|
||||
t = add_token(t, g_arrow_unicode, "->", get_arrow_prec());
|
||||
|
|
|
@ -11,6 +11,10 @@ Author: Leonardo de Moura
|
|||
#include "util/name.h"
|
||||
#include "util/lua.h"
|
||||
|
||||
#ifndef LEAN_DEFAULT_PRECEDENCE
|
||||
#define LEAN_DEFAULT_PRECEDENCE 1
|
||||
#endif
|
||||
|
||||
namespace lean {
|
||||
unsigned get_max_prec();
|
||||
unsigned get_arrow_prec();
|
||||
|
@ -22,9 +26,9 @@ class token_info {
|
|||
public:
|
||||
token_info():m_command(true) {}
|
||||
token_info(char const * val):
|
||||
m_command(true), m_token(val), m_value(val), m_precedence(0) {}
|
||||
m_command(true), m_token(val), m_value(val), m_precedence(LEAN_DEFAULT_PRECEDENCE) {}
|
||||
token_info(char const * token, char const * val):
|
||||
m_command(true), m_token(token), m_value(val), m_precedence(0) {}
|
||||
m_command(true), m_token(token), m_value(val), m_precedence(LEAN_DEFAULT_PRECEDENCE) {}
|
||||
token_info(char const * val, unsigned prec):
|
||||
m_command(false), m_token(val), m_value(val), m_precedence(prec) {}
|
||||
token_info(char const * token, char const * val, unsigned prec):
|
||||
|
@ -40,8 +44,8 @@ token_table mk_token_table();
|
|||
token_table mk_default_token_table();
|
||||
token_table add_command_token(token_table const & s, char const * token);
|
||||
token_table add_command_token(token_table const & s, char const * token, char const * val);
|
||||
token_table add_token(token_table const & s, char const * token, unsigned prec = 0);
|
||||
token_table add_token(token_table const & s, char const * token, char const * val, unsigned prec = 0);
|
||||
token_table add_token(token_table const & s, char const * token, unsigned prec = LEAN_DEFAULT_PRECEDENCE);
|
||||
token_table add_token(token_table const & s, char const * token, char const * val, unsigned prec = LEAN_DEFAULT_PRECEDENCE);
|
||||
void for_each(token_table const & s, std::function<void(char const *, token_info const&)> const & fn);
|
||||
void display(std::ostream & out, token_table const & s);
|
||||
token_table const * find(token_table const & s, char c);
|
||||
|
|
|
@ -9,7 +9,7 @@ constant x : N
|
|||
constant y : N
|
||||
constant z : N
|
||||
infixr `∧`:25 := and
|
||||
notation `if` c `then` t `else` e := ite c t e
|
||||
notation `if` c `then` t:45 `else` e:45 := ite c t e
|
||||
check if p ∧ q then f x else y
|
||||
check if p ∧ q then q else y
|
||||
constant list : Type.{1}
|
||||
|
|
Loading…
Reference in a new issue