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

📄 testb.java

📁 a Java program that reads a file containing instructions written in self-defined file (TPL in this c
💻 JAVA
字号:
import java.io.*;
import java.util.*;


public class testb
{
	static String fname;
	static String line;
	public static Vector reWord=new Vector();
	public static Vector rest=new Vector();
	
	
	public static void doStuff(String fname)
	{
		int count=0;
		
		
		try{
				BufferedReader inFile=new BufferedReader(new FileReader(fname));
				String nline;	
					
				while((nline=inFile.readLine())!=null&&(nline.equalsIgnoreCase("end"))!=true)	
				{
							    
					StringTokenizer nfile=new StringTokenizer(nline);
					if(nfile.countTokens()>1)
					{
							    									
						int x=nline.indexOf(" ");
						String fStr=nline.substring(0,x);
						reWord.addElement(fStr);
						String sStr=nline.substring((x+1),nline.length());
						rest.addElement(sStr);
					}//end of if
					else
					{
					
						reWord.addElement(nline);
						rest.addElement(" ");
																		
					}//end of else
					
				}//end of while
			}catch(IOException e){
					System.out.println("an error ["+e+"]");
			}//end of catch
			/*for(int n=0;n<reWord.size();n++)
			{
		
				//System.out.println(reWord.elementAt(n)+"888"+rest.elementAt(n));
				String temp=(String)reWord.elementAt(n);
				//System.out.println(rest.elementAt(n));
				//System.out.println(temp);
				if((temp.equals("#"))==true)
					System.out.println(rest.elementAt(n));
				else if((temp.equalsIgnoreCase("integer"))==true)
					
				else if((temp.equalsIgnoreCase("string"))==true)
					
				else if((temp.equalsIgnoreCase("let"))==true)
					let();
				else if(tempt.equalsIgnoreCase("calculate"))==true)
					calculate();
				else if((temp.equalsIgnoreCase("print"))==true)
					System.out.println(rest.elementAt(n));
				else if((temp.equalsIgnoreCase("println"))==true)
				
					System.out.println(rest.elementAt(n));
				else
				
					System.out.print("");
					
				
		}//end of for*/
		System.out.println("TPL Finished ok ["+(count+1)+" lines processed]");
		
	}//end of print
	
	public static void otherStuff()
	{
		System.out.println("no end Statement");
		System.exit(0);
	}
	int interger(String temp)
	{
		
		
	public static void main(String args[])
	{	
		
		boolean x=false;
		boolean y;
		if(args.length>=1)
		
		{	
			try{
					BufferedReader inFile=new BufferedReader(new FileReader(args[0]));
					
					for(int i=0;i<args.length;i++)
						fname=args[i];
					
					while((line=inFile.readLine())!=null)	
					{
					 	
					 	y=line.equalsIgnoreCase("end");
					 	if( y==true)
					 	{
					 		x=y;
					 		doStuff(fname);
					 	}
					 }
					 if(x==false)
					 	otherStuff();
					 
				}catch(IOException e){
					System.out.println("an error ["+e+"]");
				}
		}
	
		
	}
		
				
}

	

⌨️ 快捷键说明

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