-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavaDB.parser
89 lines (71 loc) · 3.09 KB
/
JavaDB.parser
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
/************************************** L1 Parser ******************************************/
ClassDecl class_declaration =
modifiers.m? CLASS IDENTIFIER owner.o super.s? interfaces.i? class_body.b
{:
return new L1ClassDecl(new Modifiers(m), IDENTIFIER, s, i, b, o);
:}
;
ClassDecl class_declaration =
modifiers.m? CLASS IDENTIFIER type_parameters.p owner.o super.s? interfaces.i? class_body.b
{:
return new L1GenericClassDecl(new Modifiers(m), IDENTIFIER, s, i, b, p, o);
:}
;
Opt owner =
OWNEDBY reference_type.t {: return new Opt(t); :}
;
Expr unary_expression = OWNEROF unary_expression.e {: return new OwnerOfExpr(e); :}
;
/************************************** L2 Parser ******************************************/
ClassDecl class_declaration =
modifiers.m? CLASS IDENTIFIER WITH member_parameters.fs owner.o? super.s? interfaces.i? class_body.b
{:
return new L2ClassDecl(new Modifiers(m), IDENTIFIER, s, i, b, o, fs);
:}
;
ClassDecl class_declaration =
modifiers.m? CLASS IDENTIFIER type_parameters.p WITH member_parameters.fs owner.o? super.s? interfaces.i? class_body.b
{:
return new L2GenericClassDecl(new Modifiers(m), IDENTIFIER, s, i, b, p, o, fs);
:}
;
List member_parameters =
LBRACK member_parameter_list_1.l {: return l; :}
;
List member_parameter_list =
member_parameter_list.l COMMA member_parameter.p {: return l.add(p); :}
| member_parameter.p {: return new List().add(p); :}
;
List member_parameter_list_1 =
member_parameter_1.p {: return new List().add(p); :}
| member_parameter_list.l COMMA member_parameter_1.p {: return l.add(p); :}
;
List method_parameter_args =
type.t1 {: return new List().add(t1); :}
| method_parameter_args.l COMMA type.t1 {: return l.add(t1); :}
;
MemberVariable member_parameter =
type.t1 name.t2 DOT IDENTIFIER {: return new FieldVariable(t1, t2, IDENTIFIER); :}
| type.t1 name.t2 DOT IDENTIFIER LPAREN method_parameter_args.l? RPAREN {: return new MethodVariable(t1, t2, IDENTIFIER, l); :}
;
MemberVariable member_parameter_1 =
member_parameter.m RBRACK {: return m; :}
;
List parfield_access_list =
parfield_access_list.l COMMA parfield_access.p {: return l.add(p); :}
| parfield_access.p {: return new List().add(p); :}
;
List parfield_access_list_1 =
parfield_access_1.p {: return new List().add(p); :}
| parfield_access_list.l COMMA parfield_access_1.p {: return l.add(p); :}
;
ParMemberAccess parfield_access =
name.t DOT IDENTIFIER {: return new ParMemberAccess(t, IDENTIFIER); :}
;
ParMemberAccess parfield_access_1 =
name.t DOT IDENTIFIER RBRACK {: return new ParMemberAccess(t, IDENTIFIER); :}
;
Expr class_instance_creation_expression =
NEW class_or_interface_type.t WITH LBRACK parfield_access_list_1.pl LPAREN argument_list.l? RPAREN subclass_body.b?
{: return new ParMemberClassInstanceExpr(t, l, b, pl); :}
;