-
Notifications
You must be signed in to change notification settings - Fork 13
/
rholang.cf
143 lines (126 loc) · 4.54 KB
/
rholang.cf
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
-- Top level contract declaration
DContr. Contr ::= Proc1 ;
-- Processes
PNil. Proc4 ::= "Nil" ;
PValue. Proc4 ::= Value;
PDrop. Proc3 ::= "*" Chan ;
PInject. Proc3 ::= "#" Chan ;
PLift. Proc2 ::= Chan "!" "(" [Proc] ")" ;
PFoldL. Proc1 ::= "sum" "(" Bind "/:" Bind ")" "{" Proc "}" ;
PFoldR. Proc1 ::= "total" "(" Bind ":\\" Bind ")" "{" Proc "}" ;
PInput. Proc1 ::= "for" "(" [Bind] ")" "{" Proc "}" ;
PChoice. Proc1 ::= "select" "{" [CBranch] "}" ;
PMatch. Proc1 ::= "match" Proc "with" [PMBranch] ;
PNew. Proc1 ::= "new" [Var] "in" Proc1 ;
PPrint. Proc1 ::= "print" "(" Proc ")" ;
PConstr. Proc1 ::= Var "(" [Proc] ")" ;
PContr. Proc1 ::= "contract" Var "(" [CPattern] ")" "=" "{" Proc "}" ;
PPar. Proc ::= Proc "|" Proc1 ;
separator nonempty Proc "," ;
_. Proc ::= Proc1 ;
_. Proc1 ::= Proc2 ;
_. Proc2 ::= Proc3 ;
_. Proc3 ::= Proc4 ;
_. Proc4 ::= "{" Proc "}" ;
-- Channels
CVar. Chan ::= Var ;
CQuote. Chan ::= "@" Proc3 ;
-- Variable binding
InputBind. Bind ::= CPattern "<-" Chan ;
CondInputBind. Bind ::= CPattern "<-" Chan "if" Proc ;
separator nonempty Bind ";" ;
-- Pattern match branches
PatternMatch. PMBranch ::= PPattern "=>" "{" Proc "}" ;
separator nonempty PMBranch "" ;
-- Choice branch
Choice. CBranch ::= "case" [Bind] "=>" "{" Proc "}" ;
separator nonempty CBranch "" ;
-- Quantity
QTrue. RhoBool ::= "true" ;
QFalse. RhoBool ::= "false" ;
QBool. Quantity7 ::= RhoBool ;
QInt. Quantity7 ::= Integer ;
QDouble. Quantity7 ::= Double ;
QString. Quantity7 ::= String;
QVar. Quantity7 ::= Var;
QMap. Quantity7 ::= "Map()" ;
QDot. Quantity6 ::= Quantity7 "." Var "(" [Quantity] ")" ;
QNeg. Quantity5 ::= "-" Quantity6 ;
QMult. Quantity4 ::= Quantity4 "*" Quantity5 ;
QDiv. Quantity4 ::= Quantity4 "/" Quantity5 ;
QAdd. Quantity3 ::= Quantity3 "+" Quantity4 ;
QMinus. Quantity3 ::= Quantity3 "-" Quantity4 ;
QLt. Quantity2 ::= Quantity2 "<" Quantity3 ;
QLte. Quantity2 ::= Quantity2 "<=" Quantity3 ;
QGt. Quantity2 ::= Quantity2 ">" Quantity3 ;
QGte. Quantity2 ::= Quantity2 ">=" Quantity3 ;
QEq. Quantity1 ::= Quantity1 "==" Quantity2 ;
QNeq. Quantity1 ::= Quantity1 "!=" Quantity2 ;
_. Quantity ::= Quantity1 ;
_. Quantity1 ::= Quantity2 ;
_. Quantity2 ::= Quantity3 ;
_. Quantity3 ::= Quantity4 ;
_. Quantity4 ::= Quantity5 ;
_. Quantity5 ::= Quantity6 ;
_. Quantity6 ::= Quantity7 ;
_. Quantity7 ::= "(" Quantity ")" ;
separator Quantity "," ;
-- Values
VQuant. Value ::= Quantity ;
EChar. Value ::= Char ;
ETuple. Value ::= "[" [Proc] "]" ;
-- EStruct. Entity ::= Struct ;
-- ECollect. Entity ::= Collect ;
-- StructConstr. Struct ::= Var "{" [Proc] "}" ;
-- CString. Collect ::= String ;
-- EDate. Entity ::= Datetime ;
-- CArray. Collect ::= Array ;
-- CList. Collect ::= List ;
-- Variable patterns
VarPtVar. VarPattern ::= Var ;
VarPtWild. VarPattern ::= "_" ;
separator VarPattern "," ;
-- Process patterns
PPtVar. PPattern4 ::= VarPattern ;
PPtNil. PPattern4 ::= "Nil" ;
PPtVal. PPattern4 ::= ValPattern ;
PPtDrop. PPattern3 ::= "*" CPattern ;
PPtInject. PPattern3 ::= "#" CPattern ;
PPtOutput. PPattern2 ::= CPattern "!" "(" [PPattern] ")" ;
PPtInput. PPattern1 ::= "for" "(" [PatternBind] ")" "{" PPattern "}" ;
PPtMatch. PPattern1 ::= "match" PPattern "with" [PatternPatternMatch] ;
PPtNew. PPattern1 ::= "new" [VarPattern] "in" PPattern1 ;
PPtConstr. PPattern1 ::= Var "(" [PPattern] ")" ;
PPtPar. PPattern ::= PPattern "|" PPattern1 ;
separator PPattern "," ;
coercions PPattern 4 ;
-- Channel patterns
CPtVar. CPattern ::= VarPattern ;
CValPtrn. CPattern ::= ValPattern ;
CPtQuote. CPattern ::= "@" PPattern3 ;
separator CPattern "," ;
-- Bind pattern
PtBind. PatternBind ::= CPattern "<-" CPattern ;
separator nonempty PatternBind ";" ;
-- Pattern match branch pattern
PtBranch. PatternPatternMatch ::= PPattern "=>" "{" PPattern "}" ;
separator nonempty PatternPatternMatch "" ;
-- Value patterns
VPtStruct. ValPattern ::= Var "{" [PPattern] "}" ;
VPtTuple. ValPattern ::= "<" [PPattern] ">" ;
VPtTrue. ValPattern ::= "true" ;
VPtFalse. ValPattern ::= "false" ;
VPtInt. ValPattern ::= Integer ;
VPtDbl. ValPattern ::= Double ;
VPtStr. ValPattern ::= String ;
--VPtString. ValPattern ::= ;
--VPtArray. ValPattern ::= ;
--VPtList. ValPattern ::= ;
separator nonempty ValPattern "," ;
-- Names and variables
token Name (upper (letter | digit | '_' | '\'' | '-' )*) ;
token Var (lower (letter | digit | '_' | '\'' | '-')*) ;
separator nonempty Var "," ;
separator nonempty Name "," ;
comment "//" ;
comment "/*" "*/" ;