-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathDIDParser.g4
52 lines (36 loc) · 1.18 KB
/
DIDParser.g4
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
parser grammar DIDParser;
options {
tokenVocab = DIDLexer;
}
program: defination* actor?;
defination: Type Name Eq datatype Semicolon;
actor: Service Name? Colon (tuptype Arrow)? (actortype | Name);
actortype: LeftB (methodtype Semicolon)* RightB;
datatype:
Name # Name
| PrimType # Primitive
| comptype # Component;
comptype: constype | reftype;
constype:
OPT datatype # Option
| VEC datatype # Vector
| RECORD LeftB RightB # EmptyRecord
| RECORD LeftB recordfield (Semicolon recordfield)* Semicolon? RightB # Record
| VARIANT LeftB RightB # EmptyVariant
| VARIANT LeftB variantfield (Semicolon variantfield)* Semicolon? RightB # Variant;
recordfield:
Name Colon datatype # RecordKV
| datatype # RecordData;
variantfield:
Name Colon datatype # VariantKV
| Name # VariantName;
reftype: FUNC functype | Service actortype;
functype: tuptype Arrow tuptype funcann?;
tuptype:
LeftP RightP # EmptyTuple
| LeftP argtypes RightP # Tuple;
argtypes:
datatype (Comma datatype)* Comma?
| Name Colon datatype;
funcann: Query # Query | CompositeQuery #CompositeQuery | Oneway # Oneway;
methodtype: Name Colon functype;