1 | case-sensitive // cause that's what Java is |
2 | |
3 | = source |
4 | <sourcepart> <source> = source |
5 | |
6 | ! <int> = translatorcall |
7 | |
8 | <translatorcall> = sourcepart |
9 | |
10 | <classdecl> = sourcepart |
11 | |
12 | <modifiers> class <identifier> <typeparams> = classhead |
13 | |
14 | static = modifier |
15 | public = modifier |
16 | abstract = modifier |
17 | protected = modifier |
18 | final = modifier |
19 | transient = modifier |
20 | volatile = modifier |
21 | synchronized = modifier |
22 | |
23 | = modifiers |
24 | <modifier> <modifiers> = modifiers |
25 | |
26 | <classhead> { } = emptyclass |
27 | |
28 | <emptyclass> = classdecl |
29 | |
30 | <classhead> { <classbody> } = classdecl |
31 | |
32 | <classbody> <classbody> = classbody |
33 | |
34 | ; = classbody |
35 | |
36 | <vardecl> = classbody |
37 | |
38 | <qid> = type |
39 | <qid> <typeparams> = type |
40 | <type> [] = type |
41 | |
42 | <> = typeargs |
43 | < <typelist> > = typeargs |
44 | |
45 | <typeargs> = typeargs_opt |
46 | = typeargs_opt |
47 | |
48 | = typeparams |
49 | < <typeparamlist_opt> > = typeparams |
50 | |
51 | = typeparamlist_opt |
52 | <typeparamlist> = typeparamlist_opt |
53 | |
54 | <typeparam> = typeparamlist |
55 | <typeparam>, <typeparamlist> = typeparamlist |
56 | |
57 | <type> = typeparam |
58 | <type> extends <type> = typeparam |
59 | <type> implements <type> = typeparam |
60 | |
61 | <type> = typelist |
62 | <type>, <typelist> = typelist |
63 | |
64 | <block> = blockorsemicolon |
65 | ; = blockorsemicolon |
66 | |
67 | () = argsdecl2 |
68 | (<argsdecl>) = argsdecl2 |
69 | |
70 | = throws_opt |
71 | throws <typelist> = throws_opt |
72 | |
73 | <modifiers> <type> <identifier> <argsdecl2> <throws_opt> <blockorsemicolon> = method |
74 | |
75 | <modifiers> <identifier> <argsdecl2> <throws_opt> <block> = constructordecl |
76 | <modifiers> * <argsdecl2> <throws_opt> <block> = constructordecl // javax |
77 | |
78 | <constructordecl> = classbody |
79 | <method> = classbody |
80 | |
81 | <classdecl> = classbody // inner classes! |
82 | |
83 | <identifier> = expX |
84 | <quoted> = expX |
85 | <int> = expX |
86 | -<int> = expX |
87 | |
88 | // explist, args |
89 | |
90 | <exp> = actualExplist |
91 | <exp>, <actualExplist> = actualExplist |
92 | <actualExplist> = explist |
93 | = explist |
94 | |
95 | (<explist>) = args |
96 | |
97 | // function calls - precedence? |
98 | |
99 | <identifier> <args> = call |
100 | <call> = expX |
101 | |
102 | // method call - precedence? |
103 | |
104 | <exp>.<call> = methodcall |
105 | <methodcall> = expX |
106 | |
107 | // qualified identifier |
108 | |
109 | <identifier> = qid |
110 | <identifier>.<qid> = qid |
111 | <qid> = expX |
112 | |
113 | // "new" expressions |
114 | |
115 | new <qid> <typeargs_opt> = newexp // JavaX! |
116 | new <qid> <typeargs_opt> <args> = newexp |
117 | <newexp> = exp |
118 | |
119 | // bracketing expressions - gives highest precedence |
120 | |
121 | ( <exp> ) = expX |
122 | |
123 | // binary operators |
124 | |
125 | <expX> = exp3 |
126 | |
127 | <exp3> = exp2 |
128 | <exp2> * <exp3> = exp2 |
129 | <exp2> / <exp3> = exp2 |
130 | |
131 | <exp2> = exp1 |
132 | <exp1> + <exp2> = exp1 |
133 | <exp1> - <exp2> = exp1 |
134 | |
135 | <exp1> = exp0 |
136 | <exp1> < <exp1> = exp0 |
137 | <exp1> > <exp1> = exp0 |
138 | <exp1> != <exp1> = exp0 |
139 | |
140 | = empty // hack... |
141 | <exp1> = <empty> = <exp1> = exp0 |
142 | |
143 | // m1 = minus 1... |
144 | <exp0> = expm1 |
145 | <exp0> ? <exp0> : <exp0> = expm1 // priority? |
146 | |
147 | // casts (where in hierarchy?) |
148 | |
149 | (<type>) <exp1> = exp1 |
150 | |
151 | <expm1> = exp |
152 | |
153 | <type> <identifier> = argsdecl |
154 | <type> * <identifier> = argsdecl // javax |
155 | <argsdecl>, <argsdecl> = argsdecl |
156 | |
157 | // variable declarations (both local and fields) |
158 | |
159 | // simple variable declaration |
160 | |
161 | <modifiers> <type> <identifier> = vardeclShort |
162 | <vardeclShort>; = <vardecl> |
163 | |
164 | // same with initializer |
165 | |
166 | <modifiers> <type> <identifier> = <exp> = vardeclShort |
167 | |
168 | // todo: multiple decls... |
169 | |
170 | <vardecl> = statement |
171 | <classdecl> = statement -- local class declared in code |
172 | |
173 | // empty statement |
174 | |
175 | ; = statement |
176 | |
177 | // if statements! |
178 | |
179 | = else |
180 | else <statement> = else |
181 | |
182 | if (<exp>) <statement> <else> = if |
183 | |
184 | // extra rule because parser has trouble with empty classes at end of stream... |
185 | if (<exp>) <statement> = if |
186 | |
187 | <if> = statement |
188 | |
189 | // empty statement |
190 | |
191 | ; = emptyStatement |
192 | <emptyStatement> = statement |
193 | |
194 | // return statement! |
195 | |
196 | ret = returnKeyword |
197 | return = returnKeyword |
198 | |
199 | <returnKeyword> <exp>; = return |
200 | <return> = statement |
201 | |
202 | // statement list |
203 | |
204 | = statements |
205 | <statement> <statements> = statements |
206 | |
207 | // blocks! |
208 | |
209 | { <statements> } = block |
210 | <block> = statement |
211 | |
212 | // assigments! |
213 | |
214 | <exp> = <exp> = assignmentShort |
215 | <exp> += <exp> = assignmentShort |
216 | <exp> -= <exp> = assignmentShort |
217 | <exp> *= <exp> = assignmentShort |
218 | <exp> /= <exp> = assignmentShort |
219 | // etc... |
220 | |
221 | <assignmentShort>; = statement |
222 | <call>; = statement |
223 | <methodcall>; = statement |
224 | <newexp>; = statement |
225 | |
226 | // for! - gotta look how it is defined exactly... |
227 | |
228 | = for1 |
229 | <vardeclShort> = for1 |
230 | <explist> = for1 |
231 | <assignmentShort> = for1 |
232 | |
233 | <explist> = for2 |
234 | |
235 | for (<for1>; <for2>; <for1>) <statement> = for |
236 | <for> = statement |
237 | |
238 | // foreach |
239 | |
240 | for (<modifiers> <type> <identifier> : <exp>) <statement> = foreach |
241 | <foreach> = statement |
242 | |
243 | // imports |
244 | |
245 | import <qid>; = import |
246 | import <qid>.*; = import |
247 | import static <qid>; = import |
248 | import static <qid>.*; = import |
249 | |
250 | <import> = sourcepart |
251 | |
252 | // synchronized statement |
253 | |
254 | synchronized(<exp>) <statement> = statement |
255 | |
256 | // try / catch |
257 | |
258 | catch (<vardecl>) <block> = catch |
259 | |
260 | finally <block> = catches |
261 | <catch> = catches |
262 | <catch> <catches> = catches |
263 | |
264 | try <block> <catches> = try |
265 | |
266 | <try> = statement |
Began life as a copy of #1002324
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002329 |
Snippet name: | Java(X) Parsing Rules using empty classes (current) |
Eternal ID of this version: | #1002329/1 |
Text MD5: | 5dd9dfd537b7cbb49a52ee9afcd1f134 |
Author: | stefan |
Category: | javax |
Type: | Document |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-02-01 21:54:35 |
Source code size: | 4889 bytes / 266 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 781 / 1220 |
Referenced in: | [show references] |