資源簡介
算符優先算法(Java)
比較好的語法分析程序??!

代碼片段和文件信息
package?opg;
public?class?Grammar
{
private?char vn[] =?{‘S‘‘E‘‘T‘‘F‘}; //非終結符
private?char vt[] =?{?‘+‘?‘*‘?‘i‘?‘(‘?‘)‘?‘#‘?}; //終結符
private?String strForm[] =?{?“S→#E#“?“E→E+T“?“E→T“?“T→T*F“?“T→F““F→(E)“?“F→i“};//文法的產生式
???
//判斷一個字符是否是Vt中的字母是返回其在Vt中位置,否則返回-1
public?int?isVt(char?ch)
{
int?temp?=?0i;
for?(i?=?0;?i? {
if?(ch?==?vt[i])
{
temp?=?i;
break;
}
}
if(i>=vt.length)
{
return?-1;
}
else?return?temp;
}
//判斷一個字符是否是Vn中的字母是返回其在Vn中位置,否則返回-1
public?int?isVn(char?ch)
{
int?temp?=?0i;
for?(i?=?0;?i? {
if?(ch?==?vn[i])
{
temp?=?i;
break;
}
}
if(i>=vn.length)
{
return?-1;
}
else?return?temp;
}
//返回終結符的個數
public?int?lengthVt()
{
return?vt.length;
}
//返回非終結符的個數
public?int?lengthVn()
{
return?vn.length;
}
//返回文法產生式
public?String[]?getForm()
{
return?strForm;
}
//返回Vt中第i個字符
public?char?getVt(int?i)
{
char?ch=‘?‘;
????if(i>=0&&i ????{
???? ch=vt[i];
????}
????return?ch;
}
//返回Vn中第i個字符
public?char?getVn(int?i)
{
char?ch=‘?‘;
????if(i>=0&&i ????{
???? ch=vn[i];
????}
????return?ch;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1391??2009-05-05?09:57??opg\Grammar.java
?????文件???????4592??2009-05-05?11:44??opg\OPGAnlyze.java
?????文件???????7272??2009-05-05?10:47??opg\OPGConstruct.java
?????目錄??????????0??2009-05-05?11:36??opg
-----------?---------??----------?-----??----
????????????????13255????????????????????4
- 上一篇:一個帶界面的詞法分析+語法分析語法樹生成
- 下一篇:大學生租房系統項目可行性報告
評論
共有 條評論