⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exprparser.java

📁 实现的一个简单的语言编译器,可以编译类JAVA 的小语言
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    "\030\051\031\060\033\067\034\070\035\041\036\042\040" +
    "\065\041\062\044\066\055\071\056\064\057\052\060\054" +
    "\061\055\062\037\063\050\064\045\001\001\000\002\001" +
    "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
    "\000\002\001\001\000\042\027\056\030\155\031\060\034" +
    "\070\035\041\036\042\040\065\044\066\055\071\056\064" +
    "\057\052\060\054\061\055\062\037\063\050\064\045\001" +
    "\001\000\002\001\001\000\044\005\153\027\056\030\100" +
    "\031\060\034\070\035\041\036\042\040\065\044\066\055" +
    "\071\056\064\057\052\060\054\061\055\062\037\063\050" +
    "\064\045\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\000\002\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\000\002\001\001\000\002\001\001\000" +
    "\014\031\116\036\042\040\065\044\066\055\071\001\001" +
    "\000\002\001\001\000\004\042\107\001\001\000\002\001" +
    "\001\000\042\027\056\030\104\031\060\034\070\035\041" +
    "\036\042\040\065\044\066\055\071\056\064\057\052\060" +
    "\054\061\055\062\037\063\050\064\045\001\001\000\044" +
    "\005\077\027\056\030\100\031\060\034\070\035\041\036" +
    "\042\040\065\044\066\055\071\056\064\057\052\060\054" +
    "\061\055\062\037\063\050\064\045\001\001\000\002\001" +
    "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
    "\000\002\001\001\000\042\027\056\030\103\031\060\034" +
    "\070\035\041\036\042\040\065\044\066\055\071\056\064" +
    "\057\052\060\054\061\055\062\037\063\050\064\045\001" +
    "\001\000\002\001\001\000\002\001\001\000\002\001\001" +
    "\000\002\001\001\000\002\001\001\000\040\027\056\031" +
    "\060\034\070\035\115\036\042\040\065\044\066\055\071" +
    "\056\064\057\052\060\054\061\055\062\037\063\050\064" +
    "\045\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\000\002\001\001\000\014\031\124\036\042\040\065" +
    "\044\066\055\071\001\001\000\014\031\123\036\042\040" +
    "\065\044\066\055\071\001\001\000\014\031\122\036\042" +
    "\040\065\044\066\055\071\001\001\000\002\001\001\000" +
    "\002\001\001\000\002\001\001\000\022\031\127\036\042" +
    "\040\065\044\066\055\071\056\064\057\052\060\145\001" +
    "\001\000\022\031\127\036\042\040\065\044\066\055\071" +
    "\056\064\057\052\060\130\001\001\000\002\001\001\000" +
    "\002\001\001\000\020\031\127\036\042\040\065\044\066" +
    "\055\071\056\064\057\144\001\001\000\020\031\127\036" +
    "\042\040\065\044\066\055\071\056\064\057\143\001\001" +
    "\000\020\031\127\036\042\040\065\044\066\055\071\056" +
    "\064\057\142\001\001\000\020\031\127\036\042\040\065" +
    "\044\066\055\071\056\064\057\135\001\001\000\002\001" +
    "\001\000\016\031\127\036\042\040\065\044\066\055\071" +
    "\056\\001\001\000\016\031\127\036\042\040\065\044" +
    "\066\055\071\056\140\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\000\026\031\127\036\042\040\065" +
    "\044\066\055\071\056\064\057\052\060\054\061\055\062" +
    "\147\001\001\000\002\001\001\000\024\031\127\036\042" +
    "\040\065\044\066\055\071\056\064\057\052\060\054\061" +
    "\151\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\000\002\001\001\000\002\001\001\000\002\001\001" +
    "\000\002\001\001\000\002\001\001\000\014\006\165\045" +
    "\016\046\167\047\024\054\166\001\001\000\002\001\001" +
    "\000\002\001\001\000\006\037\273\055\027\001\001\000" +
    "\004\070\171\001\001\000\006\010\172\011\174\001\001" +
    "\000\002\001\001\000\004\066\175\001\001\000\002\001" +
    "\001\000\056\003\223\011\202\013\210\014\217\015\214" +
    "\020\221\021\204\022\200\023\224\025\222\026\220\027" +
    "\205\031\206\032\177\034\070\036\215\040\065\044\066" +
    "\045\016\046\225\047\024\055\071\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\000\002\001\001\000" +
    "\002\001\001\000\002\001\001\000\002\001\001\000\002" +
    "\001\001\000\042\027\056\030\241\031\060\034\070\035" +
    "\041\036\042\040\065\044\066\055\071\056\064\057\052" +
    "\060\054\061\055\062\037\063\050\064\045\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\000\002\001" +
    "\001\000\002\001\001\000\002\001\001\000\054\011\202" +
    "\013\210\014\230\015\214\020\221\021\204\022\200\023" +
    "\224\025\222\026\220\027\205\031\206\032\177\034\070" +
    "\036\215\040\065\044\066\045\016\046\225\047\024\055" +
    "\071\001\001\000\002\001\001\000\012\004\226\037\026" +
    "\050\030\055\027\001\001\000\002\001\001\000\002\001" +
    "\001\000\002\001\001\000\002\001\001\000\042\027\056" +
    "\030\233\031\060\034\070\035\041\036\042\040\065\044" +
    "\066\055\071\056\064\057\052\060\054\061\055\062\037" +
    "\063\050\064\045\001\001\000\002\001\001\000\042\011" +
    "\202\013\235\015\214\020\221\021\204\022\200\023\224" +
    "\025\222\027\205\031\206\032\177\034\070\036\215\040" +
    "\065\044\066\055\071\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\000\042\027\056\030\244\031\060" +
    "\034\070\035\041\036\042\040\065\044\066\055\071\056" +
    "\064\057\052\060\054\061\055\062\037\063\050\064\045" +
    "\001\001\000\002\001\001\000\050\011\202\013\251\015" +
    "\214\016\252\017\247\020\254\021\204\022\200\023\224" +
    "\024\246\025\222\027\205\031\206\032\177\034\070\036" +
    "\215\040\065\044\066\055\071\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\000\002\001\001\000\042" +
    "\027\056\030\256\031\060\034\070\035\041\036\042\040" +
    "\065\044\066\055\071\056\064\057\052\060\054\061\055" +
    "\062\037\063\050\064\045\001\001\000\002\001\001\000" +
    "\050\011\202\013\235\015\214\016\252\017\260\020\254" +
    "\021\204\022\200\023\224\024\246\025\222\027\205\031" +
    "\206\032\177\034\070\036\215\040\065\044\066\055\071" +
    "\001\001\000\002\001\001\000\042\027\056\030\262\031" +
    "\060\034\070\035\041\036\042\040\065\044\066\055\071" +
    "\056\064\057\052\060\054\061\055\062\037\063\050\064" +
    "\045\001\001\000\002\001\001\000\050\011\202\013\251" +
    "\015\214\016\252\017\264\020\254\021\204\022\200\023" +
    "\224\024\246\025\222\027\205\031\206\032\177\034\070" +
    "\036\215\040\065\044\066\055\071\001\001\000\002\001" +
    "\001\000\050\011\202\013\267\015\214\016\252\017\266" +
    "\020\254\021\204\022\200\023\224\024\246\025\222\027" +
    "\205\031\206\032\177\034\070\036\215\040\065\044\066" +
    "\055\071\001\001\000\002\001\001\000\002\001\001\000" +
    "\042\011\202\013\267\015\214\020\221\021\204\022\200" +
    "\023\224\025\222\027\205\031\206\032\177\034\070\036" +
    "\215\040\065\044\066\055\071\001\001\000\002\001\001" +
    "\000\002\001\001\000\002\001\001\000\012\045\016\046" +
    "\167\047\024\054\300\001\001\000\004\067\276\001\001" +
    "\000\006\010\277\011\174\001\001\000\002\001\001\000" +
    "\002\001\001\000\042\027\056\030\303\031\060\034\070" +
    "\035\041\036\042\040\065\044\066\055\071\056\064\057" +
    "\052\060\054\061\055\062\037\063\050\064\045\001\001" +
    "\000\002\001\001\000\002\001\001\000\002\001\001\000" +
    "\042\027\056\030\307\031\060\034\070\035\041\036\042" +
    "\040\065\044\066\055\071\056\064\057\052\060\054\061" +
    "\055\062\037\063\050\064\045\001\001\000\002\001\001" +
    "\000\002\001\001\000\002\001\001\000\012\004\317\037" +
    "\026\050\030\055\316\001\001\000\010\045\016\046\313" +
    "\047\024\001\001\000\012\004\314\037\026\050\030\055" +
    "\027\001\001\000\002\001\001\000\002\001\001\000\002" +
    "\001\001\000\002\001\001\000\002\001\001\000\014\006" +
    "\322\045\016\046\167\047\024\054\166\001\001\000\002" +
    "\001\001\000\004\072\324\001\001\000\006\010\325\011" +
    "\174\001\001\000\002\001\001\000\004\071\327\001\001" +
    "\000\006\010\330\011\174\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$ExprParser$actions action_obj;

  /** Action encapsulation object initializer. */
  protected void init_actions()
    {
      action_obj = new CUP$ExprParser$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$ExprParser$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;}

  /** <code>EOF</code> Symbol index. */
  public int EOF_sym() {return 0;}

  /** <code>error</code> Symbol index. */
  public int error_sym() {return 1;}


    private boolean success = true;    private boolean debug = false;	    public InterRepresent doParse(File src) throws ParserException {		System.out.println("front:PB05210242");		ExprLexer lexer = null;        try {            lexer = new ExprLexer( new FileReader(src) );        } catch (FileNotFoundException e) {            throw new ParserException();        }                setScanner(lexer);        symbolFactory = new DefaultSymbolFactory();        try {            parse();        }catch (Exception e) {            System.err.println("Parser Exception.");            if (debug) {                e.printStackTrace();            }            throw new ParserException();        }        myHIR ir = new myHIR();        ir.setIR(action_obj.getAST());        ir.setTable(action_obj.majesty,action_obj.methodTable);        /*HIR ir = new HIR();        ir.setIR(action_obj.getAST());*/                success = action_obj.success();         if (!success) {        	System.out.println("[NOTICE] Vital error found in the parser,compilering stopped.....");        	System.exit(-1);        }        return ir;	}		public static void main(String[] argv)  throws ParserException{        String srcFileName = "C:/ROOT_DIR/PB05011/PB05210242/test/exp_list.tx";  // source file name        File srcFile = new File(srcFileName);        System.out.println("front:PB05210242");                ExprParser parser = new ExprParser();        HIR ir = null;        try {            ir = (HIR)parser.doParse(srcFile);        } catch (ParserException e) {            System.err.println("ParserException");            e.printStackTrace();            System.exit(-1);        }                ASTViewer astviewer = new ASTViewer((ASTNode)ir.getIR(), new GenericPropertyDump());        astviewer.show();    }    public boolean getResult(){    	return success;    }   
}

/** Cup generated class to encapsulate user supplied action code.*/
class CUP$ExprParser$actions {

	private AST ast = AST.newAST(AST.JLS3);    private CompilationUnit root = ast.newCompilationUnit(); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -