Class Parser


  • public class Parser
    extends java_cup.runtime.lr_parser
    CUP v0.11b 20160615 (GIT 4ac7450) generated parser.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static short[][] _action_table
      Parse-action table.
      protected static short[][] _production_table
      Production table.
      protected static short[][] _reduce_table
      reduce_goto table.
      protected adams.parser.mathematicalexpression.Parser.CUP$Parser$actions action_obj
      Instance of action encapsulation class.
      protected ParserHelper m_Helper
      the helper.
      protected Double m_Result
      for storing the result of the expression.
      protected HashMap m_Symbols
      variable - value relation.
      • Fields inherited from class java_cup.runtime.lr_parser

        _done_parsing, _error_sync_size, action_tab, cur_token, lookahead, lookahead_pos, production_tab, reduce_tab, stack, symbolFactory, tos
    • Constructor Summary

      Constructors 
      Constructor Description
      Parser()
      Deprecated.
      Parser​(java_cup.runtime.Scanner s)
      Deprecated.
      Parser​(java_cup.runtime.Scanner s, java_cup.runtime.SymbolFactory sf)
      Constructor which sets the default scanner.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      short[][] action_table()
      Access to parse-action table.
      java_cup.runtime.Symbol do_action​(int act_num, java_cup.runtime.lr_parser parser, Stack stack, int top)
      Invoke a user supplied parse action.
      int EOF_sym()
      EOF Symbol index.
      int error_sym()
      error Symbol index.
      ParserHelper getHelper()
      Returns the parser helper.
      Double getResult()
      Returns the result of the evaluation.
      Class getSymbolContainer()  
      HashMap getSymbols()
      Returns the current variable - value relation in use.
      protected void init_actions()
      Action encapsulation object initializer.
      static void main​(String[] args)
      Runs the parser from commandline.
      short[][] production_table()
      Access to production table.
      short[][] reduce_table()
      Access to reduce_goto table.
      void setResult​(Double value)
      Sets the result of the evaluation.
      void setSymbols​(HashMap value)
      Sets the variable - value relation to use.
      int start_production()
      Indicates start production.
      int start_state()
      Indicates start state.
      • Methods inherited from class java_cup.runtime.lr_parser

        advance_lookahead, cur_err_token, debug_message, debug_parse, debug_reduce, debug_shift, debug_stack, done_parsing, dump_stack, error_recovery, error_sync_size, expected_token_ids, find_recovery_config, get_action, get_reduce, getScanner, getSymbolFactory, parse, parse_lookahead, read_lookahead, report_error, report_expected_token_ids, report_fatal_error, restart_lookahead, scan, setScanner, shift_under_error, symbl_name_from_id, syntax_error, try_parse_ahead, unpackFromStrings, unrecovered_syntax_error, user_init
    • Field Detail

      • _production_table

        protected static final short[][] _production_table
        Production table.
      • _action_table

        protected static final short[][] _action_table
        Parse-action table.
      • _reduce_table

        protected static final short[][] _reduce_table
        reduce_goto table.
      • action_obj

        protected adams.parser.mathematicalexpression.Parser.CUP$Parser$actions action_obj
        Instance of action encapsulation class.
      • m_Symbols

        protected HashMap m_Symbols
        variable - value relation.
      • m_Result

        protected Double m_Result
        for storing the result of the expression.
    • Constructor Detail

      • Parser

        @Deprecated
        public Parser()
        Deprecated.
        Default constructor.
      • Parser

        @Deprecated
        public Parser​(java_cup.runtime.Scanner s)
        Deprecated.
        Constructor which sets the default scanner.
      • Parser

        public Parser​(java_cup.runtime.Scanner s,
                      java_cup.runtime.SymbolFactory sf)
        Constructor which sets the default scanner.
    • Method Detail

      • getSymbolContainer

        public final Class getSymbolContainer()
        Overrides:
        getSymbolContainer in class java_cup.runtime.lr_parser
      • production_table

        public short[][] production_table()
        Access to production table.
        Specified by:
        production_table in class java_cup.runtime.lr_parser
      • action_table

        public short[][] action_table()
        Access to parse-action table.
        Specified by:
        action_table in class java_cup.runtime.lr_parser
      • reduce_table

        public short[][] reduce_table()
        Access to reduce_goto table.
        Specified by:
        reduce_table in class java_cup.runtime.lr_parser
      • init_actions

        protected void init_actions()
        Action encapsulation object initializer.
        Specified by:
        init_actions in class java_cup.runtime.lr_parser
      • do_action

        public java_cup.runtime.Symbol do_action​(int act_num,
                                                 java_cup.runtime.lr_parser parser,
                                                 Stack stack,
                                                 int top)
                                          throws Exception
        Invoke a user supplied parse action.
        Specified by:
        do_action in class java_cup.runtime.lr_parser
        Throws:
        Exception
      • start_state

        public int start_state()
        Indicates start state.
        Specified by:
        start_state in class java_cup.runtime.lr_parser
      • start_production

        public int start_production()
        Indicates start production.
        Specified by:
        start_production in class java_cup.runtime.lr_parser
      • EOF_sym

        public int EOF_sym()
        EOF Symbol index.
        Specified by:
        EOF_sym in class java_cup.runtime.lr_parser
      • error_sym

        public int error_sym()
        error Symbol index.
        Specified by:
        error_sym in class java_cup.runtime.lr_parser
      • setSymbols

        public void setSymbols​(HashMap value)
        Sets the variable - value relation to use.
        Parameters:
        value - the variable-value relation
      • getSymbols

        public HashMap getSymbols()
        Returns the current variable - value relation in use.
        Returns:
        the variable-value relation
      • getHelper

        public ParserHelper getHelper()
        Returns the parser helper.
        Returns:
        the helper
      • setResult

        public void setResult​(Double value)
        Sets the result of the evaluation.
        Parameters:
        value - the result
      • getResult

        public Double getResult()
        Returns the result of the evaluation.
        Returns:
        the result
      • main

        public static void main​(String[] args)
                         throws Exception
        Runs the parser from commandline. Either reads lines from System.in or from a provided file (line by line). With -symbols as first parameter one can provide predefined variable values. E.g.: -symbols "Y=10;X=3" "X+Y"
        Parameters:
        args - the commandline arguments
        Throws:
        Exception - if something goes wrong