-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code for new style pattern-match parsing
Syntax as described in github issue #286 parses. Examples: > ``case x of 0 => 3 | SUC n when n < 10 => n + 1``; val it = ``PMATCH x [PMATCH_ROW (λ_. 0) (K T) (λ_. 3); PMATCH_ROW (λn. SUC n) (λn. n < 10) (λn. n + 1)]``: term > Datatype `tree = Lf | Nd tree 'a tree`; <<HOL message: Defined type: "tree">> val it = (): unit > ``case t of Lf => 0 | Nd t1 x t2 => x + f t1``; val it = ``PMATCH t [PMATCH_ROW (λ_. Lf) (K T) (λ_. 0); PMATCH_ROW (λ(t1,x,t2). Nd t1 x t2) (K T) (λ(t1,x,t2). x + f t1)]``: term > ``x + case t of Lf => 0 | x .| Nd t1 x t2 => f t1``; <<HOL message: inventing new type variable names: 'a>> val it = ``x + PMATCH t [PMATCH_ROW (λ_. Lf) (K T) (λ_. 0); PMATCH_ROW (λx. Nd t1 x t2) (K T) (λx. f t1)]``: term > ``x + case t of Lf => 0 | t1,t2 .| Nd t1 x t2 => f t1``; val it = ``x + PMATCH t [PMATCH_ROW (λ_. Lf) (K T) (λ_. 0); PMATCH_ROW (λ(t1,t2). Nd t1 x t2) (K T) (λ(t1,t2). f t1)]``: term > ``x + case t of Lf => 0 | t1,t2 .| Nd t1 x t2 when g t2 > 6 => f t1``; val it = ``x + PMATCH t [PMATCH_ROW (λ_. Lf) (K T) (λ_. 0); PMATCH_ROW (λ(t1,t2). Nd t1 x t2) (λ(t1,t2). g t2 > 6) (λ(t1,t2). f t1)]``: term I think we do still need a separate notation to indicate no variables are to be bound, as | .| pat => rhs won't work when .| is an infix. Maybe | ..| pat => rhs This would be needed in a situation where all of the variables in pat have to be read as free (referring to variables occurring in a wider context).
- Loading branch information
Showing
7 changed files
with
160 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters