• 大小: 13KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-07-24
  • 语言: 其他
  • 标签:

资源简介

编译原理课程设计——实现简单的四则元算,包括词法分析、语法分析、语义分析

资源截图

代码片段和文件信息

package com.panhanchun.simpleParser;
/**
 * @author 潘汉春
 * @note Demonstrate the Parser
 * @date 15/01/2007
 * 
 */
import javax.swing.*;

import java.awt.*;              //for layout managers and more
import java.awt.event.*;        //for action events

@SuppressWarnings(“serial“)
public class Demo extends JPanel
                             implements ActionListener {
    protected static final String textFieldString = “算术表达式“;
    protected static final String buttonString = “JButton“;

    protected JLabel actionLabel;
    protected JTextArea textArea0;
    protected JTextArea textArea1;

    public Demo() {
        setLayout(new BorderLayout());
       
        //Create a regular text field.
        JTextField textField = new JTextField(25);
        textField.setActionCommand(textFieldString);
        textField.addActionListener(this);

        //Create some labels for the fields.
        JLabel textFieldLabel = new JLabel(textFieldString + “: “);
        textFieldLabel.setLabelFor(textField);
     
        //Create a label to put messages during an action event.
        actionLabel = new JLabel(“运行结果“);
        actionLabel.setBorder(BorderFactory.createEmptyBorder(25000));

        //Lay out the text controls and the labels.
        JPanel textControlsPane = new JPanel();
        GridBagLayout gridbag = new GridBagLayout();

        textControlsPane.setLayout(gridbag);

        JLabel[] labels = {textFieldLabel};
        JTextField[] textFields = {textField};
        addLabelTextRows(labels textFields gridbag textControlsPane);
        
        textControlsPane.setBorder(
                BorderFactory.createCompoundBorder(
                                BorderFactory.createtitledBorder(“输入“)
                                BorderFactory.createEmptyBorder(5555)));
        
        //Create a text area.
        textArea0 = new JTextArea(““);
        JScrollPane areaScrollPane0 = new JScrollPane(textArea0);
        areaScrollPane0.setVerticalScrollBarPolicy(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        areaScrollPane0.setPreferredSize(new Dimension(250 250));
        areaScrollPane0.setBorder(
            BorderFactory.createCompoundBorder(
                BorderFactory.createCompoundBorder(
                                BorderFactory.createtitledBorder(“词法分析“)
                                BorderFactory.createEmptyBorder(5555))
                areaScrollPane0.getBorder()));
        
        //Create a text area.
        textArea1 = new JTextArea(““);
        JScrollPane areaScrollPane1 = new JScrollPane(textArea1);
        areaScrollPane1.setVerticalScrollBarPolicy(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        areaScrollPane1.setPreferredSize(new Dimension(250 150));
        areaScrollPane1.setBorder(
            BorderFactory.createCompoundBorder(
                BorderFactory.createCompoundBor

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        301  2009-08-07 21:49  simpleParser\.classpath

     文件        388  2009-08-07 21:49  simpleParser\.project

     文件        629  2009-08-07 21:49  simpleParser\.settings\org.eclipse.jdt.core.prefs

     文件        552  2009-09-01 11:12  simpleParser\bin\com\panhanchun\simpleParser\Demo$1.class

     文件       5693  2009-09-01 11:12  simpleParser\bin\com\panhanchun\simpleParser\Demo.class

     文件       5076  2009-09-01 11:12  simpleParser\bin\com\panhanchun\simpleParser\Parser.class

     文件        516  2009-09-01 11:12  simpleParser\bin\com\panhanchun\simpleParser\ParserException.class

     文件       6866  2009-08-07 22:02  simpleParser\src\com\panhanchun\simpleParser\Demo.java

     文件       7527  2009-08-07 21:51  simpleParser\src\com\panhanchun\simpleParser\Parser.java

     目录          0  2009-09-01 11:12  simpleParser\bin\com\panhanchun\simpleParser

     目录          0  2009-08-07 21:50  simpleParser\src\com\panhanchun\simpleParser

     目录          0  2009-09-01 11:12  simpleParser\bin\com\panhanchun

     目录          0  2009-08-07 21:50  simpleParser\src\com\panhanchun

     目录          0  2009-09-01 11:12  simpleParser\bin\com

     目录          0  2009-08-07 21:50  simpleParser\src\com

     目录          0  2009-08-07 21:49  simpleParser\.settings

     目录          0  2009-09-01 11:12  simpleParser\bin

     目录          0  2009-08-07 21:50  simpleParser\src

     目录          0  2009-08-07 21:49  simpleParser

----------- ---------  ---------- -----  ----

                27548                    19


评论

共有 条评论

相关资源