This suggestion has been discussed at Slack. We have decided to use #"c" as notation because we wanted to allow `'` in the beginning of identifiers like in SML and F*. In particular, we wanted to allow users to use 'a 'b 'c for naming type parameters like in SML. However, nobody used this notation. In the Lean standard library, we are using greek letters for naming type parameters. So, there is no real motivation for the ugly #"c" syntax.
19 lines
326 B
Text
19 lines
326 B
Text
import system.io
|
|
|
|
inductive token
|
|
| eof : token
|
|
| plus : token
|
|
| var : string -> token
|
|
|
|
open token
|
|
open option
|
|
|
|
def to_token : string → option token
|
|
| [] := none
|
|
| (c :: cs) :=
|
|
let t : option token := match c with
|
|
| 'x' := some (var "x")
|
|
| 'y' := some (var "y")
|
|
| '+' := some plus
|
|
| _ := none
|
|
end in t
|