Advertisement
szabivan

FormulaParser.java (generated, v1)

Apr 18th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.37 KB | None | 0 0
  1.  
  2. //----------------------------------------------------
  3. // The following code was generated by CUP v0.11b 20150326 (SVN rev 63)
  4. //----------------------------------------------------
  5.  
  6. package szabivan.cup;
  7.  
  8. import java_cup.runtime.*;
  9. import formula.data.*;
  10. import java_cup.runtime.XMLElement;
  11.  
  12. /** CUP v0.11b 20150326 (SVN rev 63) generated parser.
  13.   */
  14. @SuppressWarnings({"rawtypes"})
  15. public class FormulaParser extends java_cup.runtime.lr_parser {
  16.  
  17.  public final Class getSymbolContainer() {
  18.     return FormulaParserSym.class;
  19. }
  20.  
  21.   /** Default constructor. */
  22.   @Deprecated
  23.   public FormulaParser() {super();}
  24.  
  25.   /** Constructor which sets the default scanner. */
  26.   @Deprecated
  27.   public FormulaParser(java_cup.runtime.Scanner s) {super(s);}
  28.  
  29.   /** Constructor which sets the default scanner. */
  30.   public FormulaParser(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf) {super(s,sf);}
  31.  
  32.   /** Production table. */
  33.   protected static final short _production_table[][] =
  34.     unpackFromStrings(new String[] {
  35.     "\000\012\000\002\002\003\000\002\002\004\000\002\002" +
  36.     "\005\000\002\002\005\000\002\002\005\000\002\002\005" +
  37.     "\000\002\002\005\000\002\002\004\000\002\002\003\000" +
  38.     "\002\002\003" });
  39.  
  40.   /** Access to production table. */
  41.   public short[][] production_table() {return _production_table;}
  42.  
  43.   /** Parse-action table. */
  44.   protected static final short[][] _action_table =
  45.     unpackFromStrings(new String[] {
  46.     "\000\023\000\014\010\006\012\004\013\005\014\007\015" +
  47.     "\010\001\002\000\016\002\ufff9\004\ufff9\005\ufff9\006\ufff9" +
  48.     "\007\ufff9\011\ufff9\001\002\000\016\002\ufff8\004\ufff8\005" +
  49.     "\ufff8\006\ufff8\007\ufff8\011\ufff8\001\002\000\014\010\006" +
  50.     "\012\004\013\005\014\007\015\010\001\002\000\014\010" +
  51.     "\006\012\004\013\005\014\007\015\010\001\002\000\016" +
  52.     "\002\001\004\001\005\001\006\001\007\001\011\001\001" +
  53.     "\002\000\014\002\015\004\016\005\013\006\012\007\014" +
  54.     "\001\002\000\014\010\006\012\004\013\005\014\007\015" +
  55.     "\010\001\002\000\014\010\006\012\004\013\005\014\007" +
  56.     "\015\010\001\002\000\014\010\006\012\004\013\005\014" +
  57.     "\007\015\010\001\002\000\004\002\000\001\002\000\014" +
  58.     "\010\006\012\004\013\005\014\007\015\010\001\002\000" +
  59.     "\016\002\ufffe\004\ufffe\005\013\006\ufffe\007\ufffe\011\ufffe" +
  60.     "\001\002\000\016\002\ufffb\004\016\005\013\006\012\007" +
  61.     "\ufffb\011\ufffb\001\002\000\016\002\ufffd\004\ufffd\005\ufffd" +
  62.     "\006\ufffd\007\ufffd\011\ufffd\001\002\000\016\002\ufffc\004" +
  63.     "\016\005\013\006\012\007\ufffc\011\ufffc\001\002\000\016" +
  64.     "\002\ufffa\004\ufffa\005\ufffa\006\ufffa\007\ufffa\011\ufffa\001" +
  65.     "\002\000\014\004\016\005\013\006\012\007\014\011\025" +
  66.     "\001\002\000\016\002\uffff\004\uffff\005\uffff\006\uffff\007" +
  67.     "\uffff\011\uffff\001\002" });
  68.  
  69.   /** Access to parse-action table. */
  70.   public short[][] action_table() {return _action_table;}
  71.  
  72.   /** <code>reduce_goto</code> table. */
  73.   protected static final short[][] _reduce_table =
  74.     unpackFromStrings(new String[] {
  75.     "\000\023\000\004\002\010\001\001\000\002\001\001\000" +
  76.     "\002\001\001\000\004\002\023\001\001\000\004\002\022" +
  77.     "\001\001\000\002\001\001\000\002\001\001\000\004\002" +
  78.     "\021\001\001\000\004\002\020\001\001\000\004\002\017" +
  79.     "\001\001\000\002\001\001\000\004\002\016\001\001\000" +
  80.     "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
  81.     "\001\001\000\002\001\001\000\002\001\001\000\002\001" +
  82.     "\001" });
  83.  
  84.   /** Access to <code>reduce_goto</code> table. */
  85.   public short[][] reduce_table() {return _reduce_table;}
  86.  
  87.   /** Instance of action encapsulation class. */
  88.   protected CUP$FormulaParser$actions action_obj;
  89.  
  90.   /** Action encapsulation object initializer. */
  91.   protected void init_actions()
  92.     {
  93.       action_obj = new CUP$FormulaParser$actions(this);
  94.     }
  95.  
  96.   /** Invoke a user supplied parse action. */
  97.   public java_cup.runtime.Symbol do_action(
  98.     int                        act_num,
  99.     java_cup.runtime.lr_parser parser,
  100.     java.util.Stack            stack,
  101.     int                        top)
  102.     throws java.lang.Exception
  103.   {
  104.     /* call code in generated class */
  105.     return action_obj.CUP$FormulaParser$do_action(act_num, parser, stack, top);
  106.   }
  107.  
  108.   /** Indicates start state. */
  109.   public int start_state() {return 0;}
  110.   /** Indicates start production. */
  111.   public int start_production() {return 1;}
  112.  
  113.   /** <code>EOF</code> Symbol index. */
  114.   public int EOF_sym() {return 0;}
  115.  
  116.   /** <code>error</code> Symbol index. */
  117.   public int error_sym() {return 1;}
  118.  
  119.  
  120. /** Cup generated class to encapsulate user supplied action code.*/
  121. @SuppressWarnings({"rawtypes", "unchecked", "unused"})
  122. class CUP$FormulaParser$actions {
  123.   private final FormulaParser parser;
  124.  
  125.   /** Constructor */
  126.   CUP$FormulaParser$actions(FormulaParser parser) {
  127.     this.parser = parser;
  128.   }
  129.  
  130.   /** Method 0 with the actual generated action code for actions 0 to 300. */
  131.   public final java_cup.runtime.Symbol CUP$FormulaParser$do_action_part00000000(
  132.     int                        CUP$FormulaParser$act_num,
  133.     java_cup.runtime.lr_parser CUP$FormulaParser$parser,
  134.     java.util.Stack            CUP$FormulaParser$stack,
  135.     int                        CUP$FormulaParser$top)
  136.     throws java.lang.Exception
  137.     {
  138.       /* Symbol object for return from actions */
  139.       java_cup.runtime.Symbol CUP$FormulaParser$result;
  140.  
  141.       /* select the action based on the action number */
  142.       switch (CUP$FormulaParser$act_num)
  143.         {
  144.           /*. . . . . . . . . . . . . . . . . . . .*/
  145.           case 0: // formula ::= VARIABLE
  146.             {
  147.               Formula RESULT =null;
  148.  
  149.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("formula",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  150.             }
  151.           return CUP$FormulaParser$result;
  152.  
  153.           /*. . . . . . . . . . . . . . . . . . . .*/
  154.           case 1: // $START ::= formula EOF
  155.             {
  156.               Object RESULT =null;
  157.         int start_valleft = ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-1)).left;
  158.         int start_valright = ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-1)).right;
  159.         Formula start_val = (Formula)((java_cup.runtime.Symbol) CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-1)).value;
  160.         RESULT = start_val;
  161.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-1)), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  162.             }
  163.           /* ACCEPT */
  164.           CUP$FormulaParser$parser.done_parsing();
  165.           return CUP$FormulaParser$result;
  166.  
  167.           /*. . . . . . . . . . . . . . . . . . . .*/
  168.           case 2: // formula ::= LPAREN formula RPAREN
  169.             {
  170.               Formula RESULT =null;
  171.  
  172.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("formula",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-2)), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  173.             }
  174.           return CUP$FormulaParser$result;
  175.  
  176.           /*. . . . . . . . . . . . . . . . . . . .*/
  177.           case 3: // formula ::= formula VEE formula
  178.             {
  179.               Formula RESULT =null;
  180.  
  181.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("formula",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-2)), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  182.             }
  183.           return CUP$FormulaParser$result;
  184.  
  185.           /*. . . . . . . . . . . . . . . . . . . .*/
  186.           case 4: // formula ::= formula WEDGE formula
  187.             {
  188.               Formula RESULT =null;
  189.  
  190.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("formula",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-2)), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  191.             }
  192.           return CUP$FormulaParser$result;
  193.  
  194.           /*. . . . . . . . . . . . . . . . . . . .*/
  195.           case 5: // formula ::= formula IMPLIES formula
  196.             {
  197.               Formula RESULT =null;
  198.  
  199.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("formula",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-2)), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  200.             }
  201.           return CUP$FormulaParser$result;
  202.  
  203.           /*. . . . . . . . . . . . . . . . . . . .*/
  204.           case 6: // formula ::= formula IFF formula
  205.             {
  206.               Formula RESULT =null;
  207.  
  208.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("formula",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-2)), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  209.             }
  210.           return CUP$FormulaParser$result;
  211.  
  212.           /*. . . . . . . . . . . . . . . . . . . .*/
  213.           case 7: // formula ::= NEGATION formula
  214.             {
  215.               Formula RESULT =null;
  216.  
  217.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("formula",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.elementAt(CUP$FormulaParser$top-1)), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  218.             }
  219.           return CUP$FormulaParser$result;
  220.  
  221.           /*. . . . . . . . . . . . . . . . . . . .*/
  222.           case 8: // formula ::= UP
  223.             {
  224.               Formula RESULT =null;
  225.  
  226.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("formula",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  227.             }
  228.           return CUP$FormulaParser$result;
  229.  
  230.           /*. . . . . . . . . . . . . . . . . . . .*/
  231.           case 9: // formula ::= DOWN
  232.             {
  233.               Formula RESULT =null;
  234.  
  235.               CUP$FormulaParser$result = parser.getSymbolFactory().newSymbol("formula",0, ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$FormulaParser$stack.peek()), RESULT);
  236.             }
  237.           return CUP$FormulaParser$result;
  238.  
  239.           /* . . . . . .*/
  240.           default:
  241.             throw new Exception(
  242.                "Invalid action number "+CUP$FormulaParser$act_num+"found in internal parse table");
  243.  
  244.         }
  245.     } /* end of method */
  246.  
  247.   /** Method splitting the generated action code into several parts. */
  248.   public final java_cup.runtime.Symbol CUP$FormulaParser$do_action(
  249.     int                        CUP$FormulaParser$act_num,
  250.     java_cup.runtime.lr_parser CUP$FormulaParser$parser,
  251.     java.util.Stack            CUP$FormulaParser$stack,
  252.     int                        CUP$FormulaParser$top)
  253.     throws java.lang.Exception
  254.     {
  255.               return CUP$FormulaParser$do_action_part00000000(
  256.                                CUP$FormulaParser$act_num,
  257.                                CUP$FormulaParser$parser,
  258.                                CUP$FormulaParser$stack,
  259.                                CUP$FormulaParser$top);
  260.     }
  261. }
  262.  
  263. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement