// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//----------------------------------------------------
// The following code was generated by CUP v0.10k TUM Edition 20050516
// Fri Jan 04 18:13:12 GMT 2008
//----------------------------------------------------
package com.google.calculator.parser;
import com.google.calculator.tree.*;
import java_cup.runtime.*;
import java.util.ArrayList;
/** CUP v0.10k TUM Edition 20050516 generated parser.
* @version Fri Jan 04 18:13:12 GMT 2008
*/
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\017\000\002\003\005\000\002\002\004\000\002\003" +
"\005\000\002\003\005\000\002\003\005\000\002\003\003" +
"\000\002\003\003\000\002\003\005\000\002\003\004\000" +
"\002\003\005\000\002\003\003\000\002\004\005\000\002" +
"\004\006\000\002\005\003\000\002\005\005" });
/** Access to production table. */
public short[][] production_table() {return _production_table;}
/** Parse-action table. */
protected static final short[][] _action_table =
unpackFromStrings(new String[] {
"\000\034\000\012\004\007\010\006\014\004\015\011\001" +
"\002\000\022\002\ufffc\005\ufffc\006\ufffc\007\ufffc\010\ufffc" +
"\011\ufffc\012\ufffc\013\ufffc\001\002\000\022\002\ufff7\005" +
"\ufff7\006\ufff7\007\ufff7\010\ufff7\011\ufff7\012\ufff7\013\ufff7" +
"\001\002\000\012\004\007\010\006\014\004\015\011\001" +
"\002\000\012\004\007\010\006\014\004\015\011\001\002" +
"\000\016\002\033\007\016\010\017\011\021\012\020\013" +
"\022\001\002\000\024\002\ufffb\004\012\005\ufffb\006\ufffb" +
"\007\ufffb\010\ufffb\011\ufffb\012\ufffb\013\ufffb\001\002\000" +
"\014\004\007\005\013\010\006\014\004\015\011\001\002" +
"\000\022\002\ufff6\005\ufff6\006\ufff6\007\ufff6\010\ufff6\011" +
"\ufff6\012\ufff6\013\ufff6\001\002\000\006\005\031\006\030" +
"\001\002\000\020\005\ufff4\006\ufff4\007\016\010\017\011" +
"\021\012\020\013\022\001\002\000\012\004\007\010\006" +
"\014\004\015\011\001\002\000\012\004\007\010\006\014" +
"\004\015\011\001\002\000\012\004\007\010\006\014\004" +
"\015\011\001\002\000\012\004\007\010\006\014\004\015" +
"\011\001\002\000\012\004\007\010\006\014\004\015\011" +
"\001\002\000\022\002\ufff8\005\ufff8\006\ufff8\007\ufff8\010" +
"\ufff8\011\ufff8\012\ufff8\013\ufff8\001\002\000\022\002\ufffe" +
"\005\ufffe\006\ufffe\007\ufffe\010\ufffe\011\ufffe\012\ufffe\013" +
"\022\001\002\000\022\002\ufffd\005\ufffd\006\ufffd\007\ufffd" +
"\010\ufffd\011\ufffd\012\ufffd\013\022\001\002\000\022\002" +
"\uffff\005\uffff\006\uffff\007\uffff\010\uffff\011\021\012\020" +
"\013\022\001\002\000\022\002\001\005\001\006\001\007" +
"\001\010\001\011\021\012\020\013\022\001\002\000\012" +
"\004\007\010\006\014\004\015\011\001\002\000\022\002" +
"\ufff5\005\ufff5\006\ufff5\007\ufff5\010\ufff5\011\ufff5\012\ufff5" +
"\013\ufff5\001\002\000\020\005\ufff3\006\ufff3\007\016\010" +
"\017\011\021\012\020\013\022\001\002\000\004\002\000" +
"\001\002\000\016\005\035\007\016\010\017\011\021\012" +
"\020\013\022\001\002\000\022\002\ufffa\005\ufffa\006\ufffa" +
"\007\ufffa\010\ufffa\011\ufffa\012\ufffa\013\ufffa\001\002\000" +
"\022\002\ufff9\005\ufff9\006\ufff9\007\ufff9\010\ufff9\011\021" +
"\012\020\013\022\001\002" });
/** Access to parse-action table. */
public short[][] action_table() {return _action_table;}
/** <code>reduce_goto</code> table. */
protected static final short[][] _reduce_table =
unpackFromStrings(new String[] {
"\000\034\000\006\003\007\004\004\001\001\000\002\001" +
"\001\000\002\001\001\000\006\003\035\004\004\001\001" +
"\000\006\003\033\004\004\001\001\000\002\001\001\000" +
"\002\001\001\000\010\003\014\004\004\005\013\001\001" +
"\000\002\001\001\000\002\001\001\000\002\001\001\000" +
"\006\003\026\004\004\001\001\000\006\003\025\004\004" +
"\001\001\000\006\003\024\004\004\001\001\000\006\003" +
"\023\004\004\001\001\000\006\003\022\004\004\001\001" +
"\000\002\001\001\000\002\001\001\000\002\001\001\000" +
"\002\001\001\000\002\001\001\000\006\003\031\004\004" +
"\001\001\000\002\001\001\000\002\001\001\000\002\001" +
"\001\000\002\001\001\000\002\001\001\000\002\001\001" +
"" });
/** Access to <code>reduce_goto</code> 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 1;}
/** <code>EOF</code> Symbol index. */
public int EOF_sym() {return 0;}
/** <code>error</code> Symbol index. */
public int error_sym() {return 1;}
public static Tree getTree(java.io.InputStream input) throws Exception {
parser p = new parser(new Yylex(input));
Symbol s = p.parse();
return (Tree) s.value;
}
}
/** 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 14: // args ::= args COMMA expr
{
ArrayList<Tree> RESULT = null;
int listleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left;
int listright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right;
ArrayList<Tree> list = (ArrayList<Tree>)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value;
int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left;
int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right;
Tree e = (Tree)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value;
list.add(e); RESULT=list;
CUP$parser$result = new java_cup.runtim