Skip to content
Browse files

value expressions in AST

  • Loading branch information...
1 parent c82900f commit ed876f59770a03750dfe9001efa4bb60b703fdfe @Swizec committed Apr 21, 2012
View
140 pascal/src/compiler/synanal/PascalSyn.java
@@ -1,7 +1,7 @@
//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
-// Sat Apr 21 19:49:36 CEST 2012
+// Sat Apr 21 21:44:18 CEST 2012
//----------------------------------------------------
package compiler.synanal;
@@ -12,7 +12,7 @@
import compiler.abstree.tree.*;
/** CUP v0.11a beta 20060608 generated parser.
- * @version Sat Apr 21 19:49:36 CEST 2012
+ * @version Sat Apr 21 21:44:18 CEST 2012
*/
public class PascalSyn extends java_cup.runtime.lr_parser {
@@ -610,7 +610,18 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 79: // parameter_call ::= value COMMA parameter_call
{
Object RESULT =null;
-
+ int vleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)).left;
+ int vright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)).right;
+ Object v = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)).value;
+ int restleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).left;
+ int restright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).right;
+ Object rest = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.peek()).value;
+
+ AbsValExprs vals = new AbsValExprs();
+ vals.exprs.add((AbsValExpr)v);
+ vals.exprs.addAll(((AbsValExprs)rest).exprs);
+ RESULT = vals;
+
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("parameter_call",18, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -619,7 +630,14 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 78: // parameter_call ::= value
{
Object RESULT =null;
-
+ int vleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).left;
+ int vright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).right;
+ Object v = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.peek()).value;
+
+ AbsValExprs vals = new AbsValExprs();
+ vals.exprs.add((AbsValExpr)v);
+ RESULT = vals;
+
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("parameter_call",18, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -628,7 +646,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 77: // parameter_call ::=
{
Object RESULT =null;
-
+ RESULT = new AbsValExprs();
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("parameter_call",18, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -637,7 +655,16 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 76: // subroutine_call ::= IDENTIFIER LPARENTHESIS parameter_call RPARENTHESIS
{
Object RESULT =null;
-
+ int idleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)).left;
+ int idright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)).right;
+ String id = (String)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)).value;
+ int paramsleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).left;
+ int paramsright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).right;
+ Object params = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).value;
+
+ RESULT = new AbsCallExpr(new AbsValName(id),
+ (AbsValExprs)params);
+
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("subroutine_call",17, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -646,7 +673,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 75: // infix ::= OR
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.OR;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -655,7 +682,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 74: // infix ::= AND
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.AND;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -664,7 +691,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 73: // infix ::= LEQ
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.LEQ;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -673,7 +700,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 72: // infix ::= GEQ
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.GEQ;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -682,7 +709,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 71: // infix ::= GTH
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.GTH;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -691,7 +718,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 70: // infix ::= LTH
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.LTH;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -700,7 +727,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 69: // infix ::= NEQ
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.NEQ;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -709,7 +736,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 68: // infix ::= EQU
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.EQU;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -718,7 +745,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 67: // infix ::= SUB
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.SUB;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -727,7 +754,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 66: // infix ::= ADD
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.ADD;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -736,7 +763,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 65: // infix ::= DIV
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.DIV;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -745,7 +772,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 64: // infix ::= MUL
{
Object RESULT =null;
-
+ RESULT = AbsBinExpr.MUL;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("infix",16, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -754,7 +781,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 63: // prefix ::= NOT
{
Object RESULT =null;
-
+ RESULT = AbsUnExpr.NOT;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("prefix",15, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -763,7 +790,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 62: // prefix ::= PTR
{
Object RESULT =null;
-
+ RESULT = AbsUnExpr.MEM;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("prefix",15, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -772,7 +799,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 61: // prefix ::= ADD
{
Object RESULT =null;
-
+ RESULT = AbsUnExpr.ADD;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("prefix",15, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -781,7 +808,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 60: // prefix ::= SUB
{
Object RESULT =null;
-
+ RESULT = AbsUnExpr.SUB;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("prefix",15, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -790,7 +817,10 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 59: // value ::= LPARENTHESIS value RPARENTHESIS
{
Object RESULT =null;
-
+ int vleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).left;
+ int vright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).right;
+ Object v = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).value;
+ RESULT = v;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("value",14, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -799,7 +829,10 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 58: // value ::= LBRACKET type_desc RBRACKET
{
Object RESULT =null;
-
+ int descleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).left;
+ int descright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).right;
+ Object desc = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).value;
+ RESULT = new AbsAlloc((AbsTypeExpr)desc);
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("value",14, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -808,7 +841,10 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 57: // value ::= subroutine_call
{
Object RESULT =null;
-
+ int callleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).left;
+ int callright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).right;
+ Object call = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.peek()).value;
+ RESULT = call;
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("value",14, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -817,7 +853,15 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 56: // value ::= value DOT value
{
Object RESULT =null;
-
+ int v1left = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)).left;
+ int v1right = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)).right;
+ Object v1 = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)).value;
+ int v2left = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).left;
+ int v2right = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).right;
+ Object v2 = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.peek()).value;
+ RESULT = new AbsBinExpr(AbsBinExpr.RECACCESS,
+ (AbsValExpr)v1,
+ (AbsValExpr)v2);
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("value",14, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -826,7 +870,15 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 55: // value ::= value LBRACKET value RBRACKET
{
Object RESULT =null;
-
+ int v1left = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)).left;
+ int v1right = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)).right;
+ Object v1 = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)).value;
+ int v2left = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).left;
+ int v2right = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).right;
+ Object v2 = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).value;
+ RESULT = new AbsBinExpr(AbsBinExpr.ARRACCESS,
+ (AbsValExpr)v1,
+ (AbsValExpr)v2);
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("value",14, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -847,7 +899,18 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 53: // value ::= value infix value
{
Object RESULT =null;
-
+ int v1left = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)).left;
+ int v1right = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)).right;
+ Object v1 = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)).value;
+ int opleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).left;
+ int opright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).right;
+ Object op = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).value;
+ int v2left = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).left;
+ int v2right = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).right;
+ Object v2 = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.peek()).value;
+ RESULT = new AbsBinExpr((Integer)op,
+ (AbsValExpr)v1,
+ (AbsValExpr)v2);
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("value",14, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-2)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -856,7 +919,11 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 52: // value ::= value PTR
{
Object RESULT =null;
-
+ int vleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).left;
+ int vright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).right;
+ Object v = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).value;
+ RESULT = new AbsUnExpr(AbsUnExpr.VAL,
+ (AbsValExpr)v);
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("value",14, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -865,7 +932,14 @@ public void report_fatal_error(String message, Object info) throws Exception {
case 51: // value ::= prefix value
{
Object RESULT =null;
-
+ int pleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).left;
+ int pright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).right;
+ Object p = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).value;
+ int vleft = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).left;
+ int vright = ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()).right;
+ Object v = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.peek()).value;
+ RESULT = new AbsUnExpr((Integer)p,
+ (AbsValExpr)v);
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("value",14, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
return CUP$PascalSyn$result;
@@ -1192,8 +1266,8 @@ public void report_fatal_error(String message, Object info) throws Exception {
Object t = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.peek()).value;
RESULT = new AbsArrayType((AbsTypeExpr)t,
- new AbsNilConst(),
- new AbsNilConst());
+ (AbsValExpr)lo,
+ (AbsValExpr)hi);
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("type_array",21, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-7)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
@@ -1385,7 +1459,7 @@ public void report_fatal_error(String message, Object info) throws Exception {
Object v = (Object)((java_cup.runtime.Symbol) CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-1)).value;
RESULT = new AbsConstDecl(new AbsDeclName(id),
- new AbsNilConst());
+ (AbsValExpr)v);
CUP$PascalSyn$result = parser.getSymbolFactory().newSymbol("one_constant",6, ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.elementAt(CUP$PascalSyn$top-3)), ((java_cup.runtime.Symbol)CUP$PascalSyn$stack.peek()), RESULT);
}
View
2 pascal/src/compiler/synanal/PascalTok.java
@@ -1,7 +1,7 @@
//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
-// Sat Apr 21 19:49:36 CEST 2012
+// Sat Apr 21 21:44:18 CEST 2012
//----------------------------------------------------
package compiler.synanal;
View
68 pascal/src/compiler/synanal/pascal.cup
@@ -90,7 +90,7 @@ constant_ ::= one_constant:c {:
one_constant ::= IDENTIFIER:id EQU value:v SEMIC
{:
RESULT = new AbsConstDecl(new AbsDeclName(id),
- new AbsNilConst());
+ (AbsValExpr)v);
:};
/* types */
type ::= {: RESULT = new AbsDecls(); :} | TYPE type_:t {: RESULT = t; :};
@@ -124,8 +124,8 @@ type_atom ::= BOOL {: RESULT = new AbsAtomType(AbsAtomType.BOOL); :}
type_array ::= ARRAY LBRACKET value:lo DOTS value:hi RBRACKET OF type_desc:t
{:
RESULT = new AbsArrayType((AbsTypeExpr)t,
- new AbsNilConst(),
- new AbsNilConst());
+ (AbsValExpr)lo,
+ (AbsValExpr)hi);
:};
type_record ::= RECORD type_record_components:fields END
{:
@@ -184,19 +184,57 @@ value ::= BOOL_CONST:val {: RESULT = new AbsAtomConst(val, AbsAtomConst.BOOL); :
| CHAR_CONST:val {: RESULT = new AbsAtomConst(val, AbsAtomConst.CHAR); :}
| INT_CONST:val {: RESULT = new AbsAtomConst(val, AbsAtomConst.INT); :}
| NIL {: RESULT = new AbsNilConst(); :}
- | prefix value
- | value PTR
- | value infix value
+ | prefix:p value:v {: RESULT = new AbsUnExpr((Integer)p,
+ (AbsValExpr)v); :}
+ | value:v PTR {: RESULT = new AbsUnExpr(AbsUnExpr.VAL,
+ (AbsValExpr)v); :}
+ | value:v1 infix:op value:v2 {: RESULT = new AbsBinExpr((Integer)op,
+ (AbsValExpr)v1,
+ (AbsValExpr)v2); :}
| IDENTIFIER:id {: RESULT = new AbsValName(id); :}
- | value LBRACKET value RBRACKET
- | value DOT value
- | subroutine_call
- | LBRACKET type_desc RBRACKET
- | LPARENTHESIS value RPARENTHESIS;
-prefix ::= SUB | ADD | PTR | NOT;
-infix ::= MUL | DIV | ADD | SUB | EQU | NEQ | LTH | GTH | GEQ | LEQ | AND | OR;
-subroutine_call ::= IDENTIFIER LPARENTHESIS parameter_call RPARENTHESIS;
-parameter_call ::= | value | value COMMA parameter_call;
+ | value:v1 LBRACKET value:v2 RBRACKET {: RESULT = new AbsBinExpr(AbsBinExpr.ARRACCESS,
+ (AbsValExpr)v1,
+ (AbsValExpr)v2); :}
+ | value:v1 DOT value:v2 {: RESULT = new AbsBinExpr(AbsBinExpr.RECACCESS,
+ (AbsValExpr)v1,
+ (AbsValExpr)v2); :}
+ | subroutine_call:call {: RESULT = call; :}
+ | LBRACKET type_desc:desc RBRACKET {: RESULT = new AbsAlloc((AbsTypeExpr)desc); :}
+ | LPARENTHESIS value:v RPARENTHESIS {: RESULT = v; :};
+
+prefix ::= SUB {: RESULT = AbsUnExpr.SUB; :}
+ | ADD {: RESULT = AbsUnExpr.ADD; :}
+ | PTR {: RESULT = AbsUnExpr.MEM; :}
+ | NOT {: RESULT = AbsUnExpr.NOT; :};
+infix ::= MUL {: RESULT = AbsBinExpr.MUL; :}
+ | DIV {: RESULT = AbsBinExpr.DIV; :}
+ | ADD {: RESULT = AbsBinExpr.ADD; :}
+ | SUB {: RESULT = AbsBinExpr.SUB; :}
+ | EQU {: RESULT = AbsBinExpr.EQU; :}
+ | NEQ {: RESULT = AbsBinExpr.NEQ; :}
+ | LTH {: RESULT = AbsBinExpr.LTH; :}
+ | GTH {: RESULT = AbsBinExpr.GTH; :}
+ | GEQ {: RESULT = AbsBinExpr.GEQ; :}
+ | LEQ {: RESULT = AbsBinExpr.LEQ; :}
+ | AND {: RESULT = AbsBinExpr.AND; :}
+ | OR {: RESULT = AbsBinExpr.OR; :};
+subroutine_call ::= IDENTIFIER:id LPARENTHESIS parameter_call:params RPARENTHESIS
+{:
+ RESULT = new AbsCallExpr(new AbsValName(id),
+ (AbsValExprs)params);
+ :};
+parameter_call ::= {: RESULT = new AbsValExprs(); :}
+ | value:v {:
+ AbsValExprs vals = new AbsValExprs();
+ vals.exprs.add((AbsValExpr)v);
+ RESULT = vals;
+ :}
+ | value:v COMMA parameter_call:rest {:
+ AbsValExprs vals = new AbsValExprs();
+ vals.exprs.add((AbsValExpr)v);
+ vals.exprs.addAll(((AbsValExprs)rest).exprs);
+ RESULT = vals;
+ :};
/*
statements

0 comments on commit ed876f5

Please sign in to comment.
Something went wrong with that request. Please try again.