Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg @ 18411:dc2e000bed40
SL: add basic support for creating objects and accessing properties
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Tue, 18 Nov 2014 23:02:58 +0100 |
parents | f444ef4684ec |
children | cfb85e1f4ca5 |
comparison
equal
deleted
inserted
replaced
18410:f444ef4684ec | 18411:dc2e000bed40 |
---|---|
200 | 200 |
201 | 201 |
202 Factor<out SLExpressionNode result> | 202 Factor<out SLExpressionNode result> |
203 = (. result = null; .) | 203 = (. result = null; .) |
204 ( | 204 ( |
205 identifier (. Token nameToken = t; .) | 205 identifier (. result = factory.createRead(t); .) |
206 ( | 206 [ |
207 "(" (. List<SLExpressionNode> parameters = new ArrayList<>(); | 207 MemberExpression<out result, result, null, t> |
208 SLExpressionNode parameter; .) | 208 ] |
209 [ | |
210 Expression<out parameter> (. parameters.add(parameter); .) | |
211 { | |
212 "," | |
213 Expression<out parameter> (. parameters.add(parameter); .) | |
214 } | |
215 ] | |
216 ")" (. Token finalToken = t; .) | |
217 (. result = factory.createCall(nameToken, parameters, finalToken); .) | |
218 | | |
219 "=" | |
220 Expression<out SLExpressionNode value> (. result = factory.createAssignment(nameToken, value); .) | |
221 | | |
222 (. result = factory.createRead(nameToken); .) | |
223 ) | |
224 | | 209 | |
225 stringLiteral (. result = factory.createStringLiteral(t); .) | 210 stringLiteral (. result = factory.createStringLiteral(t); .) |
226 | | 211 | |
227 numericLiteral (. result = factory.createNumericLiteral(t); .) | 212 numericLiteral (. result = factory.createNumericLiteral(t); .) |
228 | | 213 | |
232 (. result = factory.createParenExpression(expr, start, length); .) | 217 (. result = factory.createParenExpression(expr, start, length); .) |
233 ) | 218 ) |
234 . | 219 . |
235 | 220 |
236 | 221 |
222 MemberExpression<out SLExpressionNode result, SLExpressionNode receiver, SLExpressionNode assignmentReceiver, Token assignmentName> | |
223 = (. result = null; | |
224 Token nestedAssignmentName = null; .) | |
225 ( | |
226 "(" (. List<SLExpressionNode> parameters = new ArrayList<>(); | |
227 SLExpressionNode parameter; .) | |
228 [ | |
229 Expression<out parameter> (. parameters.add(parameter); .) | |
230 { | |
231 "," | |
232 Expression<out parameter> (. parameters.add(parameter); .) | |
233 } | |
234 ] | |
235 ")" (. Token finalToken = t; .) | |
236 (. result = factory.createCall(receiver, parameters, finalToken); .) | |
237 | | |
238 "=" | |
239 Expression<out SLExpressionNode value> (. if (assignmentName == null) { | |
240 SemErr("invalid assignment target"); | |
241 } else if (assignmentReceiver == null) { | |
242 result = factory.createAssignment(assignmentName, value); | |
243 } else { | |
244 result = factory.createWriteProperty(assignmentReceiver, assignmentName, value); | |
245 } .) | |
246 | | |
247 "." | |
248 identifier | |
249 (. result = factory.createReadProperty(receiver, t); .) | |
250 (. nestedAssignmentName = t; .) | |
251 ) | |
252 [ | |
253 MemberExpression<out result, result, receiver, nestedAssignmentName> | |
254 ] | |
255 . | |
256 | |
257 | |
237 END SimpleLanguage. | 258 END SimpleLanguage. |