Skip to content

Commit

Permalink
use #check_failure command to erase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Seasawher committed Apr 15, 2024
1 parent 7119967 commit 8e7052d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions lean/main/05_syntax.lean
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ We can now write `MyTerm` in place of things like `1 + 1` and it will be
it just means that the Lean parser can understand it:
-/

def Playground1.test := MyTerm
#check_failure MyTerm
-- elaboration function for 'termMyTerm' has not been implemented
-- MyTerm

Expand Down Expand Up @@ -182,7 +182,7 @@ scoped syntax "βŠ₯" : term -- βŠ₯ for false
scoped syntax "⊀" : term -- ⊀ for true
scoped syntax:40 term " OR " term : term
scoped syntax:50 term " AND " term : term
#check βŠ₯ OR (⊀ AND βŠ₯) -- elaboration function hasn't been implemented but parsing passes
#check_failure βŠ₯ OR (⊀ AND βŠ₯) -- elaboration function hasn't been implemented but parsing passes

end Playground2

Expand Down Expand Up @@ -214,7 +214,7 @@ will re-embed it into the `term` category:
-/

syntax "[Bool|" boolean_expr "]" : term
#check [Bool| βŠ₯ AND ⊀] -- elaboration function hasn't been implemented but parsing passes
#check_failure [Bool| βŠ₯ AND ⊀] -- elaboration function hasn't been implemented but parsing passes

/-!
### Syntax combinators
Expand Down Expand Up @@ -275,20 +275,20 @@ add this to the `term` category:
-/

syntax "bin(" binNumber ")" : term
#check bin(Z, O, Z, Z, O) -- elaboration function hasn't been implemented but parsing passes
#check_failure bin(Z, O, Z, Z, O) -- elaboration function hasn't been implemented but parsing passes
#check bin() -- fails to parse because `binNumber` is "one or many": expected 'O' or 'Z'

syntax binNumber' := binDigit,* -- note the *
syntax "emptyBin(" binNumber' ")" : term
#check emptyBin() -- elaboration function hasn't been implemented but parsing passes
#check_failure emptyBin() -- elaboration function hasn't been implemented but parsing passes

/-!
Note that nothing is limiting us to only using one syntax combinator per parser,
we could also have written all of this inline:
-/

syntax "binCompact(" ("Z" <|> "O"),+ ")" : term
#check binCompact(Z, O, Z, Z, O) -- elaboration function hasn't been implemented but parsing passes
#check_failure binCompact(Z, O, Z, Z, O) -- elaboration function hasn't been implemented but parsing passes

/-!
As a final feature, let's add an optional string comment that explains the binary
Expand All @@ -297,8 +297,8 @@ literal being declared:

-- The (...)? syntax means that the part in parentheses is optional
syntax "binDoc(" (str ";")? binNumber ")" : term
#check binDoc(Z, O, Z, Z, O) -- elaboration function hasn't been implemented but parsing passes
#check binDoc("mycomment"; Z, O, Z, Z, O) -- elaboration function hasn't been implemented but parsing passes
#check_failure binDoc(Z, O, Z, Z, O) -- elaboration function hasn't been implemented but parsing passes
#check_failure binDoc("mycomment"; Z, O, Z, Z, O) -- elaboration function hasn't been implemented but parsing passes

/-!
## Operating on Syntax
Expand Down Expand Up @@ -559,9 +559,9 @@ the bound variables, we refer the reader to the macro chapter.
1. Create an "urgent minus πŸ’€" notation such that `5 * 8 πŸ’€ 4` returns `20`, and `8 πŸ’€ 6 πŸ’€ 1` returns `3`.
**a)** Using `notation` command.
**b)** Using `infix` command.
**c)** Using `syntax` command.
**a)** Using `notation` command.
**b)** Using `infix` command.
**c)** Using `syntax` command.
Hint: multiplication in Lean 4 is defined as `infixl:70 " * " => HMul.hMul`.
Expand Down
2 changes: 1 addition & 1 deletion lean/main/07_elaboration.lean
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def myanonImpl : TermElab := fun stx typ? => do
elabTerm stx typ -- call term elaboration recursively

#check (⟨⟨1, sorry⟩⟩ : Fin 12) -- { val := 1, isLt := (_ : 1 < 12) } : Fin 12
#check ⟨⟨1, sorry⟩⟩ -- expected type must be known
#check_failure ⟨⟨1, sorry⟩⟩ -- expected type must be known
#check (⟨⟨0⟩⟩ : Nat) -- type doesn't have exactly one constructor
#check (⟨⟨⟩⟩ : Nat β†’ Nat) -- type is not of the expected form: Nat -> Nat

Expand Down

0 comments on commit 8e7052d

Please sign in to comment.