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

📄 exc.jj

📁 a small Excel made bye java and javacc
💻 JJ
📖 第 1 页 / 共 2 页
字号:
options {
  JDK_VERSION = "1.5";
  STATIC= false ;
}
PARSER_BEGIN(Exc)   
package javacctp;   
import tpdos.*;
import javax.swing.JOptionPane;    
import java.io.PrintStream ; 
import java.io.ByteArrayInputStream;
 public class Exc {
  	public Exc(String Text){
        	this(new ByteArrayInputStream(Text.getBytes(), 0, Text.length()));       	
  	}
public  Object evale()
    throws ParseException, TokenMgrError, NumberFormatException 
    {
      return formul();  
	  }   
	  double previousValue = 0.0 ;    
	  double [][]arguments=new double [20][20] ;
      int [] tab=new int[20];
	  /************************************************/	
	 
double sume(int i)
{
double r = 0 ;
 for (int j = 0 ; j <= tab[i] ; j ++)
  r += arguments[i][j] ;
       
 return r ;
}
/****************************************************/
 int entier(int s)
 { int k=0;
	  if(s>=65||s<=90 ){ k=s-65 ;return k; }
	  else if(s>=97||s<=122){k=s-97;return k;}
	  else return k;
	  }  
/************************************************/
void recalcul(String chaine){
	for(int i=0;i<=Excel.table.getRowCount();i++){
		for(int j=0;j<=Excel.table.getColumnCount();j++){
	Excel.tablesave[i][j].equals(chaine);  }}
  }
/************************************************/
double moyenne(int imb) 
{
 double r = 0 ;
 for (int i = 0 ; i <= tab[imb] ; i ++)
   r += arguments[imb][i] ;
  
 return (r / (tab[imb] + 1)) ;
}
/***************************************************/
double facto(double i)
{
 
 long r = 1 ;
 for (int j = 1 ; j <= i ; j ++)
  r *= j ;
 return r ;
}
/****************************************************/
double max(int i)
{
 
 double r = -10000 ;
 for (int j = 0 ; j <= tab[i] ; j ++)
  if (r < arguments[i][j])
   r = arguments[i][j] ;
 return r ;
}
/*********************************************************/
double min(int i)
{

 double r = 10000;
 for (int j = 0 ; j <= tab[i] ; j ++)
  if (r > arguments[i][j])
   r = arguments[i][j] ;
 return r ;
}
/****************************************************/
double prode(int i)
{
 
 double r = 1 ;
  for (int j = 0 ; j <= tab[i] ; j ++)
  r *= arguments[i][j] ;  
 return r ;
}
/***************************************************/
double var(int i)
{
 
 double r = 0 ;
 double m ;
 m = moyenne(i) ;
 for (int j = 0 ; j <= tab[i] ; j ++)
  r += (arguments[i][j] - m) * (arguments[i][j] - m) ;

 return (r / (tab[i] + 1)) ;
}
/****************************************************/
double ecarttype(int i)
{
 
 return (Math.sqrt(var(i)));
}
/***************************************************/
	  
	  }
	  PARSER_END(Exc)
/*************************************************************/
TOKEN_MGR_DECLS :
{
public  static int imb=-1;
public static int i=-1;
public static boolean indicateur = false ;

}
/************************************************************/
TOKEN : {                      <plus    :"+">
                              |<moins   :"-">
                              |<mult    :"*"> 
                              |<div     :"/">
                              |<po      :"(">
                              |<pf      :")">
                              |<DeuxP   :":">  {indicateur = true ;}
                              |<virg    :",">
                              |<egal     :"=">
                              |<Egal    :"==">
                              |<Diff    :"<>">
                              |<Inf     :"<"> 
                              |<Sup     :">">
                              |<SupE    :">=">
                              |<InfE    :"<=">
                              |<p       :["P","p"]["I","i"]>
                              |<or      :["O","o"]["R","r"]> 
                              |<and      :["A","a"]["N","n"]["D","d"]>
                              |<si      :["S","s"]["I","i"]>
                              |<Sinu    :["S","s"]["I","i"]["N","n"]>
                              |<Cosi     :["C","c"]["O","o"]["S","s"]>
                              |<Tang    :["T","t"]["A","a"]["N","n"]>
                              |<Abs     :["A","a"]["B","b"]["S","s"]>
                              |<Acos    :["A","a"]["C","c"]["O","o"]["S","s"]>
                              |<Asin    :["A","a"]["S","s"]["I","i"]["N","n"]>
                              |<Atan    :["A","a"]["T","t"]["A","a"]["N","n"]>
                              |<Coshy   :["C","c"]["O","o"]["S","s"]["H","h"]>
                              |<Sinhy   :["S","s"]["I","i"]["N","n"]["H","h"]>
                              |<Tanhy   :["T","t"]["A","a"]["N","n"]["H","h"]>
                              |<Arrondi :["A","a"]["R","r"]["R","r"]["O","o"]["N","n"]["D","d"]["I","i"]>
                              |<Exp     :["E","e"]["X","x"]["P","p"]>
                              |<Ln      :["L","l"]["N","n"]>
                              |<Log     :["L","l"]["O","o"]["G","g"]>
                              |<racine  :["R","r"]["A","a"]["C","c"]["I","i"]["N","n"]["E","e"]>
                              |<puissance:["P","p"]["U","u"]["I","i"]["S","s"]["S","s"]>
                              |<fact     :["F","f"]["A","a"]["C","c"]["T","t"]>
							  |<minimum :["M","m"]["I","i"]["N","n"]> {imb++;}
                              |<maximum  :["M","m"]["A","a"]["X","x"]> {imb++;}
                              |<moy      :["M","m"]["O","o"]["Y","y"]> {imb++;}
                              |<sum      :["S","s"]["O","o"]["M","m"]> {imb++;}
                              |<prod     :["P","p"]["R","r"]["O","o"]["D","d"]> {imb++;}
                              |<Vari     :["V","v"]["A","a"]["R","r"]> {imb++;}
                              |<Ecartype :["E","e"]["C","c"]["A","a"]["R","r"]["T","t"]> {imb++;}
							  |<sous     :["S","s"]["O","o"]["U","u"]["S","s"]> {imb++;}
                              
}
SKIP :                    {" "}						   
TOKEN :                    {<EOL:"\n"|"\r"|"\r\n">}
TOKEN :{ < valeur : (["0"-"9"])+|(["0"-"9"])+ "." (["0"-"9"])+ | (["0"-"9"])+ "." | "." (["0"-"9"])+ > }
TOKEN: {  <id: ["A"-"Z","a"-"z"](["0"-"9"])+ > }
/************************************************************************************/
 Object formul () throws NumberFormatException :
{}
{<egal>
 previousValue =expression() 
 <EOL>
           	 
        	{	return (Object)(previousValue) ;}
        	
}
/*********************************/
double expression():
{
double k,value;
}					   
{
value=t()
  ( <or> k=t() {if ((k != 0) || (value != 0))
                                   value= 1 ;
                                  else 
                                   value= 0 ;
                                 }   )*
		{return value;}
}
/*******************************/
double t():
{ 
double k,value;
}
{
 value=t1()
 ( <and> k=t1()  {  if ((k == 0) || (value == 0))
                                   value = 0 ;
                        else 
                                   value = 1 ;
                      }      )*
     {return value;}								 
}	
/******************************/						   
double t1():
{double k,value;
}

⌨️ 快捷键说明

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