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

📄 state.java

📁 PEPA模型性能分析工具
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package semantic;

import semantic.Symbol;
import gui.PepaConsole;
import trans.Debug;
import trans.Parsing;
import trans.Lexer;
import java.util.Stack;

public class State implements GoState{

	private short next_action[][]={
			{5,-4,13,-4,17,-4,18,-4,22,-4,-1,0},
			{5,16,13,8,17,7,18,12,22,13,-1,0},
			{0,4,-1,0},
			{0,-1,-1,0},
			{7,86,-1,0},
			{3,84,-1,0},
			{22,82,-1,0},
			{0,-38,6,-38,7,-38,9,-38,10,-38,15,-38,16,-38,20,-38,22,-38,-1,0},
			{7,-7,-1,0},
			{5,-3,13,-3,17,-3,18,-3,22,-3,-1,0},
			{0,-40,9,38,10,42,15,39,16,43,22,-40,-1,0},
			{22,65,-1,0},
			{0,-37,8,61,9,-37,10,-37,15,-37,16,-37,22,-37,-1,0},
			{7,60,-1,0},
			{7,-9,-1,0},
			{5,16,13,8,22,18,-1,0},
			{6,40,9,38,10,42,15,39,16,43,-1,0},
			{2,-14,6,-37,9,-37,10,-37,15,-37,16,-37,-1,0},
			{2,20,-1,0},
			{4,21,5,24,22,23,23,25,-1,0},
			{6,-23,12,-23,14,-23,15,-23,16,-23,-1,0},
			{6,37,12,31,14,29,15,30,16,32,-1,0},
			{6,-22,12,-22,14,-22,15,-22,16,-22,-1,0},
			{4,21,5,24,22,23,23,25,-1,0},
			{6,-12,7,-12,12,-12,14,-12,15,-12,16,-12,-1,0},
			{6,-21,12,-21,14,-21,15,-21,16,-21,-1,0},
			{6,28,12,31,14,29,15,30,16,32,-1,0},
			{6,-20,12,-20,14,-20,15,-20,16,-20,-1,0},
			{4,21,5,24,22,23,23,25,-1,0},
			{4,21,5,24,22,23,23,25,-1,0},
			{4,21,5,24,22,23,23,25,-1,0},
			{4,21,5,24,22,23,23,25,-1,0},
			{6,-19,12,-19,14,-19,15,-19,16,-19,-1,0},
			{6,-17,12,-17,14,29,15,-17,16,32,-1,0},
			{6,-16,12,-16,14,29,15,-16,16,32,-1,0},
			{6,-18,12,-18,14,-18,15,-18,16,-18,-1,0},
			{3,-15,-1,0},
			{5,-26,13,-26,22,-26,-1,0},
			{5,16,13,8,22,58,-1,0},
			{0,-36,6,-36,7,-36,9,-36,10,-36,15,-36,16,-36,20,-36,22,-36,-1,0},
			{5,16,13,8,22,58,-1,0},
			{11,53,19,45,22,46,-1,0},
			{19,45,-1,0},
			{0,-35,6,-35,7,-35,9,-35,10,-35,15,-35,16,-35,20,-35,22,-35,-1,0},
			{22,46,-1,0},
			{2,-14,11,-14,20,-14,-1,0},
			{2,-31,11,-31,20,-31,-1,0},
			{2,49,20,50,-1,0},
			{22,46,-1,0},
			{0,-29,6,-29,7,-29,9,-29,10,-29,11,-29,15,-29,16,-29,20,-29,22,-29,-1,0},
			{2,-30,11,-30,20,-30,-1,0},
			{11,-27,-1,0},
			{5,-25,13,-25,22,-25,-1,0},
			{2,49,11,-28,-1,0},
			{11,56,-1,0},
			{5,-24,13,-24,22,-24,-1,0},
			{0,-34,6,-34,7,-34,9,-34,10,-34,15,-34,16,43,20,-34,22,-34,-1,0},
			{0,-37,6,-37,7,-37,9,-37,10,-37,15,-37,16,-37,20,-37,22,-37,-1,0},
			{0,-33,6,-33,7,-33,9,38,10,42,15,-33,16,43,20,-33,22,-33,-1,0},
			{5,-5,13,-5,17,-5,18,-5,22,-5,-1,0},
			{5,16,13,8,22,58,23,25,-1,0},
			{7,-13,9,38,10,42,15,39,16,43,-1,0},
			{7,-11,-1,0},
			{7,-8,-1,0},
			{8,66,-1,0},
			{23,25,-1,0},
			{0,-2,22,69,-1,0},
			{0,-39,22,-39,-1,0},
			{8,70,-1,0},
			{4,21,5,24,19,72,22,23,23,25,-1,0},
			{12,31,14,76,15,30,16,32,-1,0},
			{5,16,13,8,22,58,-1,0},
			{9,38,10,42,15,39,16,43,20,74,-1,0},
			{7,75,-1,0},
			{0,-41,22,-41,-1,0},
			{4,21,5,24,19,77,22,23,23,25,-1,0},
			{5,16,13,8,22,58,-1,0},
			{9,38,10,42,15,39,16,43,20,79,-1,0},
			{7,80,-1,0},
			{0,-42,22,-42,-1,0},
			{7,-10,-1,0},
			{8,83,-1,0},
			{5,16,13,8,22,58,-1,0},
		    {5,16,13,8,22,58,-1,0},
			{0,-32,6,-32,7,-32,9,-32,10,-32,15,-32,16,43,20,-32,22,-32,-1,0},
			{5,-6,13,-6,17,-6,18,-6,22,-6,-1,0}
			};
	
