-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLetSeqExtension.xstw
54 lines (44 loc) · 1.37 KB
/
LetSeqExtension.xstw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module LetSeqExtension;
extension {
lexical syntax
"let" -> Keyword
"in" -> Keyword
lexical restrictions
"let" "in" -/- [0-9a-zA-Z]
context-free syntax
"let" Bindings "in" Term -> Term {cons("Let")}
context-free syntax
ID "=" Term -> Binding
Binding -> Bindings
Binding ";" Bindings -> Bindings
context-free priorities
{ Term Term -> Term
Term "+" Term -> Term } >
"let" Bindings "in" Term -> Term
lexical syntax
"bs" [0-9a-zA-Z]* -> MVBindings
lexical restrictions
MVBindings -/- [0-9a-zA-Z]
variables
MVBindings -> Bindings {prefer}
inductive definitions
T-LetSeq1:
(C |- t1 : T1) (C,x:T1 |- let bs in t2 : T2)
--------------------------------------------
C |- let x = t1; bs in t2 : T2
T-LetSeq2:
(C |- t1 : T1) (C,x:T1 |- t2 : T2)
----------------------------------
C |- let x = t1 in t2 : T2
desugarings
{ (C |- t1 : T1) (C,x:T1 |- let bs in t2 : T2)
--------------------------------------------
C |- [ let x = t1; bs in t2 ] : T2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>
(\x:T1. let bs in t2) t1 }
{ (C |- t1 : T1) (C,x:T1 |- t2 : T2)
----------------------------------
C |- [ let x = t1 in t2 ] : T2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>
(\x:T1. t2) t1 }
}