ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
COMPILER CONSTRUCTIONGROUP 27MA'AM MARYAM FEROZE
2
3
NON-TERMINALSCFGFIRST SETFOLLOW SET
4
Structure
5
<start><class_def> <start> DT, when, func_def ,iterate, ID, array, yield, attempt,inc_dec, call_func, sealed, void$
6
<MST> <start>
7
8
9
Function Definition
10
<func_def> <DT_func> define ID ( <args> ) { <body> }void
11
<DT_func>voidvoid , int
12
int
13
<args>DT ID <n_args>DT
14
<n_args> , DT ID <n_args>, , E)
15
E
16
<body> <MST>DT, when, func_def ,iterate, ID, array, yield, attempt,inc_dec, call_func$
17
18
OOP
19
<class_def>SEALED GROUP ID {<class_body>}sealed , group$ , }
20
GROUP ID <inheritance> {<class_body>}
21
<inheritance>extends IDextends , implements , ϵID, }
22
implements ID <inheritance 2>
23
ϵ
24
<inheritance 2>, ID <inheritance_2>, , ϵID, }
25
ϵ
26
<class_body><C_MT><S_ST>
ID, #, METHOD, CONSTRUCT, E$,}
27
<C_MT><C_ST> <C_MT> ID, #, METHOD, CONSTRUCT, E$,}
28
ϵ
29
<C_ST>ID <init> ;ID, #, METHOD, CONSTRUCT, E$,}
30
'#' ID <init> ;
31
method
32
construct
33
<method>METHOD <method_header>{<MST>}methodID , # , Method , construct,}
34
<method_header> <DT _or_void> ID (<params>)
DT , void ID, }
35
<DT _or_void> DT | voidDT , void ID, }
36
<constructor>constructor(<param>) {<MST>}constructorID , # , Method , construct,}
37
<params>DT ID <params 2>DT , E}
38
ϵ
39
<params2>, DT ID <params2> , , ϵ}
40
ϵ
41
42
interface
43
<interface>interface ID {<interface_body>}interface$
44
<interface_body><method_sign> ; <interface_body 2>method}
45
<interface_body 2><method_sign> ; <interface_body 2>method , ϵ}
46
ϵ
47
<method _sign>method <DT _or_void> (<params>) method}
48
<DT _or_void> DT DT,void ID , }
49
void
50
51
Body
52
<body><MST>DT, when, func_def ,iterate, ID, array, yield, attempt,inc_dec, call_func$
53
54
MST
55
<MST><SST><MST> DT, when, func_def ,iterate, ID, array, yield, attempt,inc_dec, call_func$
56
ϵ
57
58
SST
59
<SST>DT <dec> <SST>DT, when, func_def ,iterate, ID, array, yield, attempt,inc_dec, call_func
60
array<array> <SST>
61
ID <assign_st> <SST>
62
calling <func_call> <SST>
63
INC_DEC <inc_dec_st> <SST>
64
when <when_otherwise> <SST>
65
iterate <for_loop> <SST>
66
yield <yield_exp> <SST>
67
define<func_def> <SST>
68
attempt<try_catch> <SST>
69
70
Declaration
71
<dec>DT ID <init><list>DT$
72
<init>= <exp><list>=, ID,string,char,float,int,NOT(, E; , , }
73
E
74
<list>; <dec> ; , , }$
75
, ID <init> <list>
76
E
77
If-else
78
<if_else>when (<exp>){<body> } <if_else_tail>when } , $
79
<if_else_tail>check(<exp>){<body>}<if_else_tail> check, otherwise, E } , $
80
otherwise : {<body>} <if_else_tail>
81
E
82
For Loop
83
<for_loop>
iterate (<for_init> ; <cond> ; <update>) { <body> }
iterate
84
<for_init><dec>DT, ID, E;
85
<assign_st>
86
E
87
<cond> <exp>ID, string , char , float , int , NOT ;
88
<update><inc_dec_st>ID, ++ , -- , E )
89
<assign_st>
90
E
91
92
Assign Statement
93
<assign_st> ID <A2> = <exp>ID $ , )
94
<A2> .ID <A2>. , [ , ( , E=, $, )
95
[<exp>] <A2>
96
(<PL>) <F2>
97
E
98
<F2>.ID <A2> . , [ , E= , $ , )
99
[<exp>] <A2>
100
E