Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.java @ 17099:6e3cb88e6990
[SPARC] Temp slot must be 64 bit (long)
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Wed, 10 Sep 2014 11:22:41 -0700 |
parents | 7661cc464239 |
children | dc2e000bed40 |
rev | line source |
---|---|
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
1 /* |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
4 * |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
8 * |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
14 * |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
18 * |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
22 */ |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
23 |
13763
cad8bed1a1ac
Fix Eclipse formatter issues
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13761
diff
changeset
|
24 // The content of this file is automatically generated. DO NOT EDIT. |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
25 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
26 package com.oracle.truffle.sl.parser; |
12503
d7f8dd4fe876
minor reformatting based on 'mx eclipseformat'
Doug Simon <doug.simon@oracle.com>
parents:
11610
diff
changeset
|
27 |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
29 |
16067
915ebb306fcc
Truffle/Source: major API revision
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13836
diff
changeset
|
30 import com.oracle.truffle.api.source.*; |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.sl.*; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.truffle.sl.nodes.*; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
33 import com.oracle.truffle.sl.runtime.*; |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
34 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
35 // Checkstyle: stop |
7517
b6743d7eb8d4
disabled auto-formatting of generated code
Doug Simon <doug.simon@oracle.com>
parents:
7503
diff
changeset
|
36 // @formatter:off |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
37 public class Parser { |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
38 public static final int _EOF = 0; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
39 public static final int _identifier = 1; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
40 public static final int _stringLiteral = 2; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
41 public static final int _numericLiteral = 3; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
42 public static final int maxT = 30; |
7292
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 static final boolean T = true; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
45 static final boolean x = false; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
46 static final int minErrDist = 2; |
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 public Token t; // last recognized token |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
49 public Token la; // lookahead token |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
50 int errDist = minErrDist; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
51 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
52 public final Scanner scanner; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
53 public final Errors errors; |
12752
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
12503
diff
changeset
|
54 private final SLNodeFactory factory; |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
55 |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
56 public Parser(SLContext context, Source source) { |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
57 this.scanner = new Scanner(source.getInputStream()); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
58 this.factory = new SLNodeFactory(context, source); |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
59 errors = new Errors(); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
60 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
61 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
62 void SynErr(int n) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
63 if (errDist >= minErrDist) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
64 errors.SynErr(la.line, la.col, n); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
65 errDist = 0; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
66 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
67 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
68 public void SemErr(String msg) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
69 if (errDist >= minErrDist) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
70 errors.SemErr(t.line, t.col, msg); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
71 errDist = 0; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
72 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
73 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
74 void Get() { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
75 for (;;) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
76 t = la; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
77 la = scanner.Scan(); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
78 if (la.kind <= maxT) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
79 ++errDist; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
80 break; |
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 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
83 la = t; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
84 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
85 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
86 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
87 void Expect(int n) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
88 if (la.kind == n) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
89 Get(); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
90 else { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
91 SynErr(n); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
92 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
93 } |
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 boolean StartOf(int s) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
96 return set[s][la.kind]; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
97 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
98 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
99 void ExpectWeak(int n, int follow) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
100 if (la.kind == n) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
101 Get(); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
102 else { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
103 SynErr(n); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
104 while (!StartOf(follow)) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
105 Get(); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
106 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
107 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
108 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
109 boolean WeakSeparator(int n, int syFol, int repFol) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
110 int kind = la.kind; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
111 if (kind == n) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
112 Get(); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
113 return true; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
114 } else if (StartOf(repFol)) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
115 return false; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
116 else { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
117 SynErr(n); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
118 while (!(set[syFol][kind] || set[repFol][kind] || set[0][kind])) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
119 Get(); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
120 kind = la.kind; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
121 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
122 return StartOf(syFol); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
123 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
124 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
125 |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
126 void SimpleLanguage() { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
127 Function(); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
128 while (la.kind == 4) { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
129 Function(); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
130 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
131 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
132 |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
133 void Function() { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
134 Expect(4); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
135 Expect(1); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
136 Token identifierToken = t; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
137 Expect(5); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
138 int bodyStartPos = t.charPos; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
139 factory.startFunction(identifierToken, bodyStartPos); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
140 if (la.kind == 1) { |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
141 Get(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
142 factory.addFormalParameter(t); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
143 while (la.kind == 6) { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
144 Get(); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
145 Expect(1); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
146 factory.addFormalParameter(t); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
147 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
148 } |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
149 Expect(7); |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
150 SLStatementNode body = Block(false); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
151 factory.finishFunction(body); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
152 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
153 |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
154 SLStatementNode Block(boolean inLoop) { |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
155 SLStatementNode result; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
156 factory.startBlock(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
157 List<SLStatementNode> body = new ArrayList<>(); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
158 Expect(8); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
159 int start = t.charPos; |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
160 while (StartOf(1)) { |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
161 SLStatementNode s = Statement(inLoop); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
162 body.add(s); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
163 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
164 Expect(9); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
165 int length = (t.charPos + t.val.length()) - start; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
166 result = factory.finishBlock(body, start, length); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
167 return result; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
168 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
169 |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
170 SLStatementNode Statement(boolean inLoop) { |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
171 SLStatementNode result; |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
172 result = null; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
173 switch (la.kind) { |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
174 case 13: { |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
175 result = WhileStatement(); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
176 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
177 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
178 case 10: { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
179 Get(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
180 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:
12754
diff
changeset
|
181 Expect(11); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
182 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
183 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
184 case 12: { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
185 Get(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
186 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:
12754
diff
changeset
|
187 Expect(11); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
188 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
189 } |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
190 case 14: { |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
191 result = IfStatement(inLoop); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
192 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
193 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
194 case 16: { |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
195 result = ReturnStatement(); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
196 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
197 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
198 case 1: case 2: case 3: case 5: { |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
199 result = Expression(); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
200 Expect(11); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
201 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
202 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
203 default: SynErr(31); break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
204 } |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
205 return result; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
206 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
207 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
208 SLStatementNode WhileStatement() { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
209 SLStatementNode result; |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
210 Expect(13); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
211 Token whileToken = t; |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
212 Expect(5); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
213 SLExpressionNode condition = Expression(); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
214 Expect(7); |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
215 SLStatementNode body = Block(true); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
216 result = factory.createWhile(whileToken, condition, body); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
217 return result; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
218 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
219 |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
220 SLStatementNode IfStatement(boolean inLoop) { |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
221 SLStatementNode result; |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
222 Expect(14); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
223 Token ifToken = t; |
16685
888907296590
Backed out changeset: d654cd5ed05a
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
16684
diff
changeset
|
224 Expect(5); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
225 SLExpressionNode condition = Expression(); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
226 Expect(7); |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
227 SLStatementNode thenPart = Block(inLoop); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
228 SLStatementNode elsePart = null; |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
229 if (la.kind == 15) { |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
230 Get(); |
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
231 elsePart = Block(inLoop); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
232 } |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
233 result = factory.createIf(ifToken, condition, thenPart, elsePart); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
234 return result; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
235 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
236 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
237 SLStatementNode ReturnStatement() { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
238 SLStatementNode result; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
239 Expect(16); |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
240 Token returnToken = t; |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
241 SLExpressionNode value = null; |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
242 if (StartOf(2)) { |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
243 value = Expression(); |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
244 } |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
245 result = factory.createReturn(returnToken, value); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
246 Expect(11); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
247 return result; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
248 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
249 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
250 SLExpressionNode Expression() { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
251 SLExpressionNode result; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
252 result = LogicTerm(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
253 while (la.kind == 17) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
254 Get(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
255 Token op = t; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
256 SLExpressionNode right = LogicTerm(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
257 result = factory.createBinary(op, result, right); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
258 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
259 return result; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
260 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
261 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
262 SLExpressionNode LogicTerm() { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
263 SLExpressionNode result; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
264 result = LogicFactor(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
265 while (la.kind == 18) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
266 Get(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
267 Token op = t; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
268 SLExpressionNode right = LogicFactor(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
269 result = factory.createBinary(op, result, right); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
270 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
271 return result; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
272 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
273 |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
274 SLExpressionNode LogicFactor() { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
275 SLExpressionNode result; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
276 result = Arithmetic(); |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
277 if (StartOf(3)) { |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
278 switch (la.kind) { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
279 case 19: { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
280 Get(); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
281 break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
282 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
283 case 20: { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
284 Get(); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
285 break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
286 } |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
287 case 21: { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
288 Get(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
289 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
290 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
291 case 22: { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
292 Get(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
293 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
294 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
295 case 23: { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
296 Get(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
297 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
298 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
299 case 24: { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
300 Get(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
301 break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
302 } |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
303 } |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
304 Token op = t; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
305 SLExpressionNode right = Arithmetic(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
306 result = factory.createBinary(op, result, right); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
307 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
308 return result; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
309 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
310 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
311 SLExpressionNode Arithmetic() { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
312 SLExpressionNode result; |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
313 result = Term(); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
314 while (la.kind == 25 || la.kind == 26) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
315 if (la.kind == 25) { |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
316 Get(); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
317 } else { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
318 Get(); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
319 } |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
320 Token op = t; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
321 SLExpressionNode right = Term(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
322 result = factory.createBinary(op, result, right); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
323 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
324 return result; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
325 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
326 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
327 SLExpressionNode Term() { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
328 SLExpressionNode result; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
329 result = Factor(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
330 while (la.kind == 27 || la.kind == 28) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
331 if (la.kind == 27) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
332 Get(); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
333 } else { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
334 Get(); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
335 } |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
336 Token op = t; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
337 SLExpressionNode right = Factor(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
338 result = factory.createBinary(op, result, right); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
339 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
340 return result; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
341 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
342 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
343 SLExpressionNode Factor() { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
344 SLExpressionNode result; |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
345 result = null; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
346 if (la.kind == 1) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
347 Get(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
348 Token nameToken = t; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
349 if (la.kind == 5) { |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
350 Get(); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
351 List<SLExpressionNode> parameters = new ArrayList<>(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
352 SLExpressionNode parameter; |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
353 if (StartOf(2)) { |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
354 parameter = Expression(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
355 parameters.add(parameter); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
356 while (la.kind == 6) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
357 Get(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
358 parameter = Expression(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
359 parameters.add(parameter); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
360 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
361 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
362 Expect(7); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
363 Token finalToken = t; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
364 result = factory.createCall(nameToken, parameters, finalToken); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
365 } else if (la.kind == 29) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
366 Get(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
367 SLExpressionNode value = Expression(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
368 result = factory.createAssignment(nameToken, value); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
369 } else if (StartOf(4)) { |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
370 result = factory.createRead(nameToken); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
371 } else SynErr(32); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
372 } else if (la.kind == 2) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
373 Get(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
374 result = factory.createStringLiteral(t); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
375 } else if (la.kind == 3) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
376 Get(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
377 result = factory.createNumericLiteral(t); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
378 } else if (la.kind == 5) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
379 Get(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
380 int start = t.charPos; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
381 result = Expression(); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
382 SLExpressionNode expr = result; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
383 Expect(7); |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
384 int length = (t.charPos + t.val.length()) - start; |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
385 result = factory.createParenExpression(expr, start, length); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
386 } else SynErr(33); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
387 return result; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
388 } |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
389 |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
390 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
391 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
392 public void Parse() { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
393 la = new Token(); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
394 la.val = ""; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
395 Get(); |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
396 SimpleLanguage(); |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
397 Expect(0); |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
398 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
399 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
400 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
401 private static final boolean[][] set = { |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
402 {T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
403 {x,T,T,T, x,T,x,x, x,x,T,x, T,T,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
404 {x,T,T,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}, |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
405 {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, T,x,x,x, x,x,x,x}, |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
406 {x,x,x,x, x,x,T,T, x,x,x,T, x,x,x,x, x,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x} |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
407 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
408 }; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
409 |
16880
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
410 public static void parseSL(SLContext context, Source source) { |
7661cc464239
Truffle/Instrumentation: Added Instrumentable interface and LineLocationToSourceSections map
David Piorkowski <david.piorkowski@oracle.com>
parents:
16687
diff
changeset
|
411 Parser parser = new Parser(context, source); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
412 parser.Parse(); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
413 if (parser.errors.errors.size() > 0) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
414 StringBuilder msg = new StringBuilder("Error(s) parsing script:\n"); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
415 for (String error : parser.errors.errors) { |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
416 msg.append(error).append("\n"); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
417 } |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
418 throw new SLException(msg.toString()); |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
419 } |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
420 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
421 } // end Parser |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
422 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
423 class Errors { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
424 |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
425 protected final List<String> errors = new ArrayList<>(); |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
426 public String errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
427 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
428 protected void printMsg(int line, int column, String msg) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
429 StringBuffer b = new StringBuffer(errMsgFormat); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
430 int pos = b.indexOf("{0}"); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
431 if (pos >= 0) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
432 b.delete(pos, pos + 3); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
433 b.insert(pos, line); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
434 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
435 pos = b.indexOf("{1}"); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
436 if (pos >= 0) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
437 b.delete(pos, pos + 3); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
438 b.insert(pos, column); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
439 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
440 pos = b.indexOf("{2}"); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
441 if (pos >= 0) |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
442 b.replace(pos, pos + 3, msg); |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
443 errors.add(b.toString()); |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
444 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
445 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
446 public void SynErr(int line, int col, int n) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
447 String s; |
12754
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
448 switch (n) { |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
449 case 0: s = "EOF expected"; break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
450 case 1: s = "identifier expected"; break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
451 case 2: s = "stringLiteral expected"; break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
452 case 3: s = "numericLiteral expected"; break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
453 case 4: s = "\"function\" expected"; break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
454 case 5: s = "\"(\" expected"; break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
455 case 6: s = "\",\" expected"; break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
456 case 7: s = "\")\" expected"; break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
457 case 8: s = "\"{\" expected"; break; |
7311354f5bf8
SL: fixed eclipse formatter problems.
Christian Humer <christian.humer@gmail.com>
parents:
12752
diff
changeset
|
458 case 9: s = "\"}\" expected"; break; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
459 case 10: s = "\"break\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
460 case 11: s = "\";\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
461 case 12: s = "\"continue\" expected"; break; |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
462 case 13: s = "\"while\" expected"; break; |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
463 case 14: s = "\"if\" expected"; break; |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
464 case 15: s = "\"else\" expected"; break; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
465 case 16: s = "\"return\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
466 case 17: s = "\"||\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
467 case 18: s = "\"&&\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
468 case 19: s = "\"<\" expected"; break; |
13821
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
469 case 20: s = "\"<=\" expected"; break; |
b16ec83edc73
Documentation and more refactoring of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13763
diff
changeset
|
470 case 21: s = "\">\" expected"; break; |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
471 case 22: s = "\">=\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
472 case 23: s = "\"==\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
473 case 24: s = "\"!=\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
474 case 25: s = "\"+\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
475 case 26: s = "\"-\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
476 case 27: s = "\"*\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
477 case 28: s = "\"/\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
478 case 29: s = "\"=\" expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
479 case 30: s = "??? expected"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
480 case 31: s = "invalid Statement"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
481 case 32: s = "invalid Factor"; break; |
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
482 case 33: s = "invalid Factor"; break; |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
483 default: |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
484 s = "error " + n; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
485 break; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
486 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
487 printMsg(line, col, s); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
488 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
489 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
490 public void SemErr(int line, int col, String s) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
491 printMsg(line, col, s); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
492 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
493 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
494 public void SemErr(String s) { |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
495 errors.add(s); |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
496 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
497 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
498 public void Warning(int line, int col, String s) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
499 printMsg(line, col, s); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
500 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
501 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
502 public void Warning(String s) { |
13761
7c418666c6c9
Refactoring and cleanup of Simple Language (more to come soon)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12754
diff
changeset
|
503 errors.add(s); |
7292
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
504 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
505 } // Errors |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
506 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
507 class FatalError extends RuntimeException { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
508 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
509 public static final long serialVersionUID = 1L; |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
510 |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
511 public FatalError(String s) { |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
512 super(s); |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
513 } |
213c1297a814
Simple Language: A simple dynamic programming language to demonstrate Truffle features
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
514 } |