/*
* LL1.java
*
* Created on __DATE__, __TIME__
*/
package view;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JLabel;
import java.awt.Font;
public class LL1 extends javax.swing.JFrame {
Statement sta;//
Connection conn;//
ResultSet rs;//
DefaultTableModel dtm;//
String Vn[] = null;//
Vector<String> P = null;//
int firstComplete[] = null;
// 把已判断过first的数据储存
char first[][] = null;
// 存储最终first
int followComplete[] = null;
// 把已判断过follow的数据储存
char follow[][] = null;
// 存储最终follow
char select[][] = null;
// 存储最终select
int LL = 0;
// 标记是否为LL(1)文法
String vt_tou[] = null;
// 储存Vt
Object shuju[][] = null;
// 存储表达式数据
char yn_null[] = null;
// 存储能否推出空
/** Creates new form LL1 */
public LL1() {
initComponents();
setLocationRelativeTo(null);
this.setSize(900, 650);
}
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea2 = new javax.swing.JTextArea();
jTextArea2.setEditable(false);
jButton1 = new javax.swing.JButton();
jScrollPane3 = new javax.swing.JScrollPane();
jScrollPane4 = new javax.swing.JScrollPane();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jScrollPane5 = new javax.swing.JScrollPane();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jScrollPane2.setViewportView(jTextArea2);
jButton1.setText("\u6c42First\u96c6");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
//first集
}
});
jButton2.setText("\u6c42Follow\u96c6");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
//follow集
}
});
jButton3.setText("\u6784\u9020\u9884\u6d4b\u5206\u6790\u8868");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
//预测分析表
}
});
jButton4.setText("\u9009\u62e9\u6587\u4ef6");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
//选择文件
}
});
lblNewLabel = new JLabel("\u5206\u6790\u7ED3\u679C:");
lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 16));
GroupLayout groupLayout = new GroupLayout(getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(150)
.addComponent(jButton1)
.addGap(400)
.addComponent(jButton2))
.addGroup(groupLayout.createSequentialGroup()
.addGap(72)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 292, GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4)
.addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 314, GroupLayout.PREFERRED_SIZE))
.addGap(49)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(jScrollPane5, GroupLayout.PREFERRED_SIZE, 411, GroupLayout.PREFERRED_SIZE)
.addGroup(groupLayout.createSequentialGroup()
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jScrollPane4, GroupLayout.PREFERRED_SIZE, 370, GroupLayout.PREFERRED_SIZE))
.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)))
.addGroup(groupLayout.createSequentialGroup()
.addGap(94)
.addComponent(jButton3)
.addGap(18)
.addComponent(jScrollPane3, GroupLayout.PREFERRED_SIZE, 517, GroupLayout.PREFERRED_SIZE)))
.addContainerGap(694, Short.MAX_VALUE))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(10)
.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 155, GroupLayout.PREFERRED_SIZE)
.addGap(6)
.addComponent(jButton4))
.addGroup(groupLayout.createSequentialGroup()
.addGap(9)
.addComponent(lblNewLabel)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jScrollPane5, GroupLayout.PREFERRED_SIZE, 101, GroupLayout.PREFERRED_SIZE)))
.addGap(6)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 154, GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane4, GroupLayout.PREFERRED_SIZE, 151, GroupLayout.PREFERRED_SIZE))
.addGap(50)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(52)
.addComponent(jScrollPane3, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createSequentialGroup()
.addGap(96)
.addComponent(jButton3)))
.addContainerGap(267, Short.MAX_VALUE))
);
jTextArea4 = new javax.swing.JTextArea();
jScrollPane5.setViewportView(jTextArea4);
jTextArea4.setEditable(false);
jTextArea4.setColumns(20);
jTextArea4.setFont(new java.awt.Font("Monospaced", 0, 36));
jTextArea4.setRows(5);
jTextArea3 = new javax.swing.JTextArea();
jTextArea3.setEditable(false);
jScrollPane4.setViewportView(jTextArea3);
jTextArea3.setColumns(20);
jTextArea3.setRows(5);
jTable1 = new javax.swing.JTable();
jScrollPane3.setViewportView(jTable1);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object[][] { { null, null, null, null },
{ null, null, null, null }, { null, null, null, null },
{ null, null, null, null } }, new String[] { "Title 1",
"Title 2", "Title 3", "Title 4" }));
getContentPane().setLayout(groupLayout);
pack();
}
//添加文件
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jTextArea1.setText("");
JFileChooser jFileChooser = new JFileChooser();
FileFilter fileFilter = new FileNameExtensionFilter("txt", "txt");
jFileChooser.setFileFilter(fileFilter);
if (jFileChooser.APPROVE_OPTION == jFileChooser.showOpenDialog(this)) {
File file = jFileChooser.getSelectedFile();
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
} catch (FileNotFoundExc