We are going to start making drastic changes in the parser, elaborator, attributes, etc. Examples: - No View objects. I am going to implement match_syntax. - No RecT in the parser. I am going to implement parser extensions using an approach similar to the one I used to implement environment extensions. - No Parsec. I will use an approach similar to the one used in the experiment https://github.com/leanprover/lean4/tree/master/tests/playground/parser It is easier to perform these changes with the new frontend disabled. I will slowly re-active it as I apply the changes. cc @kha
32 lines
985 B
Text
32 lines
985 B
Text
/-
|
|
Copyright (c) 2018 Microsoft Corporation. All rights reserved.
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
Authors: Leonardo de Moura, Sebastian Ullrich
|
|
-/
|
|
prelude
|
|
import init.data.nat init.data.rbmap init.lean.format
|
|
|
|
namespace Lean
|
|
|
|
structure Position :=
|
|
(line : Nat)
|
|
(column : Nat)
|
|
|
|
namespace Position
|
|
instance : DecidableEq Position :=
|
|
{decEq := λ ⟨l₁, c₁⟩ ⟨l₂, c₂⟩,
|
|
if h₁ : l₁ = l₂ then
|
|
if h₂ : c₁ = c₂ then isTrue (Eq.recOn h₁ (Eq.recOn h₂ rfl))
|
|
else isFalse (λ contra, Position.noConfusion contra (λ e₁ e₂, absurd e₂ h₂))
|
|
else isFalse (λ contra, Position.noConfusion contra (λ e₁ e₂, absurd e₁ h₁))}
|
|
|
|
protected def lt : Position → Position → Bool
|
|
| ⟨l₁, c₁⟩ ⟨l₂, c₂⟩ := (l₁, c₁) < (l₂, c₂)
|
|
|
|
instance : HasFormat Position :=
|
|
⟨λ ⟨l, c⟩, "⟨" ++ fmt l ++ ", " ++ fmt c ++ "⟩"⟩
|
|
|
|
instance : Inhabited Position := ⟨⟨1, 0⟩⟩
|
|
end Position
|
|
|
|
end Lean
|