-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsyntax_extend_memo.txt
More file actions
89 lines (58 loc) · 2.25 KB
/
syntax_extend_memo.txt
File metadata and controls
89 lines (58 loc) · 2.25 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# self hostingするために必要な拡張
## Variant型
http://caml.inria.fr/pub/docs/manual-ocaml/typedecl.html からとってくる
とりあえず、目標は
type-definition ::= "type" typedef { "and" typedef }
typedef ::= typeconstr-name type-information
typeconstr-name ::= lowercase-ident
type-information ::= [type-equation] [type-representation]
type-equation ::= = typexpr
type-representation ::= "=" ["|"] constr-decl { "|" constr-decl }
constr-decl ::= (constr-name ∣ [] ∣ (::)) [ of constr-args ]
constr-name ::= capitalized-ident
constr-args ::= typexpr { * typexpr }
くらいで。(record型はまだいいきがする...)
ところで、typexprは
typexpr ::= ' ident
∣ ( typexpr )
∣ typexpr -> typexpr
∣ typexpr { * typexpr }+
∣ typeconstr
∣ typexpr typeconstr
poly-typexpr ::= typexpr
∣ { ' ident }+ . typexpr
method-type ::= method-name : poly-typexpr
の部分集合をとりそう。(まだ未定)
# type ('x,'y) c = H of ('x list) * ('y list);;
type ('x, 'y) c = H of 'x list * 'y list
# type d = (int,int) c;;
type d = (int, int) c
こんなんあるけどまだいらんよね。
ところで、プログラム全体は
unit-implementation ::= [ module-items ] (from 7.12 Compilation units)
module-items ::= {;;} ( definition ∣ expr ) { {;;} ( definition ∣ ;; expr) } {;;} (from 7.11 Module expressions (module implementations))
なので、 これに全体が従いそう。
definition ::= let [rec] let-binding { and let-binding }
∣ type-definition
∣ open module-path
さらにこれ。(openの実装はまだ先)
match は、
match expr with pattern-matching
であり、さらに
pattern-matching ::= [ | ] pattern [when expr] -> expr { | pattern [when expr] -> expr }
(whenはまだ先)
pattern ::= value-name
∣ _
∣ pattern as value-name
∣ ( pattern )
∣ pattern "|" pattern
∣ constr pattern
∣ pattern { , pattern }+
∣ pattern :: pattern
は、これくらい。( as はまだ先(か実装しないか)ぽい)
# mliについて
specification ::=
| val value-name : typexpr
∣ type-definition
∣ open module-path
くらい。