标签:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.printf("请输入源代码");
String daima = scanner.next();
int i = 0; String c[] = {"begin", "if", "then","while", "do", "end", "id"};
String result="";
String a=daima.substring(0,1);
int s1=0; while ( "#".compareTo(a)!=0)
{ while ( ".".compareTo(a)!=0)
{ if(s1==1)
{ result=""; s1=0; }
result = result+a;
i++;
a=daima.substring(i, i +1);
}
s1=1;
System.out.println(result);
for (int j = 0; j < 6; j++) {
if (result.compareTo(c[j])==0)
{ int k=j+1;
System.out.println("<"+k+","+result+">"); }
i++;
a=daima.substring(i,i+1);}
}
}
标签:
原文地址:http://www.cnblogs.com/zlcan/p/4823282.html