資源簡介
1、項目開發工具為MyEclipse2014
2、使用了Struts2框架作為控制層
3、HTML5圖形用戶界面
4、JAVA語言寫后端
該項目完成的功能有:自動消去規則左遞歸;自動計算出First、Follow集;自動構造預測分析表;可輸入句子進行判斷。
代碼我都寫了注釋,由于項目后期完成的比較急促,所以代碼冗余度比較大,還沒有時間進行精簡。
如果不需要網頁的圖形用戶界面,可將項目中的算法部分單獨取出,也可直接運行得到結果。算法部分位于項目中的MyClass包中。

代碼片段和文件信息
package?MyAction;
import?java.io.FileWriter;
import?java.util.ArrayList;
import?java.util.List;
import?java.util.Map;
import?MyClass.BeginTest;
import?MyClass.BeginTest_if_then;
import?MyClass.YuceTable;
import?com.opensymphony.xwork2.ActionContext;
import?com.opensymphony.xwork2.ActionSupport;
public?class?myAction?extends?ActionSupport?{
private?String?NT[];
private?String?T[];
private?String?yucebiao[][];
private?String?noLeftG[];??//沒有左遞歸的文法G
private?String?first[];
private?String?follow[];
private?String?myG;
private?String?myTest;
private?boolean?result;
private?String?match[][];
private?int?matchLen;
private?String?G[];
private?String?path_filename;
private?String?chooseWF;
public?String?execute()?throws?Exception{
Map?session=ActionContext.getContext().getSession();?
int?count?=?0;
for?(?int?i?=?0;?i? if?(?this.myG.charAt(i)?==?‘@‘){
count++;
}
}
System.out.println(count+“個@“);
this.G?=?new?String[?count?];
int?beginIndex?=?0;
int?endIndex?=?0;
int?i;
for?(?i?=?0;?i? endIndex?=?this.myG.indexOf(“@“??beginIndex);
if?(?endIndex?!=?-1?){
this.G[i]?=?this.myG.substring(beginIndex?endIndex);
beginIndex?=?endIndex?+?1;
}
}
// System.out.println(this.myTest);
// System.out.println(this.myG);
int?choose?=?Integer.parseInt(this.chooseWF);
if?(?choose?==?1?){
BeginTest?beginTest?=?new?BeginTest(this.G);
this.first?=?beginTest.getFirst();
this.follow?=?beginTest.getFollow();
this.NT?=?beginTest.getNT();
this.T?=?beginTest.getT();
this.noLeftG?=?beginTest.getNoLeftG();
this.yucebiao?=?beginTest.getYucebiao();
}else{
BeginTest_if_then?beginTest?=?new?BeginTest_if_then(this.G);
this.first?=?beginTest.getFirst();
this.follow?=?beginTest.getFollow();
this.NT?=?beginTest.getNT();
this.T?=?beginTest.getT();
this.noLeftG?=?beginTest.getNoLeftG();
this.yucebiao?=?beginTest.getYucebiao();
}
List?list1?=?new?ArrayList();
list1.add(first);
list1.add(follow);
list1.add(NT);
list1.add(T);
list1.add(noLeftG);
list1.add(G);
List?list2?=?new?ArrayList();
list2.add(yucebiao);
session.put(“list1“?list1);
session.put(“list2“?list2);
return?SUCCESS;
}
public?String?beginTest()?throws?Exception{
Map?session=ActionContext.getContext().getSession();?
int?count?=?0;
for?(?int?i?=?0;?i? if?(?this.myG.charAt(i)?==?‘@‘){
count++;
}
}
System.out.println(count+“個@“);
this.G?=?new?String[?count?];
int?beginIndex?=?0;
int?endIndex?=?0;
int?i;
for?(?i?=?0;?i? endIndex?=?this.myG.indexOf(“@“??beginIndex);
if?(?endIndex?!=?-1?){
this.G[i]?=?this.myG.substring(beginIndex?endIndex);
beginIndex?=?endIndex?+?1;
}
}
// Sy
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1092??2018-05-31?16:26??BYYLkcsj\.classpath
?????文件???????1333??2018-05-31?17:17??BYYLkcsj\.project
?????文件????????522??2018-05-31?16:04??BYYLkcsj\.settings\.jsdtscope
?????文件????????164??2018-05-31?16:26??BYYLkcsj\.settings\com.genuitec.runtime.libraries.xm
?????文件????????364??2018-05-31?16:04??BYYLkcsj\.settings\org.eclipse.jdt.core.prefs
?????文件????????483??2018-05-31?16:04??BYYLkcsj\.settings\org.eclipse.wst.common.component
?????文件????????464??2018-05-31?16:26??BYYLkcsj\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2018-05-31?16:04??BYYLkcsj\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2018-05-31?16:04??BYYLkcsj\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件???????7520??2018-06-16?10:34??BYYLkcsj\src\MyAction\myAction.java
?????文件???????5800??2018-06-15?15:06??BYYLkcsj\src\MyClass\BeginTest.java
?????文件???????7983??2018-06-16?01:36??BYYLkcsj\src\MyClass\BeginTest_if_then.java
?????文件????????769??2018-05-31?16:23??BYYLkcsj\src\MyClass\Model.java
?????文件??????17178??2018-06-15?09:41??BYYLkcsj\src\MyClass\YuceTable.java
?????文件??????21526??2018-06-16?01:12??BYYLkcsj\src\MyClass\YuceTable_if_then.java
?????文件????????724??2018-06-03?10:29??BYYLkcsj\src\struts.xm
?????文件???????3652??2018-06-16?00:11??BYYLkcsj\WebRoot\leftBar.jsp
?????文件???????1263??2018-06-16?00:09??BYYLkcsj\WebRoot\Main.jsp
?????文件?????????39??2018-05-31?16:04??BYYLkcsj\WebRoot\me
?????文件????????548??2018-06-03?09:56??BYYLkcsj\WebRoot\rightShow.html
?????文件???????2472??2018-06-02?10:45??BYYLkcsj\WebRoot\testResult_error.jsp
?????文件???????5178??2018-06-03?00:28??BYYLkcsj\WebRoot\testResult_success.jsp
?????文件???????6964??2018-06-19?12:23??BYYLkcsj\WebRoot\WEB-INF\classes\MyAction\myAction.class
?????文件???????6810??2018-06-19?12:23??BYYLkcsj\WebRoot\WEB-INF\classes\MyClass\BeginTest.class
?????文件???????8298??2018-06-19?12:23??BYYLkcsj\WebRoot\WEB-INF\classes\MyClass\BeginTest_if_then.class
?????文件???????1323??2018-06-19?12:23??BYYLkcsj\WebRoot\WEB-INF\classes\MyClass\Model.class
?????文件??????12590??2018-06-19?12:23??BYYLkcsj\WebRoot\WEB-INF\classes\MyClass\YuceTable.class
?????文件??????13393??2018-06-19?12:23??BYYLkcsj\WebRoot\WEB-INF\classes\MyClass\YuceTable_if_then.class
?????文件????????724??2018-06-03?10:29??BYYLkcsj\WebRoot\WEB-INF\classes\struts.xm
?????文件????????710??2018-05-31?17:08??BYYLkcsj\WebRoot\WEB-INF\web.xm
............此處省略16個文件信息
- 上一篇:超市收銀系統純java代碼實現
- 下一篇:Android-eclipse俄羅斯方塊
評論
共有 條評論