Mercurial > hg > graal-jvmci-8
diff 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 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg Fri Aug 01 16:28:06 2014 -0700 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg Fri Aug 01 16:30:22 2014 -0700 @@ -84,12 +84,12 @@ Block<out SLStatementNode result, boolean inLoop> = (. factory.startBlock(); List<SLStatementNode> body = new ArrayList<>(); .) -"{" (. int lBracePos = t.charPos; .) +"{" (. int start = t.charPos; .) { Statement<out SLStatementNode s, inLoop> (. body.add(s); .) } -"}" (. int length = (t.charPos + t.val.length()) - lBracePos; .) - (. result = factory.finishBlock(body, lBracePos, length); .) +"}" (. int length = (t.charPos + t.val.length()) - start; .) + (. result = factory.finishBlock(body, start, length); .) . @@ -115,8 +115,8 @@ WhileStatement<out SLStatementNode result> = -"while" -"(" (. Token whileToken = t; .) +"while" (. Token whileToken = t; .) +"(" Expression<out SLExpressionNode condition> ")" Block<out SLStatementNode body, true> (. result = factory.createWhile(whileToken, condition, body); .) @@ -225,7 +225,10 @@ | numericLiteral (. result = factory.createNumericLiteral(t); .) | - "(" Expression<out result> ")" + "(" (. int start = t.charPos; .) + Expression<out result> (. SLExpressionNode expr = result; .) + ")" (. int length = (t.charPos + t.val.length()) - start; .) + (. result = factory.createParenExpression(expr, start, length); .) ) .