资源简介
词法分析器可以对C语言进行词法分析,且用java写的界面

代码片段和文件信息
package bianyi;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.Jframe;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
public class init extends Jframe implements ActionListener
{
private JTextArea input = new JTextArea();
private JScrollPane jsp=new JScrollPane(input);
private JTextArea text=new JTextArea();
private JScrollPane jsp2=new JScrollPane(text);
private JLabel label=new JLabel(“词法分析“);
private JButton button = new JButton(“确定“);
private JButton b2=new JButton(“重置“);
public init()
{
super(“一个测试框框“);
jsp.setBounds(40 100300 500);
jsp2.setBounds(400 100300 500);
label.setBounds(3002020050);
button.setBounds(200 650 100 30);
b2.setBounds(400 650 100 30);
//创建Font对象 使用Serief字体,显示风格为斜体Font.ITALIC,加粗Font.BOLD,字号大小为28
Font fnt = new Font(“Serief“ Font.ITALIC + Font.BOLD 30);
label.setFont(fnt); //设置标签中的字体
this.setLayout(null);
this.setBounds(800 800 800 800);
this.add(jsp);
this.add(jsp2);
this.add(label);
this.add(button);
this.add(b2);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(-1);
}
});
button.addActionListener(this);
b2.addActionListener(this);
this.setVisible(true);
}
private String keyWord[] = {“auto““break““case““char““const““continue“
“default““do““double““else““enum““extern““float““for““goto“
“if““int““long““register““return““short““signed““sizeof““static“
“struct““switch““typedef““union““unsigned““void““volatile““while“};
//判断是否是关键字
boolean isKey(String str)
{
for(int i = 0;i < keyWord.length;i++)
{
if(keyWord[i].equals(str))
return true;
}
return false;
}
//判断是否是字母
boolean isLetter(char letter)
{
if((letter >= ‘a‘ && letter <= ‘z‘)||(letter >= ‘A‘ && letter <= ‘Z‘))
return true;
else
return false;
}
//判断是否是数字
boolean isDigit(char digit)
{
if(digit >= ‘0‘ && digit <= ‘9‘)
return true;
else
return false;
}
private char ch;
void analyze(char[] chars)
{
String arr = ““;
for(int i = 0;i< chars.length;i++) {
ch = chars[i];
arr = ““;
if(ch == ‘ ‘||ch == ‘\t‘||ch == ‘\n‘||ch == ‘\r‘){}
else if(isLetter(ch)){
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 301 2018-11-25 19:04 bianyi\.classpath
文件 382 2018-11-25 19:04 bianyi\.project
文件 598 2018-11-25 19:04 bianyi\.settings\org.eclipse.jdt.core.prefs
文件 620 2018-11-25 22:02 bianyi\bin\bianyi\init$1.class
文件 5658 2018-11-25 22:02 bianyi\bin\bianyi\init.class
文件 6822 2018-11-25 22:02 bianyi\src\bianyi\init.java
- 上一篇:语法分析器java实现
- 下一篇:俄罗斯方块可行性研究报告
相关资源
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Android非常漂亮的登录界面
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
评论
共有 条评论