Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg @ 16675:0fc43b066eee
SL/SourceAttribution: correct some omissions, and in particular add new node SLParenExpressionNode to represent a parenthesized expression; this is semantically neutral of course, but needed to account correctly for the text of such an expression (as opposed to its contents).
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Fri, 01 Aug 2014 16:30:22 -0700 |
parents | abe7128ca473 |
children | d654cd5ed05a |
comparison
equal
deleted
inserted
replaced
16674:70f47dbbcabd | 16675:0fc43b066eee |
---|---|
82 | 82 |
83 | 83 |
84 Block<out SLStatementNode result, boolean inLoop> | 84 Block<out SLStatementNode result, boolean inLoop> |
85 = (. factory.startBlock(); | 85 = (. factory.startBlock(); |
86 List<SLStatementNode> body = new ArrayList<>(); .) | 86 List<SLStatementNode> body = new ArrayList<>(); .) |
87 "{" (. int lBracePos = t.charPos; .) | 87 "{" (. int start = t.charPos; .) |
88 { | 88 { |
89 Statement<out SLStatementNode s, inLoop> (. body.add(s); .) | 89 Statement<out SLStatementNode s, inLoop> (. body.add(s); .) |
90 } | 90 } |
91 "}" (. int length = (t.charPos + t.val.length()) - lBracePos; .) | 91 "}" (. int length = (t.charPos + t.val.length()) - start; .) |
92 (. result = factory.finishBlock(body, lBracePos, length); .) | 92 (. result = factory.finishBlock(body, start, length); .) |
93 . | 93 . |
94 | 94 |
95 | 95 |
96 Statement<out SLStatementNode result, boolean inLoop> | 96 Statement<out SLStatementNode result, boolean inLoop> |
97 = (. result = null; .) | 97 = (. result = null; .) |
113 . | 113 . |
114 | 114 |
115 | 115 |
116 WhileStatement<out SLStatementNode result> | 116 WhileStatement<out SLStatementNode result> |
117 = | 117 = |
118 "while" | 118 "while" (. Token whileToken = t; .) |
119 "(" (. Token whileToken = t; .) | 119 "(" |
120 Expression<out SLExpressionNode condition> | 120 Expression<out SLExpressionNode condition> |
121 ")" | 121 ")" |
122 Block<out SLStatementNode body, true> (. result = factory.createWhile(whileToken, condition, body); .) | 122 Block<out SLStatementNode body, true> (. result = factory.createWhile(whileToken, condition, body); .) |
123 . | 123 . |
124 | 124 |
223 | | 223 | |
224 stringLiteral (. result = factory.createStringLiteral(t); .) | 224 stringLiteral (. result = factory.createStringLiteral(t); .) |
225 | | 225 | |
226 numericLiteral (. result = factory.createNumericLiteral(t); .) | 226 numericLiteral (. result = factory.createNumericLiteral(t); .) |
227 | | 227 | |
228 "(" Expression<out result> ")" | 228 "(" (. int start = t.charPos; .) |
229 Expression<out result> (. SLExpressionNode expr = result; .) | |
230 ")" (. int length = (t.charPos + t.val.length()) - start; .) | |
231 (. result = factory.createParenExpression(expr, start, length); .) | |
229 ) | 232 ) |
230 . | 233 . |
231 | 234 |
232 | 235 |
233 END SimpleLanguage. | 236 END SimpleLanguage. |