lean4-htt/tests/lean/run/name_mangling.lean
Sebastian Ullrich 2823bebd23 refactor(library/init/lean/parser/parsec): message.pos: replace with iterator
This allows efficient recovery from a parse error as well as implementing
`has_to_string` for `message`
2018-07-30 10:38:00 -07:00

19 lines
791 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
open tactic
meta def check (s : string) : tactic unit :=
match id.run $ parsec.parse (identifier : parsec' _) 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 >> 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