lean4-htt/tests/lean/run/name_mangling.lean
Sebastian Ullrich 0f7c0ac8bf feat(init/lean/parser/parser): make a monad transformer
Also move parser combinators into the more specific namespace `init.lean.parser.parser_t`.
2018-06-04 12:57:23 +02:00

19 lines
805 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 init.lean.name_mangling init.lean.parser.identifier
open lean lean.parser lean.parser.parser_t
open tactic
meta def check (s : string) : tactic unit :=
match id.run $ parse identifier s with
| except.ok n :=
trace (name.mangle n) >>
if name.demangle (name.mangle n) = some n then exact `(true)
else trace ("mangling failed at " ++ s) >> exact `(false)
| except.error ex := trace (ex.to_string s) >> exact `(false)
example : by check "_αβ" := trivial
example : by check "αβ" := trivial
example : by check "nat.add" := trivial
example : by check "test.bla.foo" := trivial
example : by check "t21'αβ._₁._12" := trivial
example : by check "nat" := trivial
example : by check "nat.equations._eqn1" := trivial