91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 66KB
    文件類型: .rar
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-09-06
  • 語言: Java
  • 標(biāo)簽: java??源碼??詞法分析??

資源簡介

使用直接分析法編制C語言子集的詞法分析程序(帶實(shí)驗(yàn)報(bào)告),最近翻出來的以前編譯原理課程做的記法分析程序,有需要的參考一下吧,java實(shí)現(xiàn)

資源截圖

代碼片段和文件信息

import?java.awt.*;
import?java.awt.event.*;
import?java.io.*;
import?java.util.*;
import?javax.swing.*;
import?javax.swing.table.*;

public?class?WordAnalyze?extends?Jframe{
ArrayList?wordList=new?ArrayList();
//char?[]?operators={‘=‘‘+‘‘-‘‘*‘‘/‘‘(‘‘)‘‘{‘‘}‘‘‘‘;‘‘#‘‘[‘‘]‘‘<‘‘>‘‘\“‘‘.‘};
StringBuffer?temp=new?StringBuffer();
String?origin=null;
char?ch=‘?‘;
int?index=0;
Properties?keywords=new?Properties();
Properties?operators=new?Properties();
JToolBar?toolbar=new?JToolBar();
int?strLength=0;


JTextArea?textArea;
DefaultTableModel?tableModel;
JTable?table;
JSplitPane?split;

WordAnalyze() {
super(“--簡易C語言詞法分析器--“);
setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
int?xy;
Dimension?size=Toolkit.getDefaultToolkit().getScreenSize();
x=(size.width-400)/2;
y=(size.height-400)/2;
setSize(450400);
setLocation(xy);
textArea=new?JTextArea();
textArea.setForeground(Color.BLUE);
textArea.setLineWrap(true);
String?[]?columnNames={“單詞““編碼““屬性“};
tableModel=new?DefaultTableModel();
table=new?JTable(tableModel);
table.setForeground(Color.BLUE);
tableModel.addColumn(“單詞“);
tableModel.addColumn(“編碼“);
tableModel.addColumn(“說明“);
split=new?JSplitPane(JSplitPane.HORIZONTAL_SPLITnew?JScrollPane(textArea)new?JScrollPane(table));
toolbar.add(new?analyze(“analyze“new?ImageIcon(“images\\analyze.gif“)));
toolbar.add(new?quit(“quit“new?ImageIcon(“images\\quit.gif“)));
getContentPane().add(toolbarBorderLayout.NORTH);
getContentPane().add(split);
split.setDividerLocation(210);
split.setResizeWeight(1);
}

class?analyze?extends?AbstractAction?{?
public?analyze(String?text?Icon?icon)?{?
super(text?icon);?
}?
public?void?actionPerformed(ActionEvent?e)?{
origin=textArea.getText();
tableModel.setRowCount(0);
strLength=origin.length();
wordList.clear();
loadKeywordAndOperator();
if(analyze())
showResault();

}?
}

class?quit?extends?AbstractAction?{?
public?quit(String?text?Icon?icon){?
super(text?icon);?
}?
public?void?actionPerformed(ActionEvent?e)?{?
System.exit(0);
}?
}

void?showResault()?{
//textArea.setText(Arrays.toString(wordList.toArray()));
object?[]?wordArr=wordList.toArray();
String?row[]=new?String?[3];
String?code=null;
for(int?i=0;i row[0]=(String)wordArr[i];
if((code=keywords.getProperty(row[0]))!=null){
row[1]=code;
row[2]=“關(guān)鍵字“;
}
else?if((code=operators.getProperty(row[0]))!=null){
row[1]=code;
row[2]=“運(yùn)算符/界符“;
}
else?if(row[0].charAt(0)>47&&row[0].charAt(0)<58){
row[1]=“0“;
row[2]=“常數(shù)“;
}
else?{
row[1]=“1“;
row[2]=“標(biāo)識(shí)符“;
}
tableModel.addRow(row);
}

}

void?loadKeywordAndOperator() {
try?{
keywords.load(new?FileInputStream(new?File(“keywords.properties“)));
o

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件?????134656??2007-04-15?15:37??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\使用直接分析法編制C語言子集的詞法分析程序.doc

?????文件???????1104??2007-04-13?16:46??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\images\analyze.gif

?????文件???????1116??2007-04-13?16:46??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\images\quit.gif

????..A.SH.??????4608??2007-04-13?16:53??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\images\Thumbs.db

?????文件????????295??2007-04-14?16:33??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\keywords.properties

?????文件????????210??2007-04-14?17:04??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\operators.properties

?????文件???????1180??2007-04-15?22:17??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\WordAnalyze$analyze.class

?????文件????????560??2007-04-15?22:17??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\WordAnalyze$quit.class

?????文件???????5963??2007-04-15?22:17??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\WordAnalyze.class

?????文件???????4740??2007-04-15?22:17??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\WordAnalyze.java

?????目錄??????????0??2007-04-13?16:53??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序\images

?????目錄??????????0??2007-04-15?15:32??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序\源程序

?????目錄??????????0??2007-06-30?16:55??實(shí)驗(yàn)一:使用直接分析法編制C語言子集的詞法分析程序

-----------?---------??----------?-----??----

???????????????154432????????????????????13


評(píng)論

共有 條評(píng)論

相關(guān)資源