	private short reduce_action[][]={
			{1,1,4,2,-1,-1},
			{2,9,3,10,5,14,6,13,7,8,8,4,9,5,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{5,80,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{14,40,17,66,-1,-1},
			{7,63,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{3,16,9,5,10,18,-1,-1},
			{14,40,-1,-1},
			{-1,-1},
			{-1,-1},
			{15,25,16,21,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{15,25,16,26,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{15,25,16,35,-1,-1},
			{15,25,16,34,-1,-1},
			{15,25,16,33,-1,-1},
			{15,25,16,32,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{3,58,9,5,-1,-1},
			{-1,-1},
			{3,56,9,5,-1,-1},
		    {10,46,11,54,12,51,13,53,-1,-1},
			{12,43,-1,-1},
			{-1,-1},
			{10,46,13,47,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{10,50,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{14,40,-1,-1},
			{-1,-1},
			{14,40,-1,-1},
			{-1,-1},
			{3,61,9,5,15,62,-1,-1},
			{14,40,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{15,62,-1,-1},
			{18,67,-1,-1},
			{-1,-1},
			{-1,-1},
			{15,25,16,70,-1,-1},
			{-1,-1},
			{3,72,9,5,-1,-1},
			{14,40,-1,-1},
			{-1,-1},
			{-1,-1},
			{15,25,16,35,-1,-1},
			{3,77,9,5,-1,-1},
			{14,40,-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
			{-1,-1},
		   {3,61,9,5,-1,-1},
			{3,84,9,5,-1,-1},
			{14,40,-1,-1},
			{-1,-1}
	};
	
	private short product_action[][]={
			{0,2},
			{4,3},
			{1,2},
			{1,0},
			{2,2},
			{2,2},
			{8,1},
			{8,2},
			{6,1},
			{6,2},
			{7,3},
			{15,1},
			{5,3},
			{10,1},
			{9,5},
			{16,3},
			{16,3},
			{16,3},
			{16,3},
			{16,3},
			{16,1},
			{16,1},
			{16,1},
			{14,3},
			{14,2},
			{14,1},
			{11,1},
			{11,1},
			{12,3},
			{13,3},
			{13,1},
			{3,3},
			{3,3},
			{3,3},
			{3,3},
			{3,3},
			{3,1},
			{3,1},
			{17,2},
			{17,0},
			{18,6},
			{18,8}
	};
	
	public short get_action(int state,int sym)
	{
        short row[] = next_action[state];
        if(row.length < 20)
        {
            for(int probe = 0; probe < row.length; probe++)
            {
                short tag = row[probe++];
                if(tag == sym || tag == -1)
                    return row[probe];
            }

        } else
        {
            int first = 0;
            for(int last = (row.length - 1) / 2 - 1; first <= last;)
            {
                int probe = (first + last) / 2;
                if(sym == row[probe * 2])
                    return row[probe * 2 + 1];
                if(sym > row[probe * 2])
                    first = probe + 1;
                else
                    last = probe - 1;
            }

            return row[row.length - 1];
        }
        return (short)0;
	}
	
	public short get_reduce(int state,int sym)
	{
		 short row[] = reduce_action[state];
	        if(row == null)
	            return (short)-1;
	        for(int probe = 0; probe < row.length; probe++)
	        {
	            short tag = row[probe++];
	            if(tag == sym || tag == -1)
	                return row[probe];
	        }

	        return (short)-1;
	}
	
	public short sym_num(int state)
	{
		return product_action[state][0];
	}
	public short sym_size(int state)
	{
		return product_action[state][1];
	}

	public Symbol do_action(int act,Stack symstack) throws ParserException, RateException
	{
		int top=symstack.size()-1;
		Symbol result=null;
		switch(act)
		{
		case 41: // resdefn ::= STRN EQUALS rate MULT LSET proc RSET SEMI 
		{	
			String s = (String)((Symbol)symstack.elementAt(top-7)).value;
			Rate r=(Rate)((Symbol)symstack.elementAt(top-5)).value;
			Process p= (Process)((Symbol)symstack.elementAt(top-2)).value;
			Process.addmult(s, r, p);
			Debug.println(5, "Found Result Definition:\t\t"+s+"="+r+"*"+p);
			result=new Symbol(18);
			return result;
		}
		case 40: // resdefn ::= STRN EQUALS LSET proc RSET SEMI 
		{	
			String s = (String)((Symbol)symstack.elementAt(top-5)).value;
			Process p= (Process)((Symbol)symstack.elementAt(top-2)).value;
			Process.addDef(s,p);
			Debug.println(5, "Found Process Definition:\t\t"+s+"="+p); 
			result=new Symbol(18);

⌨️ 快捷键说明

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