lean4-htt/tests/lean/1363.lean
Henrik Böving b7db82894b
feat: generalized Parsec (#4774)
For experimentation by @the-sofi-uwu.

I also have an efficient number parser in LeanSAT that I am planning to
upstream after we have sufficiently bikeshed this change.
2024-08-06 15:17:23 +00:00

25 lines
519 B
Text
Raw 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.Data.Parsec
open Lean Parsec String
@[macro_inline] -- Error
def f : Nat → Nat
| 0 => 0
| n + 1 => f n
@[macro_inline] -- Error
def g : Nat → Nat
| 0 => 0
| n + 1 => g n
termination_by x => x
@[macro_inline] -- Error
def h : Nat → Nat → Nat
| 0, _ => 0
| n + 1, m => h n m
termination_by x y => x
@[macro_inline] -- Error
partial def skipMany (p : Parser α) (it : String.Iterator) : Parser PUnit := do
match p it with
| .success it _ => skipMany p it
| .error _ _ => pure ()