Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg @ 21646:645f170013a4
Fix in the scheduler for proxy node handling.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 01 Jun 2015 22:14:34 +0200 |
parents | cfb85e1f4ca5 |
children |
rev | line source |
---|---|
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
1 /* |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
4 * |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
7 * published by the Free Software Foundation. |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
8 * |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
13 * accompanied this code). |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
14 * |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
18 * |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
21 * questions. |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
22 */ |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
23 |
13882
afd6fa5e8229
SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13836
diff
changeset
|
24 /* |
afd6fa5e8229
SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13836
diff
changeset
|
25 * This is the grammar of SL that is used to automatically generate the Parser.java and Scanner.java |
afd6fa5e8229
SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13836
diff
changeset
|
26 * files. You can download the parser generator Coco/R from http://ssw.jku.at/coco/. Then run |
afd6fa5e8229
SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13836
diff
changeset
|
27 * "java -jar Coco.jar SimpleLanguage.atg" |
afd6fa5e8229
SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13836
diff
changeset
|
28 */ |
afd6fa5e8229
SL: Feedback from reviewers
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13836
diff
changeset
|
29 |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
30 COMPILER SimpleLanguage |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
31 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
32 CHARACTERS |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
33 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
34 letter = 'A'..'Z' + 'a'..'z'. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
35 nonZeroDigit = "123456789". |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
36 digit = "0123456789". |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
37 cr = '\r'. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
38 lf = '\n'. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
39 tab = '\t'. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
40 stringChar = ANY - "\"" - '\\' - cr - lf. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
41 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
42 TOKENS |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
43 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
44 identifier = letter {letter | digit}. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
45 stringLiteral = "\"" { stringChar } "\"". |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
46 numericLiteral = "0" | nonZeroDigit { digit }. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
47 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
48 PRAGMAS |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
49 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
50 COMMENTS FROM "/*" TO "*/" |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
51 COMMENTS FROM "//" TO lf |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
52 IGNORE cr + lf + tab |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
53 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
54 PRODUCTIONS |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
55 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
56 |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
57 SimpleLanguage |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
58 = |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
59 Function |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
60 { |
7509 | 61 Function |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
62 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
63 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
64 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
65 |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
66 Function |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
67 = |
16687
7c8ddb4233cd
SL/SourceAttribution: restore some attribution fixes that were lost in a tussle with hg; turn off tracing code in SL tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16685
diff
changeset
|
68 "function" |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
69 identifier (. Token identifierToken = t; .) |
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
70 "(" (. int bodyStartPos = t.charPos; .) |
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
71 (. factory.startFunction(identifierToken, bodyStartPos); .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
72 [ |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
73 identifier (. factory.addFormalParameter(t); .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
74 { |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
75 "," |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
76 identifier (. factory.addFormalParameter(t); .) |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
77 } |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
78 ] |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
79 ")" |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
80 Block<out SLStatementNode body, false> (. factory.finishFunction(body); .) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
81 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
82 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
83 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
84 |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
85 Block<out SLStatementNode result, boolean inLoop> |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
86 = (. factory.startBlock(); |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
87 List<SLStatementNode> body = new ArrayList<>(); .) |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
88 "{" (. int start = t.charPos; .) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
89 { |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
90 Statement<out SLStatementNode s, inLoop> (. body.add(s); .) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
91 } |
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).
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16512
diff
changeset
|
92 "}" (. int length = (t.charPos + t.val.length()) - start; .) |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
93 (. result = factory.finishBlock(body, start, length); .) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
94 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
95 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
96 |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
97 Statement<out SLStatementNode result, boolean inLoop> |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
98 = (. result = null; .) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
99 ( |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
100 WhileStatement<out result> |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
101 | |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
102 "break" (. if (inLoop) { result = factory.createBreak(t); } else { SemErr("break used outside of loop"); } .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
103 ";" |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
104 | |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
105 "continue" (. if (inLoop) { result = factory.createContinue(t); } else { SemErr("continue used outside of loop"); } .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
106 ";" |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
107 | |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
108 IfStatement<out result, inLoop> |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
109 | |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
110 ReturnStatement<out result> |
12752
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
7924
diff
changeset
|
111 | |
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
7924
diff
changeset
|
112 Expression<out result> ";" |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
113 ) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
114 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
115 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
116 |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
117 WhileStatement<out SLStatementNode result> |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
118 = |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
119 "while" (. Token whileToken = t; .) |
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
120 "(" |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
121 Expression<out SLExpressionNode condition> |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
122 ")" |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
123 Block<out SLStatementNode body, true> (. result = factory.createWhile(whileToken, condition, body); .) |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
124 . |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
125 |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
126 |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
127 IfStatement<out SLStatementNode result, boolean inLoop> |
12752
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
7924
diff
changeset
|
128 = |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
129 "if" (. Token ifToken = t; .) |
16687
7c8ddb4233cd
SL/SourceAttribution: restore some attribution fixes that were lost in a tussle with hg; turn off tracing code in SL tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16685
diff
changeset
|
130 "(" |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
131 Expression<out SLExpressionNode condition> |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
132 ")" |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
133 Block<out SLStatementNode thenPart, inLoop> (. SLStatementNode elsePart = null; .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
134 [ |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
135 "else" |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
136 Block<out elsePart, inLoop> |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
137 ] (. result = factory.createIf(ifToken, condition, thenPart, elsePart); .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
138 . |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
139 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
140 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
141 ReturnStatement<out SLStatementNode result> |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
142 = |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
143 "return" (. Token returnToken = t; |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
144 SLExpressionNode value = null; .) |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
145 [ |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
146 Expression<out value> |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
147 ] (. result = factory.createReturn(returnToken, value); .) |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
148 ";" |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
149 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
150 |
7509 | 151 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
152 Expression<out SLExpressionNode result> |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
153 = |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
154 LogicTerm<out result> |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
155 { |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
156 "||" (. Token op = t; .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
157 LogicTerm<out SLExpressionNode right> (. result = factory.createBinary(op, result, right); .) |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
158 } |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
159 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
160 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
161 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
162 LogicTerm<out SLExpressionNode result> |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
163 = |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
164 LogicFactor<out result> |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
165 { |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
166 "&&" (. Token op = t; .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
167 LogicFactor<out SLExpressionNode right> (. result = factory.createBinary(op, result, right); .) |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
168 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
169 . |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
170 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
171 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
172 LogicFactor<out SLExpressionNode result> |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
173 = |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
174 Arithmetic<out result> |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
175 [ |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
176 ("<" | "<=" | ">" | ">=" | "==" | "!=" ) (. Token op = t; .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
177 Arithmetic<out SLExpressionNode right> (. result = factory.createBinary(op, result, right); .) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
178 ] |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
179 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
180 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
181 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
182 Arithmetic<out SLExpressionNode result> |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
183 = |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
184 Term<out result> |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
185 { |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
186 ("+" | "-") (. Token op = t; .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
187 Term<out SLExpressionNode right> (. result = factory.createBinary(op, result, right); .) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
188 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
189 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
190 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
191 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
192 Term<out SLExpressionNode result> |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
193 = |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
194 Factor<out result> |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
195 { |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
196 ("*" | "/") (. Token op = t; .) |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
197 Factor<out SLExpressionNode right> (. result = factory.createBinary(op, result, right); .) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
198 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
199 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
200 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
201 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12752
diff
changeset
|
202 Factor<out SLExpressionNode result> |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
203 = (. result = null; .) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
204 ( |
18962
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
205 identifier |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
206 ( |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
207 MemberExpression<out result, null, null, t> |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
208 | |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
209 (. result = factory.createRead(t); .) |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
210 ) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
211 | |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
212 stringLiteral (. result = factory.createStringLiteral(t); .) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
213 | |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
214 numericLiteral (. result = factory.createNumericLiteral(t); .) |
7848
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
7509
diff
changeset
|
215 | |
18410
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
216 "(" (. int start = t.charPos; .) |
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
217 Expression<out result> (. SLExpressionNode expr = result; .) |
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
218 ")" (. int length = (t.charPos + t.val.length()) - start; .) |
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
219 (. result = factory.createParenExpression(expr, start, length); .) |
f444ef4684ec
SL: sanitize whitespace in ATG
Andreas Woess <andreas.woess@jku.at>
parents:
16687
diff
changeset
|
220 ) |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
221 . |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
222 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
223 |
18962
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
224 MemberExpression<out SLExpressionNode result, SLExpressionNode r, SLExpressionNode assignmentReceiver, Token assignmentName> |
18411
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
225 = (. result = null; |
18962
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
226 SLExpressionNode receiver = r; |
18411
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
227 Token nestedAssignmentName = null; .) |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
228 ( |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
229 "(" (. List<SLExpressionNode> parameters = new ArrayList<>(); |
18962
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
230 SLExpressionNode parameter; |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
231 if (receiver == null) { |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
232 receiver = factory.createRead(assignmentName); |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
233 } .) |
18411
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
234 [ |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
235 Expression<out parameter> (. parameters.add(parameter); .) |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
236 { |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
237 "," |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
238 Expression<out parameter> (. parameters.add(parameter); .) |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
239 } |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
240 ] |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
241 ")" (. Token finalToken = t; .) |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
242 (. result = factory.createCall(receiver, parameters, finalToken); .) |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
243 | |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
244 "=" |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
245 Expression<out SLExpressionNode value> (. if (assignmentName == null) { |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
246 SemErr("invalid assignment target"); |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
247 } else if (assignmentReceiver == null) { |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
248 result = factory.createAssignment(assignmentName, value); |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
249 } else { |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
250 result = factory.createWriteProperty(assignmentReceiver, assignmentName, value); |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
251 } .) |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
252 | |
18962
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
253 "." (. if (receiver == null) { |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
254 receiver = factory.createRead(assignmentName); |
cfb85e1f4ca5
Prevent polluting SLFunctionRegistry (via SLNodeFactory.createRead()) with LHS names of assignment
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18411
diff
changeset
|
255 } .) |
18411
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
256 identifier |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
257 (. result = factory.createReadProperty(receiver, t); .) |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
258 (. nestedAssignmentName = t; .) |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
259 ) |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
260 [ |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
261 MemberExpression<out result, result, receiver, nestedAssignmentName> |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
262 ] |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
263 . |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
264 |
dc2e000bed40
SL: add basic support for creating objects and accessing properties
Andreas Woess <andreas.woess@jku.at>
parents:
18410
diff
changeset
|
265 |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
266 END SimpleLanguage. |