Files
lean4/tests/playground/cmdparsertest1.lean
2020-10-27 18:29:19 -07:00

41 lines
1.2 KiB
Lean4
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Lean.Parser.Command
open Lean
open Lean.Parser
def testParser (input : String) : IO Unit :=
do
env mkEmptyEnvironment;
cmdPTables builtinCommandParsingTable.get;
stx IO.ofExcept $ runParser env cmdPTables input "<input>" "command";
IO.println stx
def test (is : List String) : IO Unit :=
is.mfor $ fun input => do
IO.println input;
testParser input
def main (xs : List String) : IO Unit :=
do
IO.println Command.declaration.info.firstTokens;
test [
"@[inline] def x := 2",
"protected def length.{u} {α : Type u} : List α → Nat
| [] := 0
| (a::as) := 1 + length as",
"/-- doc string test -/ private theorem bla (x : Nat) : x = x := Eq.refl x",
"class Alternative (f : Type u → Type v) extends Applicative f : Type (max (u+1) v) :=
(failure : ∀ {α : Type u}, f α)
(orelse : ∀ {α : Type u}, f α → f α → f α)
",
"local attribute [instance] foo bla",
"attribute [inline] test",
"open Lean (hiding Name)",
"reserve infixr ` `:30",
"reserve prefix `¬`:40",
"infixr ` ^ ` := Pow.pow",
"notation f ` $ `:1 a:0 := f a",
"notation `Prop` := Sort 0",
"notation `∅` := EmptyCollection.emptyc _",
"notation `⟦`:max a `⟧`:0 := Quotient.mk a"
]