//----------------------------------------------------
// The following code was generated by CUP v0.10k
// Tue Mar 29 16:17:14 CEST 2005
//----------------------------------------------------
package se.chalmers.cs.gf.SyntaxTree;
/** CUP v0.10k generated parser.
* @version Tue Mar 29 16:17:14 CEST 2005
*/
public class parser extends java_cup.runtime.lr_parser {
/** Default constructor. */
public parser() {super();}
/** Constructor which sets the default scanner. */
public parser(java_cup.runtime.Scanner s) {super(s);}
/** Production table. */
protected static final short _production_table[][] =
unpackFromStrings(new String[] {
"\000\010\000\002\002\004\000\002\003\004\000\002\004" +
"\003\000\002\004\003\000\002\004\003\000\002\004\005" +
"\000\002\005\002\000\002\005\004" });
/** Access to production table. */
public short[][] production_table() {return _production_table;}
/** Parse-action table. */
protected static final short[][] _action_table =
unpackFromStrings(new String[] {
"\000\014\000\004\010\004\001\002\000\016\002\ufffb\004" +
"\ufffb\005\ufffb\006\ufffb\007\ufffb\010\ufffb\001\002\000\004" +
"\002\006\001\002\000\004\002\001\001\002\000\016\002" +
"\000\004\012\005\000\006\010\007\013\010\011\001\002" +
"\000\016\002\ufffe\004\ufffe\005\ufffe\006\ufffe\007\ufffe\010" +
"\ufffe\001\002\000\016\002\uffff\004\uffff\005\uffff\006\uffff" +
"\007\uffff\010\uffff\001\002\000\004\010\004\001\002\000" +
"\016\002\ufffd\004\ufffd\005\ufffd\006\ufffd\007\ufffd\010\ufffd" +
"\001\002\000\016\002\ufffa\004\ufffa\005\ufffa\006\ufffa\007" +
"\ufffa\010\ufffa\001\002\000\004\005\016\001\002\000\016" +
"\002\ufffc\004\ufffc\005\ufffc\006\ufffc\007\ufffc\010\ufffc\001" +
"\002" });
/** Access to parse-action table. */
public short[][] action_table() {return _action_table;}
/** reduce_goto
table. */
protected static final short[][] _reduce_table =
unpackFromStrings(new String[] {
"\000\014\000\004\003\004\001\001\000\004\005\006\001" +
"\001\000\002\001\001\000\002\001\001\000\004\004\013" +
"\001\001\000\002\001\001\000\002\001\001\000\004\003" +
"\014\001\001\000\002\001\001\000\002\001\001\000\002" +
"\001\001\000\002\001\001" });
/** Access to reduce_goto
table. */
public short[][] reduce_table() {return _reduce_table;}
/** Instance of action encapsulation class. */
protected CUP$parser$actions action_obj;
/** Action encapsulation object initializer. */
protected void init_actions()
{
action_obj = new CUP$parser$actions(this);
}
/** Invoke a user supplied parse action. */
public java_cup.runtime.Symbol do_action(
int act_num,
java_cup.runtime.lr_parser parser,
java.util.Stack stack,
int top)
throws java.lang.Exception
{
/* call code in generated class */
return action_obj.CUP$parser$do_action(act_num, parser, stack, top);
}
/** Indicates start state. */
public int start_state() {return 0;}
/** Indicates start production. */
public int start_production() {return 0;}
/** EOF
Symbol index. */
public int EOF_sym() {return 0;}
/** error
Symbol index. */
public int error_sym() {return 1;}
public se.chalmers.cs.gf.SyntaxTree.Absyn.Tr pTr() throws Exception
{
java_cup.runtime.Symbol res = parse();
return (se.chalmers.cs.gf.SyntaxTree.Absyn.Tr) res.value;
}
public void syntax_error(java_cup.runtime.Symbol cur_token)
{
report_error("Syntax Error, trying to recover and continue parse...", cur_token);
}
public void unrecovered_syntax_error(java_cup.runtime.Symbol cur_token) throws java.lang.Exception
{
throw new Exception("Unrecoverable Syntax Error");
}
}
/** Cup generated class to encapsulate user supplied action code.*/
class CUP$parser$actions {
private final parser parser;
/** Constructor */
CUP$parser$actions(parser parser) {
this.parser = parser;
}
/** Method with the actual generated action code. */
public final java_cup.runtime.Symbol CUP$parser$do_action(
int CUP$parser$act_num,
java_cup.runtime.lr_parser CUP$parser$parser,
java.util.Stack CUP$parser$stack,
int CUP$parser$top)
throws java.lang.Exception
{
/* Symbol object for return from actions */
java_cup.runtime.Symbol CUP$parser$result;
/* select the action based on the action number */
switch (CUP$parser$act_num)
{
/*. . . . . . . . . . . . . . . . . . . .*/
case 7: // ListTr2 ::= ListTr2 Tr2
{
se.chalmers.cs.gf.SyntaxTree.Absyn.ListTr RESULT = null;
se.chalmers.cs.gf.SyntaxTree.Absyn.ListTr p_1 = (se.chalmers.cs.gf.SyntaxTree.Absyn.ListTr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
se.chalmers.cs.gf.SyntaxTree.Absyn.Tr p_2 = (se.chalmers.cs.gf.SyntaxTree.Absyn.Tr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = p_1; p_1.addLast(p_2);
CUP$parser$result = new java_cup.runtime.Symbol(3/*ListTr2*/, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 6: // ListTr2 ::=
{
se.chalmers.cs.gf.SyntaxTree.Absyn.ListTr RESULT = null;
RESULT = new se.chalmers.cs.gf.SyntaxTree.Absyn.ListTr();
CUP$parser$result = new java_cup.runtime.Symbol(3/*ListTr2*/, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 5: // Tr2 ::= _SYMB_0 Tr _SYMB_1
{
se.chalmers.cs.gf.SyntaxTree.Absyn.Tr RESULT = null;
se.chalmers.cs.gf.SyntaxTree.Absyn.Tr p_2 = (se.chalmers.cs.gf.SyntaxTree.Absyn.Tr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
RESULT = p_2;
CUP$parser$result = new java_cup.runtime.Symbol(2/*Tr2*/, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 4: // Tr2 ::= _INTEGER_
{
se.chalmers.cs.gf.SyntaxTree.Absyn.Tr RESULT = null;
Integer p_1 = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new se.chalmers.cs.gf.SyntaxTree.Absyn.TInt(p_1);
CUP$parser$result = new java_cup.runtime.Symbol(2/*Tr2*/, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 3: // Tr2 ::= _STRING_
{
se.chalmers.cs.gf.SyntaxTree.Absyn.Tr RESULT = null;
String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new se.chalmers.cs.gf.SyntaxTree.Absyn.TStr(p_1);
CUP$parser$result = new java_cup.runtime.Symbol(2/*Tr2*/, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 2: // Tr2 ::= _IDENT_
{
se.chalmers.cs.gf.SyntaxTree.Absyn.Tr RESULT = null;
String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new se.chalmers.cs.gf.SyntaxTree.Absyn.TAtom(p_1);
CUP$parser$result = new java_cup.runtime.Symbol(2/*Tr2*/, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 1: // Tr ::= _IDENT_ ListTr2
{
se.chalmers.cs.gf.SyntaxTree.Absyn.Tr RESULT = null;
String p_1 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
se.chalmers.cs.gf.SyntaxTree.Absyn.ListTr p_2 = (se.chalmers.cs.gf.SyntaxTree.Absyn.ListTr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
RESULT = new se.chalmers.cs.gf.SyntaxTree.Absyn.TNode(p_1,p_2);
CUP$parser$result = new java_cup.runtime.Symbol(1/*Tr*/, RESULT);
}
return CUP$parser$result;
/*. . . . . . . . . . . . . . . . . . . .*/
case 0: // $START ::= Tr EOF
{
Object RESULT = null;
se.chalmers.cs.gf.SyntaxTree.Absyn.Tr start_val = (se.chalmers.cs.gf.SyntaxTree.Absyn.Tr)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
RESULT = start_val;
CUP$parser$result = new java_cup.runtime.Symbol(0/*$START*/, RESULT);
}
/* ACCEPT */
CUP$parser$parser.done_parsing();
return CUP$parser$result;
/* . . . . . .*/
default:
throw new Exception(
"Invalid action number found in internal parse table");
}
}
}