编译原理课程设计---用java写的SNLCompiler(简单嵌套语言SNL的编译程序)

来源:互联网 发布:长春网络营销策划 编辑:程序博客网 时间:2024/06/16 20:56

SNLCompiler界面截图

SNLCompiler词法分析截图

SNLCompiler界面截图

SNLCompiler的语法分析截图

简介:

SNLCompiler是一个针对教学语言SNL(Simple Nest Language,其语法与pascal类似)的编译程序,
SNLCompiler具有单步执行的功能,可以单独执行词法分析,语法分析等,并显示执行后得到的每一步的详细结果,现在仅提供了词法分析、语法分析中的递归下降法、LL(1)分析方法。SNLCompiler具有良好的结构,使用java语言编写,充分体现面向对象的优点,使用了大量的面向对象的设计模式(Composite、visitor、builder、facade、Simple Factory、Command的模式),具有良好的扩展性。
其中:
Composite模式(各个结点类):把结点来形成语法树.把基本的结点组合成复杂的接点,并最终形成语法树
visitor模式(SNLPrinter类):访问并打印语法树(也可以用在类型检查以及目标代码生成),把对结点的操作从结点类中分离,使结点增加一个操作变的容易
builder模式(ProgramNodeBuilder类):将复杂的语法树构建过程,细化到构建每一个结点并把这个过程隐藏,提供了插拔的构建方式
facade模式(CompilerFacade类):把Compiler各个子系统进行封装,给客户端一个简洁的界面。
Simple Factory模式(ActionFactory类):提供了一个数字与一个Action对象的简单映射,并且将这些无状态的Action对象进行缓寸,使得这些对象可以共享.
Command模式(所有Action类):把对一条文法的处理动作封装为一个对象,使用ActionFactory的高效的映射,避免了冗长的switch语句,并提高了性能。

代码部分(由于最近很忙注释不够详尽,特别是后面部分):

package edu.jlu.fuliang.cifa;

import java.io.*;
import java.util.*;

import javax.swing.JTextArea;
import edu.jlu.fuliang.Error;
import edu.jlu.fuliang.ErrorList;
import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.ReservedWord;


/*
 * 词法分析的主要的功能类,提供了单词扫描,并产生Token序列
 * 以及在扫描中及时地发现并处理错误等功能
 */
public class Scanner {
 private static final int EOF = -1;

 private BufferedReader reader;
 
 private PrintWriter out;

 private ArrayList<Token> tokenList;

 private JTextArea outputArea;

 private int lineNum, linePos;

 private String lineBuf = "";

 private ErrorList errorList;

 private ReservedWord[] reservedWord = new ReservedWord[] {
   new ReservedWord("program", LexType.PROGRAM),
   new ReservedWord("type", LexType.TYPE),
   new ReservedWord("var", LexType.VAR),
   new ReservedWord("procedure", LexType.PROCEDURE),
   new ReservedWord("begin", LexType.BEGIN),
   new ReservedWord("end", LexType.END),
   new ReservedWord("array", LexType.ARRAY),
   new ReservedWord("of", LexType.OF),
   new ReservedWord("record", LexType.RECORD),
   new ReservedWord("if", LexType.IF),
   new ReservedWord("then", LexType.THEN),
   new ReservedWord("else", LexType.ELSE),
   new ReservedWord("fi", LexType.FI),
   new ReservedWord("while", LexType.WHILE),
   new ReservedWord("do", LexType.DO),
   new ReservedWord("endwh", LexType.ENDWH),
   new ReservedWord("read", LexType.READ),
   new ReservedWord("write", LexType.WRITE),
   new ReservedWord("return", LexType.RETURN),
   new ReservedWord("integer", LexType.INTEGER),
   new ReservedWord("char", LexType.CHAR) };

 /*
  * 使用InputStream,和JTextArea类型作为参数,主要用作想在JTextArea中输出 词法分析的结果以及错误信息的Scanner实例
  */
 public Scanner(InputStream inputStream, JTextArea outputArea) {
  this(inputStream);
  this.outputArea = outputArea;
 }

 /*
  * 在控制台输出词法分析的 结果以及错误信息的Scanner实例
  */
 public Scanner(InputStream inputStream) {
  out = new PrintWriter(System.out, true);
  reader = new BufferedReader(new InputStreamReader(inputStream));
  tokenList = new ArrayList<Token>();
  errorList = new ErrorList();

  try {
   lineBuf = reader.readLine();
  } catch (IOException e) {
   e.printStackTrace();
  }
  lineBuf += '/n';
  lineNum = 1;
  linePos = 0;
 }
 /*
  * 使用OutputStream作为参数可以在文件或在控制台输出词法分析的 结果以及错误信息的Scanner实例
  */
 public Scanner(InputStream inputStream,OutputStream outputStream) {
  
     this.out = new PrintWriter(outputStream,true);
  reader = new BufferedReader(new InputStreamReader(inputStream));
  tokenList = new ArrayList<Token>();
  errorList = new ErrorList();
       
  try {
   lineBuf = reader.readLine();
  } catch (IOException e) {
   e.printStackTrace();
  }
  lineBuf += '/n';
  lineNum = 1;
  linePos = 0;
 }
 /*
  * 读取下一个单词
  */
 protected int getNextChar() {
  if (lineBuf == null)
   return EOF;
  if (linePos >= lineBuf.length()) {
   try {
    lineBuf = reader.readLine();
    if (lineBuf == null)
     return EOF;
    else {
     lineBuf += '/n';
     linePos = 0;
     lineNum++;
    }
   } catch (IOException e) {
    e.printStackTrace();
   }
  }
  return lineBuf.charAt(linePos++);
 }

 /*
  * 回退一个单词
  */
 protected void unGetNextChar() {
  linePos--;
 }

 /*
  * 查询一个标识符是否为保留字类,如果是则返回类型该保留字的 类型,否则返回ID类型
  */
 protected int reservedLookup(String reserved) {
  for (int i = 0; i < reservedWord.length; i++) {
   if (reservedWord[i].getName().equals(reserved))
    return reservedWord[i].getLexType();
  }
  return LexType.ID;
 }
 /*
  * 扫描函数,形成一个token
  */
 protected Token scan() {
   Token curToken = new Token();
   StringBuffer buf = new StringBuffer("");
   processStartState(curToken, buf);
   curToken.setSem(buf.toString());
   if (curToken.getLex() == LexType.ID)
    curToken.setLex(reservedLookup(curToken.getSem()));
   curToken.setLineNum(lineNum);
   return curToken;
  }
 /*
  * 处理开始状态,根据读入的第一个字母决定下一个要处理的状态
  */
 private void processStartState(Token curToken, StringBuffer buf) {
  int c = getNextChar();

  if (Character.isDigit(c)) {
   buf.append((char) c);
   processNumState(curToken, buf);
  } else if (Character.isLetter(c)) {
   buf.append((char) c);
   processIDState(curToken, buf);
  } else if (c == ':') {
   buf.append((char) c);
   processAssignState(curToken, buf);
  } else if (c == '.') {
   buf.append((char) c);
   processRangeState(curToken, buf);
  } else if (c == '/'') {
   buf.append((char) c);
   processCharState(curToken, buf);
  } else if (c == '{')
   processCommentState(curToken, buf);
  else if (c == ' ' || c == '/t' || c == '/n') {
   processStartState(curToken,buf);
  } else {
   switch (c) {
   case EOF:
    curToken.setLex(LexType.ENDFILE);
    buf.append((char) c);
    break;
   case '=':
    curToken.setLex(LexType.EQ);
    buf.append((char) c);
    break;
   case '<':
    curToken.setLex(LexType.LT);
    buf.append((char) c);
    break;
   case '>':
    curToken.setLex(LexType.GT);
    buf.append((char) c);
    break;
   case '+':
    curToken.setLex(LexType.PLUS);
    buf.append((char) c);
    break;
   case '-':
    curToken.setLex(LexType.MINUS);
    buf.append((char) c);
    break;
   case '*':
    curToken.setLex(LexType.TIMES);
    buf.append((char) c);
    break;
   case '/':
    curToken.setLex(LexType.OVER);
    buf.append((char) c);
    break;
   case '(':
    curToken.setLex(LexType.LPAREN);
    buf.append((char) c);
    break;
   case ')':
    curToken.setLex(LexType.RPAREN);
    buf.append((char) c);
    break;
   case ';':
    curToken.setLex(LexType.SEMI);
    buf.append((char) c);
    break;
   case ',':
    curToken.setLex(LexType.COMMA);
    buf.append((char) c);
    break;
   case '[':
    curToken.setLex(LexType.LMIDPAREN);
    buf.append((char) c);
    break;
   case ']':
    curToken.setLex(LexType.RMIDPAREN);
    buf.append((char) c);
    break;
   default:
    curToken.setLex(LexType.ERROR);
    errorList.addError(new Error("Unexpected charactor: "
      + (char) c, lineNum));
    break;
   }
  }
 }
/*
 * 处理并识别赋值:=单词
 */
 protected void processAssignState(Token curToken, StringBuffer buf) {
  int c = getNextChar();
  if (c == '=') {
   curToken.setLex(LexType.ASSIGN);
   buf.append((char) c);
  } else {
   curToken.setLex(LexType.ERROR);
   errorList.addError(new Error("Unexpected charactor: " + (char) c,
     lineNum));
   unGetNextChar();
  }
 }
 /*
  * 处理并识别注释{...}单词
  */
 protected void processCommentState(Token curToken, StringBuffer buf) {
  int c = getNextChar();
  while (c != '}')
   c = getNextChar();
  processStartState(curToken, buf);
 }
 /*
  * 处理并识别数组下标中(子介)..单词
  */
 protected void processRangeState(Token curToken, StringBuffer buf) {
  int c = getNextChar();
  if (c == '.') {
   curToken.setLex(LexType.UNDERANGE);
   buf.append((char) c);
  } else {
   curToken.setLex(LexType.DOT);
   unGetNextChar();
  }
 }
/*
 * 处理并识别单个字符
 */
 protected void processCharState(Token curToken, StringBuffer buf) {
  int c = getNextChar();
  if (Character.isLetterOrDigit(c)) {

   int c1 = getNextChar();
   if (c1 == '/'') {
    curToken.setLex(LexType.CHARC);
    buf.append((char) c);
    buf.append((char) c1);
   } else {
    unGetNextChar();
    unGetNextChar();
    curToken.setLex(LexType.ERROR);
    errorList.addError(new Error("Unexpect charactor: " + (char) c,
      lineNum));
   }
  } else {
   unGetNextChar();
   curToken.setLex(LexType.ERROR);
   errorList.addError(new Error("Unexpected charactor: " + (char) c,
     lineNum));
  }
 }
 /*
  * 处理并识别标识符ID单词
  */
 protected void processIDState(Token curToken, StringBuffer buf) {
  int c = getNextChar();
  while (Character.isLetterOrDigit(c)) {
   buf.append((char) c);
   c = getNextChar();
  }
  unGetNextChar();
  curToken.setLex(LexType.ID);
 }
 /*
  * 处理并识别数字num单词
  */
 public void processNumState(Token curToken, StringBuffer buf) {
  int c = getNextChar();
  if (Character.isDigit(c)) {
   buf.append((char) c);
   c = getNextChar();
  }
  unGetNextChar();
  curToken.setLex(LexType.INTC);
 }
 /*
  * 获取下一个Token
  */
 public Token getNextToken() {
  return scan();
 }

 /*
  * 产生词法分析的Token序列
  */
 public void genTokenList() {
  Token token = scan();
  while (token.getLex() != LexType.ENDFILE) {
   tokenList.add(token);
   token = scan();
  }
  tokenList.add(token);
 }

 /*
  * 获取词法分析的token序列
  */
 public ArrayList<Token> getTokenList() {
  return tokenList;
 }

 /*
  * 在控制台上打印错误信息
  */
 public void printErrorInfoOnConsole() {
  genTokenList();
  int errorNum = errorList.getErrorNum();
  out.println("词法分析有:" + errorNum + " 个错误:");
  errorList.printErrors();
 }

 /*
  * 在JTextArea中打印错误信息
  */
 public void printErrorInfo() {
  genTokenList();
  int errorNum = errorList.getErrorNum();
  outputArea.append("词法分析有:" + errorNum + " 个错误:/n");
  ArrayList<Error> errors = errorList.getErrors();
  for (int i = 0; i < errorNum; i++) {
   outputArea.append("Error " + (i + 1) + " in line "
     + (errors.get(i).getLineNum()) + ": "
     + errors.get(i).getErrorInfo() + " ;/n");
  }
 }

 /*
  * 在控制台中打印Token序列
  */
 public void printTokenListOnConsole() {
  for (int i = 0; i < tokenList.size(); i++) {
   out.print(tokenList.get(i).getLineNum() + ": ");
   switch (tokenList.get(i).getLex()) {
   case LexType.ASSIGN:
   case LexType.EQ:
   case LexType.LT:
   case LexType.GT:
   case LexType.PLUS:
   case LexType.MINUS:
   case LexType.TIMES:
   case LexType.OVER:
   case LexType.LPAREN:
   case LexType.RPAREN:
   case LexType.DOT:
   case LexType.COMMA:
   case LexType.SEMI:
   case LexType.LMIDPAREN:
   case LexType.RMIDPAREN:
   case LexType.UNDERANGE:
    out.println(tokenList.get(i).getSem());
    break;
   case LexType.ID:
    out.println("ID, name = " + tokenList.get(i).getSem());
    break;
   case LexType.INTC:
    out.println("INTC, value = " + tokenList.get(i).getSem());
    break;
   case LexType.ENDFILE:
    out.println("EOF");
    break;
   case LexType.ERROR:
    out.println("EORR: " + tokenList.get(i).getSem());
    break;
   default:
    out.println("Resered word: " + tokenList.get(i).getSem());
    break;
   }
  }
 }

 /*
  * 在JTextArea中打印token序列
  */
 public void printTokenList() {
  for (int i = 0; i < tokenList.size(); i++) {
   outputArea.append(tokenList.get(i).getLineNum() + ": ");
   switch (tokenList.get(i).getLex()) {
   case LexType.ASSIGN:
   case LexType.EQ:
   case LexType.LT:
   case LexType.GT:
   case LexType.PLUS:
   case LexType.MINUS:
   case LexType.TIMES:
   case LexType.OVER:
   case LexType.LPAREN:
   case LexType.RPAREN:
   case LexType.DOT:
   case LexType.COMMA:
   case LexType.SEMI:
   case LexType.LMIDPAREN:
   case LexType.RMIDPAREN:
   case LexType.UNDERANGE:
    outputArea.append(tokenList.get(i).getSem() + "/n");
    break;
   case LexType.ID:
    outputArea.append("ID, name = " + tokenList.get(i).getSem()
      + "/n");
    break;
   case LexType.INTC:
    outputArea.append("INTC, value = " + tokenList.get(i).getSem()
      + "/n");
    break;
   case LexType.ENDFILE:
    outputArea.append("EOF/n");
    break;
   case LexType.ERROR:
    outputArea.append("EORR: " + tokenList.get(i).getSem() + "/n");
    break;
   default:
    outputArea.append("Resered word: " + tokenList.get(i).getSem()
      + "/n");
    break;
   }
  }
 }
}
package edu.jlu.fuliang.cifa;

/*
 * Token类,定义了该Token所在的行标,类型以及单词信息
 */
public class Token {
 
 private int lineNum;
 private int lex;
 private String sem;

 /*
  * 默认构造函数
  */
 public Token() {
  sem = "";
 }

 /*
  * 获取类型信息
  */
 public int getLex() {
  return lex;
 }

 /*
  * 设置类型信息
  */
 public void setLex(int lex) {
  this.lex = lex;
 }

 /*
  * 获取token所在的行标
  */
 public int getLineNum() {
  return lineNum;
 }

 /*
  * 设置Token所在的行标
  */
 public void setLineNum(int lineNum) {
  this.lineNum = lineNum;
 }

 /*
  * 获取Token的单词信息
  */
 public String getSem() {
  return sem;
 }

 /*
  * 设置Token的单词信息
  */
 public void setSem(String sem) {
  this.sem = sem;
 }
}

package edu.jlu.fuliang;

import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
import javax.swing.tree.*;
import javax.swing.*;

import edu.jlu.fuliang.cifa.Scanner;
import edu.jlu.fuliang.yufa.LL1.ParseLL;
import edu.jlu.fuliang.yufa.Recursion.Parser;
import edu.jlu.fuliang.yufa.Recursion.Program;
import edu.jlu.fuliang.yufa.Recursion.ProgramNodeBuilder;
import edu.jlu.fuliang.yufa.Recursion.SNLPrinter;

import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;

class Compiler extends JFrame {
 private JTextArea outputArea;

 private JDesktopPane desktop;

 private JTree tree;

 private DefaultMutableTreeNode root;

 private DefaultTreeModel model;

 private String filename = "";

 private int nextFrameX;

 private int nextFrameY;

 private int frameDistance;

 private Scanner scanner;

 static final int WIDTH = 600;

 static final int HEIGHT = 400;

 public Compiler() {
  outputArea = new JTextArea(10, 70);
  outputArea.setEditable(false);
  root = new DefaultMutableTreeNode("Workspace");

  tree = new JTree(root);
  model = new DefaultTreeModel(root);
  desktop = new JDesktopPane();

  JSplitPane innerPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
    tree, desktop);
  innerPane.setContinuousLayout(true);
  innerPane.setOneTouchExpandable(true);

  JSplitPane outerPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
    innerPane, new JScrollPane(outputArea));

  outerPane.setContinuousLayout(true);
  outerPane.setOneTouchExpandable(true);

  Container container = getContentPane();
  container.setLayout(new GridLayout(1, 1));
  container.add(outerPane);

  JMenuBar menuBar = new JMenuBar();
  setJMenuBar(menuBar);
  JMenu fileMenu = new JMenu("文件");
  menuBar.add(fileMenu);
  JMenuItem openItem = new JMenuItem("打开");
  openItem.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent event) {
    openFile();
   }
  });
  fileMenu.add(openItem);
  JMenuItem exitItem = new JMenuItem("退出");
  exitItem.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent event) {
    System.exit(0);
   }
  });
  
  fileMenu.add(exitItem);
  JMenu windowMenu = new JMenu("窗口");
  menuBar.add(windowMenu);
  JMenuItem nextItem = new JMenuItem("下一个");
  nextItem.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent event) {
    selectNextWindow();
   }
  });
  windowMenu.add(nextItem);
  JMenuItem cascadeItem = new JMenuItem("层叠");
  cascadeItem.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent event) {
    cascadeWindows();
   }
  });
  
  windowMenu.add(cascadeItem);
  JMenuItem tileItem = new JMenuItem("平铺");
  tileItem.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent event) {
    tileWindows();
   }
  });
  
  windowMenu.add(tileItem);
  final JCheckBoxMenuItem dragOutlineItem = new JCheckBoxMenuItem(
    "Drag Outline");
  dragOutlineItem.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent event) {
    desktop.setDragMode(dragOutlineItem.isSelected() ? JDesktopPane.OUTLINE_DRAG_MODE
        : JDesktopPane.LIVE_DRAG_MODE);
   }
  });
  
  windowMenu.add(dragOutlineItem);

  JMenu compilerMenu1 = new JMenu("单步执行");
  JMenuItem lexAnalzyMenuItem = new JMenuItem("词法分析");
  JMenu synAnalyzeMenu = new JMenu("语法分析");
  JMenuItem RDSynAnalyzeMenuItem = new JMenuItem("递归下降");
  JMenuItem LL1SynAnalyzeMenuItem = new JMenuItem("LL1分析法");
  
  compilerMenu1.add(lexAnalzyMenuItem);
  compilerMenu1.add(synAnalyzeMenu);
  
  synAnalyzeMenu.add(RDSynAnalyzeMenuItem);
  synAnalyzeMenu.add(LL1SynAnalyzeMenuItem);
  menuBar.add(compilerMenu1);

  lexAnalzyMenuItem.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent event) {
    outputArea.setText("");
    try {
     FileInputStream fis = new FileInputStream(filename);
     scanner = new Scanner(fis, outputArea);
    } catch (FileNotFoundException e1) {
     e1.printStackTrace();
    }
    scanner.printErrorInfo();
    scanner.printTokenList();
   }
  });
  
  RDSynAnalyzeMenuItem.addActionListener(new ActionListener() {

   public void actionPerformed(ActionEvent e) {
    outputArea.setText("");
    try {
     SNLPrinter printer = new SNLPrinter(new FileOutputStream(
       "result.txt"),new Spacing(7));

     FileInputStream fis = new FileInputStream(filename);
     scanner = new Scanner(fis, outputArea);
     ProgramNodeBuilder builder = new ProgramNodeBuilder();
     Parser parser = new Parser(scanner, builder,
       new FileOutputStream("error.txt"));
     
     Program p = (Program) builder.getTreeRoot();
     if (parser.isNoErrors()) {
      parser.PrintErrors();
      printer.visitProgram(p);
     } else {
      parser.PrintErrors();
     }
     BufferedReader br1 = new BufferedReader(
       new InputStreamReader(new FileInputStream(
         "error.txt")));
     BufferedReader br2 = new BufferedReader(
       new InputStreamReader(new FileInputStream(
         "result.txt")));
     String buf = null;
     while ((buf = br1.readLine()) != null) {
      outputArea.append(buf + "/n");
     }
     while ((buf = br2.readLine()) != null) {
      outputArea.append(buf + "/n");
     }
                    br1.close();
                    br2.close();
    } catch (IOException ex) {
     ex.printStackTrace();
    }
   }
  });
  
  LL1SynAnalyzeMenuItem.addActionListener(new ActionListener() {
   
   public void actionPerformed(ActionEvent e) {
    outputArea.setText("");
    try {
     SNLPrinter printer = new SNLPrinter(new FileOutputStream(
       "result.txt"),new Spacing(7));
     FileInputStream fis = new FileInputStream(filename);
     scanner = new Scanner(fis, outputArea);
     ParseLL parser = new ParseLL(scanner);
     Program p = (Program) parser.ParseProcess();
     if (parser.isNoErrors()) {
      printer.visitProgram(p);
     } else {
      parser.PrintErrors();
     }
     BufferedReader br = new BufferedReader(
       new InputStreamReader(new FileInputStream(
         "result.txt")));
     String buf = null;
     while ((buf = br.readLine()) != null) {
      outputArea.append(buf + "/n");
     }

    } catch (IOException ex) {
     ex.printStackTrace();
    }

   }
  });
  
  setSize(800, 600);
  setVisible(true);
 }

 public void createInternalFrame(Component c, String t) {
  final JInternalFrame iframe = new JInternalFrame(t, true, true, true);

  iframe.getContentPane().add(c);
  desktop.add(iframe);

  iframe.setFrameIcon(new ImageIcon("document.gif"));

  iframe.addVetoableChangeListener(new VetoableChangeListener() {
   public void vetoableChange(PropertyChangeEvent event)
     throws PropertyVetoException {
    String name = event.getPropertyName();
    Object value = event.getNewValue();

    if (name.equals("closed") && value.equals(Boolean.TRUE)) {
     int result = JOptionPane.showInternalConfirmDialog(iframe,
       "OK to close?");

     if (result != JOptionPane.YES_OPTION)
      throw new PropertyVetoException("User canceled close",
        event);
    }
   }
  });

  int width = desktop.getWidth() / 2;
  int height = desktop.getHeight() / 2;
  iframe.reshape(nextFrameX, nextFrameY, width, height);

  iframe.show();

  try {
   iframe.setSelected(true);
  } catch (PropertyVetoException e) {
  }

  if (frameDistance == 0)
   frameDistance = iframe.getHeight();
  iframe.getContentPane().getHeight();

  nextFrameX += frameDistance;
  nextFrameY += frameDistance;
  if (nextFrameX + width > desktop.getWidth())
   nextFrameX = 0;
  if (nextFrameY + height > desktop.getHeight())
   nextFrameY = 0;
 }

 public void cascadeWindows() {
  JInternalFrame[] frames = desktop.getAllFrames();
  int x = 0;
  int y = 0;

  int width = desktop.getWidth() / 2;
  int height = desktop.getHeight() / 2;

  for (int i = 0; i < frames.length; i++) {
   if (!frames[i].isIcon()) {
    try {
     frames[i].setMaximum(false);
     frames[i].reshape(x, y, width, height);

     x += frameDistance;
     y += frameDistance;

     if (x + width > desktop.getWidth())
      x = 0;
     if (y + height > desktop.getHeight())
      y = 0;
    } catch (PropertyVetoException e) {
    }
   }
  }
 }

 public void tileWindows() {
  JInternalFrame[] frames = desktop.getAllFrames();

  int frameCount = 0;
  for (int i = 0; i < frames.length; i++) {
   if (!frames[i].isIcon())
    frameCount++;
  }

  int rows = (int) Math.sqrt(frameCount);
  int cols = frameCount / rows;
  int extra = frameCount % rows;

  int width = desktop.getWidth() / cols;
  int height = desktop.getHeight() / rows;
  int r = 0;
  int c = 0;
  for (int i = 0; i < frames.length; i++) {
   if (!frames[i].isIcon()) {
    try {
     frames[i].setMaximum(false);
     frames[i].reshape(c * width, r * height, width, height);
     r++;
     if (r == rows) {
      r = 0;
      c++;
      if (c == cols - extra) {

       rows++;
       height = desktop.getHeight() / rows;
      }
     }
    } catch (PropertyVetoException e) {

    }
   }
  }
 }

 public void selectNextWindow() {
  JInternalFrame[] frames = desktop.getAllFrames();
  for (int i = 0; i < frames.length; i++) {
   if (frames[i].isSelected()) {

    try {
     int next = (i + 1) % frames.length;
     while (next != i && frames[next].isIcon())
      next = (next + 1) % frames.length;
     if (next == i)
      return;
     frames[next].setSelected(true);
     frames[next].toFront();
     return;
    } catch (PropertyVetoException e) {
    }
   }
  }
 }

 public void openFile() {

  JFileChooser chooser = new JFileChooser();
  chooser.setCurrentDirectory(new File("."));
  chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
   public boolean accept(File f) {
    String fname = f.getName().toLowerCase();
    return fname.endsWith(".txt") || fname.endsWith(".txt")
      || f.isDirectory();
   }

   public String getDescription() {
    return "Text Files";
   }
  });
  int r = chooser.showOpenDialog(this);

  if (r == JFileChooser.APPROVE_OPTION) {
   filename = chooser.getSelectedFile().getPath();
   StringTokenizer token = new StringTokenizer(filename, "//");
   ArrayList<DefaultMutableTreeNode> files = new ArrayList<DefaultMutableTreeNode>();
   int i = 1;
   files.add(root);
   while (token.hasMoreTokens()) {
    files.add(new DefaultMutableTreeNode(token.nextElement()));
    i++;
    model.insertNodeInto(files.get(i - 1), files.get(i - 2), 0);
   }
   try {
    URL fileUrl = new URL("file:" + filename);
    createInternalFrame(createEditorPane(fileUrl), filename);

   } catch (MalformedURLException e) {
   }
  }
 }

 public Component createEditorPane(URL u) {

  JEditorPane editorPane = new JEditorPane();
  editorPane.setEditable(false);
  editorPane.addHyperlinkListener(new HyperlinkListener() {
   public void hyperlinkUpdate(HyperlinkEvent event) {
    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
     createInternalFrame(createEditorPane(event.getURL()), event
       .getURL().toString());
   }
  });
  try {
   editorPane.setPage(u);
  } catch (IOException e) {
   editorPane.setText("Exception: " + e);
  }
  return new JScrollPane(editorPane);
 }

 public static void main(String[] args) {
  Compiler compiler = new Compiler();
  compiler.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
}

package edu.jlu.fuliang;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;

import edu.jlu.fuliang.cifa.Scanner;
import edu.jlu.fuliang.yufa.Recursion.*;

public class CompilerFacade {
 private Scanner scanner;
 private Parser parser;
 
 public CompilerFacade(){
  
 }
 
 public void LexAnalyze(String fileName){
  try {
   FileInputStream fis = new FileInputStream(fileName);
      scanner = new Scanner(fis);
      scanner.printErrorInfo();
   scanner.printTokenList();
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  }
 }
 
 public void recursiveSynAnalyze(String fileName){
  SNLPrinter printer;
  try {
   printer = new SNLPrinter(new FileOutputStream(
   "result.txt"),new Spacing(7));
  
  if(scanner == null){
           FileInputStream fis = new FileInputStream(fileName);
           scanner = new Scanner(fis);
  }
          ProgramNodeBuilder builder = new ProgramNodeBuilder();
          Parser parser = new Parser(scanner, builder,
           new FileOutputStream("error.txt"));
          Program p = (Program) builder.getTreeRoot();
          if (parser.isNoErrors()) {
           parser.PrintErrors();
           printer.visitProgram(p);
         }   
          else {
       parser.PrintErrors();
           }
         BufferedReader br1 = new BufferedReader(
         new InputStreamReader(new FileInputStream(
     "error.txt")));
        BufferedReader br2 = new BufferedReader(
         new InputStreamReader(new FileInputStream(
     "result.txt")));
   } catch (FileNotFoundException e) {
   e.printStackTrace();
   }
 }
}

package edu.jlu.fuliang;

/*
 * Error类定义了整个SNLCompiler中错误的显示信息
 * 以及出现错误所在的行,便于错误的统一管理。
 */
public class Error {
 private String errorInfo;

 private int lineNum;

 /*
  * 使用一个类型为String表示信息,一个int表示出现错误的行来 创建一个错误实例
  */
 public Error(String errorInfo, int lineNum) {
  this.errorInfo = errorInfo;
  this.lineNum = lineNum;
 }

 /*
  * 获取错误的信息
  */
 public String getErrorInfo() {
  return errorInfo;
 }

 /*
  * 获取错误出现的行标
  */
 public int getLineNum() {
  return lineNum;
 }
}
package edu.jlu.fuliang;

import java.util.ArrayList;

/*
 * ErrorList主要是保存SNLCompiler在各个过程中出现的错误
 * 可能会带了一定的内存开销,在实用的编译器中并不可取,但在教
 * 学类的SNLCompiler,使用这个类主要是为错误的统一处理,以
 * 及错误信息的打印提供了方便,因为他将各个过程中出现的错误的
 * 打印工作分离开了,便于在不同方式下打印的移植(例如既像在控制
 * 台打印,又想在文本域内显示,或者二者之间的移植)
 */
public class ErrorList {
 private ArrayList<Error> errorList;

 /*
  * 默认的构造函数
  */
 public ErrorList() {
  errorList = new ArrayList<Error>();
 }

 /*
  * 向错误列表中添加错误信息
  */
 public void addError(Error err) {
  errorList.add(err);
 }

 /*
  * 获取错误列表
  */
 public ArrayList<Error> getErrors() {
  return errorList;
 }

 public void clearError() {
  errorList.clear();
 }

 /*
  * 打印错误信息
  */
 public void printErrors() {
  for (int i = 0; i < errorList.size(); i++) {
   System.out.println("Error " + (i + 1) + " in line "
     + (errorList.get(i).getLineNum()) + ": "
     + errorList.get(i).getErrorInfo() + " ;");
  }
 }

 /*
  * 获取错误的数目
  */
 public int getErrorNum() {
  return errorList.size();
 }

}
package edu.jlu.fuliang;

/*
 * 定义了Token的各种类型常量
 */
public class LexType {
 public final static int ENDFILE = -1;

 public final static int ERROR = -2;

 public final static int PROGRAM = -3;

 public final static int PROCEDURE = -4;

 public final static int TYPE = -5;

 public final static int VAR = -6;

 public final static int IF = -7;

 public final static int THEN = -8;

 public final static int ELSE = -9;

 public final static int FI = -10;

 public final static int DO = -11;

 public final static int WHILE = -12;

 public final static int ENDWH = -13;

 public final static int BEGIN = -14;

 public final static int END = -15;

 public final static int READ = -16;

 public final static int WRITE = -17;

 public final static int ARRAY = -18;

 public final static int OF = -19;

 public final static int RECORD = -20;

 public final static int RETURN = -21;

 public final static int INTEGER = -22;

 public final static int CHAR = -23;

 public final static int ID = -24;

 public final static int INTC = -25;

 public final static int CHARC = -26;

 public final static int ASSIGN = -27;

 public final static int EQ = -28;

 public final static int LT = -29;

 public final static int GT = -30;

 public final static int PLUS = -31;

 public final static int MINUS = -32;

 public final static int TIMES = -33;

 public final static int OVER = -34;

 public final static int LPAREN = -35;

 public final static int RPAREN = -36;

 public final static int DOT = -37;

 public final static int COLON = -38;

 public final static int SEMI = -39;

 public final static int COMMA = -40;

 public final static int LMIDPAREN = -41;

 public final static int RMIDPAREN = -42;

 public final static int UNDERANGE = -43;
}
package edu.jlu.fuliang;

/*
 * 保留字类,为保留字单独设置一个类,包含了自身的类型,
 * 和名字
 */
public class ReservedWord {
 private int lexType;

 private String name;

 public ReservedWord(String name, int lexType) {
  this.lexType = lexType;
  this.name = name;
 }

 /*
  * 获取类型信息
  */
 public int getLexType() {
  return lexType;
 }

 /*
  * 设置类型信息
  */
 public void setLexType(int lex) {
  this.lexType = lex;
 }

 /*
  * 获取保留字的名字
  */
 public String getName() {
  return name;
 }

 /*
  * 设置保留字的名字
  */
 public void setName(String name) {
  this.name = name;
 }
}

package edu.jlu.fuliang;

public class Spacing {
 public final int INDENT_AMT;// 缩进的字数

 public String spc = " ";
    public String brunch = "|---->";
 public int indentLevel;// 缩紧的层次

 public Spacing(int indentAmount) {
  INDENT_AMT = indentAmount;
 }

 public String toString() {
  return spc;
 }

 public void updateSpc(int numIndentLvls) {
   if(spc.length() >= brunch.length())
   spc = spc.substring(0,spc.length()-brunch.length());
  
     indentLevel += numIndentLvls;
  if (numIndentLvls < 0){
   spc = spc.substring(0,indentLevel * INDENT_AMT);
      spc += brunch;
  }
  else if (numIndentLvls > 0) {
   StringBuffer buf = new StringBuffer(spc);
   for (int i = 0; i < numIndentLvls * INDENT_AMT; ++i)
    buf.append(" ");
   buf.append(brunch);
   spc = buf.toString();
  }
 }
}

package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.*;

public interface Action {
 public abstract void execute(Stack<Integer> signStack,
   Stack<Node> synTreeStack);

}
package edu.jlu.fuliang.yufa.LL1;

public class ActionFactory {
 //用来保存Action无状态的对象(无数据成员),并提供数与
 //Action对象的映射,不会造成内存开销,同时对象可以共享
 
 public Action[] actionsCache = new Action[] {
   null, new Process1Action(),
   new Process2Action(), new Process3Action(),
   new Process4Action(), new Process5Action(),
   new Process6Action(),new Process7Action(),
   new Process8Action(), new Process9Action(),
   new Process10Action(), new Process11Action(),
   new Process12Action(), new Process13Action(),
   new Process14Action(), new Process15Action(),
   new Process16Action(), new Process17Action(),
   new Process18Action(), new Process19Action(),
   new Process20Action(), new Process21Action(),
   new Process22Action(), new Process23Action(),
   new Process24Action(), new Process25Action(),
   new Process26Action(), new Process27Action(),
   new Process28Action(), new Process29Action(),
   new Process30Action(), new Process31Action(),
   new Process32Action(), new Process33Action(),
   new Process34Action(), new Process35Action(),
   new Process36Action(),
   new Process37Action(), new Process38Action(),
   new Process39Action(), new Process40Action(),
   new Process41Action(), new Process42Action(),
   new Process43Action(), new Process44Action(),
   new Process45Action(), new Process46Action(),
   new Process47Action(), new Process48Action(),
   new Process49Action(), new Process50Action(),
   new Process51Action(), new Process52Action(),
   new Process53Action(), new Process54Action(),
   new Process55Action(), new Process56Action(),
   new Process57Action(), new Process58Action(),
   new Process59Action(), new Process60Action(),
   new Process61Action(), new Process62Action(),
   new Process63Action(), new Process64Action(),
   new Process65Action(), new Process66Action(),
   new Process67Action(), new Process68Action(),
   new Process69Action(), new Process70Action(),
   new Process71Action(), new Process72Action(),
   new Process73Action(), new Process74Action(),
   new Process75Action(), new Process76Action(),
   new Process77Action(), new Process78Action(),
   new Process79Action(), new Process80Action(),
   new Process81Action(), new Process82Action(),
   new Process83Action(), new Process84Action(),
   new Process85Action(), new Process86Action(),
   new Process87Action(), new Process88Action(),
   new Process89Action(), new Process90Action(),
   new Process91Action(), new Process92Action(),
   new Process93Action(), new Process94Action(),
   new Process95Action(), new Process96Action(),
   new Process97Action(), new Process98Action(),
   new Process99Action(), new Process100Action(),
   new Process101Action(), new Process102Action(),
   new Process103Action(), new Process104Action()
   };

 public Action createActionInstance(int i) {
  return actionsCache[i];
 }
}
package edu.jlu.fuliang.yufa.LL1;

public class NontmlType {
 public final static int Program = 1;

 public final static int ProgramHead = 2;

 public final static int ProgramName = 3;

 public final static int DeclarePart = 4;

 public final static int TypeDec = 5;

 public final static int TypeDeclaration = 6;

 public final static int TypeDecMore = 7;

 public final static int TypeDecList = 8;

 public final static int staticTypeDecMore = 9;

 public final static int TypeId = 10;

 public final static int TypeName = 11;

 public final static int BaseType = 12;

 public final static int StructureType = 13;

 public final static int ArrayType = 14;

 public final static int Low = 15;

 public final static int Top = 16;

 public final static int RecType = 17;

 public final static int FieldDecList = 18;

 public final static int FieldDecMore = 19;

 public final static int IdList = 20;

 public final static int IdMore = 21;

 public final static int VarDec = 22;

 public final static int VarDeclaration = 23;

 public final static int VarDecList = 24;

 public final static int VarDecMore = 25;

 public final static int VarIdList = 26;

 public final static int VarIdMore = 27;

 public final static int ProcDec = 28;

 public final static int ProcDeclaration = 29;

 public final static int ProcDecMore = 30;

 public final static int ProcName = 31;

 public final static int ParamList = 32;

 public final static int ParamDecList = 33;

 public final static int ParamMore = 34;

 public final static int Param = 35;

 public final static int FormList = 36;

 public final static int FidMore = 37;

 public final static int ProcDecPart = 38;

 public final static int ProcBody = 39;

 public final static int ProgramBody = 40;

 public final static int StmList = 41;

 public final static int StmMore = 42;

 public final static int Stm = 43;

 public final static int AssCall = 44;

 public final static int AssignmentRest = 45;

 public final static int ConditionalStm = 46;

 public final static int StmL = 47;

 public final static int LoopStm = 48;

 public final static int InputStm = 49;

 public final static int InVar = 50;

 public final static int OutputStm = 51;

 public final static int ReturnStm = 52;

 public final static int CallStmRest = 53;

 public final static int ActParamList = 54;

 public final static int ActParamMore = 55;

 public final static int RelExp = 56;

 public final static int OtherRelE = 57;

 public final static int Exp = 58;

 public final static int OtherTerm = 59;

 public final static int Term = 60;

 public final static int OtherFactor = 61;

 public final static int Factor = 62;

 public final static int Variable = 63;

 public final static int VariMore = 64;

 public final static int FieldVar = 65;

 public final static int FieldVarMore = 66;

 public final static int CmpOp = 67;

 public final static int AddOp = 68;

 public final static int MultOp = 69;
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.Error;
import edu.jlu.fuliang.ErrorList;
import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.cifa.Scanner;
import edu.jlu.fuliang.cifa.Token;
import edu.jlu.fuliang.yufa.Recursion.*;

public class ParseLL {
 private int LL1Table[][] = new int[106][45];

 private Scanner scanner;

 private Stack<Integer> signStack;

 private Stack<Node> synTreeStack;

 private ErrorList errorList;

 public ParseLL(Scanner scanner) {
  for (int i = 0; i < 106; i++)
   for (int j = 0; j < 42; j++) {
    LL1Table[i][j] = 0;
   }
  this.scanner = scanner;
  signStack = new Stack<Integer>();
  synTreeStack = new Stack<Node>();
  errorList = new ErrorList();
  createLL1Table();
 }
 
 public void PrintErrors() {
  int errorNum = errorList.getErrorNum();
  System.out.println("语法分析有:" + errorNum + " 个错误:");
  errorList.printErrors();
 }
 
    public boolean isNoErrors(){
     return errorList.getErrorNum() == 0 ? true : false ;
    }
   
 protected void createLL1Table() {
  LL1Table[NontmlType.Program][-LexType.PROGRAM] = 1;

  LL1Table[NontmlType.ProgramHead][-LexType.PROGRAM] = 2;

  LL1Table[NontmlType.ProgramName][-LexType.ID] = 3;

  LL1Table[NontmlType.DeclarePart][-LexType.TYPE] = 4;
  LL1Table[NontmlType.DeclarePart][-LexType.VAR] = 4;
  LL1Table[NontmlType.DeclarePart][-LexType.PROCEDURE] = 4;
  LL1Table[NontmlType.DeclarePart][-LexType.BEGIN] = 4;

  LL1Table[NontmlType.TypeDec][-LexType.VAR] = 5;
  LL1Table[NontmlType.TypeDec][-LexType.PROCEDURE] = 5;
  LL1Table[NontmlType.TypeDec][-LexType.BEGIN] = 5;

  LL1Table[NontmlType.TypeDec][-LexType.TYPE] = 6;

  LL1Table[NontmlType.TypeDeclaration][-LexType.TYPE] = 7;

  LL1Table[NontmlType.TypeDecList][-LexType.ID] = 8;

  LL1Table[NontmlType.TypeDecMore][-LexType.VAR] = 9;
  LL1Table[NontmlType.TypeDecMore][-LexType.PROCEDURE] = 9;
  LL1Table[NontmlType.TypeDecMore][-LexType.BEGIN] = 9;

  LL1Table[NontmlType.TypeDecMore][-LexType.ID] = 10;

  LL1Table[NontmlType.TypeId][-LexType.ID] = 11;

  LL1Table[NontmlType.TypeName][-LexType.INTEGER] = 12;
  LL1Table[NontmlType.TypeName][-LexType.CHAR] = 12;

  LL1Table[NontmlType.TypeName][-LexType.ARRAY] = 13;
  LL1Table[NontmlType.TypeName][-LexType.RECORD] = 13;

  LL1Table[NontmlType.TypeName][-LexType.ID] = 14;

  LL1Table[NontmlType.BaseType][-LexType.INTEGER] = 15;

  LL1Table[NontmlType.BaseType][-LexType.CHAR] = 16;

  LL1Table[NontmlType.StructureType][-LexType.ARRAY] = 17;

  LL1Table[NontmlType.StructureType][-LexType.RECORD] = 18;

  LL1Table[NontmlType.ArrayType][-LexType.ARRAY] = 19;

  LL1Table[NontmlType.Low][-LexType.INTC] = 20;

  LL1Table[NontmlType.Top][-LexType.INTC] = 21;

  LL1Table[NontmlType.RecType][-LexType.RECORD] = 22;

  LL1Table[NontmlType.FieldDecList][-LexType.INTEGER] = 23;
  LL1Table[NontmlType.FieldDecList][-LexType.CHAR] = 23;

  LL1Table[NontmlType.FieldDecList][-LexType.ARRAY] = 24;

  LL1Table[NontmlType.FieldDecMore][-LexType.END] = 25;

  LL1Table[NontmlType.FieldDecMore][-LexType.INTEGER] = 26;
  LL1Table[NontmlType.FieldDecMore][-LexType.CHAR] = 26;
  LL1Table[NontmlType.FieldDecMore][-LexType.ARRAY] = 26;

  LL1Table[NontmlType.IdList][-LexType.ID] = 27;

  LL1Table[NontmlType.IdMore][-LexType.SEMI] = 28;

  LL1Table[NontmlType.IdMore][-LexType.COMMA] = 29;

  LL1Table[NontmlType.VarDec][-LexType.PROCEDURE] = 30;
  LL1Table[NontmlType.VarDec][-LexType.BEGIN] = 30;

  LL1Table[NontmlType.VarDec][-LexType.VAR] = 31;

  LL1Table[NontmlType.VarDeclaration][-LexType.VAR] = 32;

  LL1Table[NontmlType.VarDecList][-LexType.INTEGER] = 33;
  LL1Table[NontmlType.VarDecList][-LexType.CHAR] = 33;
  LL1Table[NontmlType.VarDecList][-LexType.ARRAY] = 33;
  LL1Table[NontmlType.VarDecList][-LexType.RECORD] = 33;
  LL1Table[NontmlType.VarDecList][-LexType.ID] = 33;

  LL1Table[NontmlType.VarDecMore][-LexType.PROCEDURE] = 34;
  LL1Table[NontmlType.VarDecMore][-LexType.BEGIN] = 34;

  LL1Table[NontmlType.VarDecMore][-LexType.INTEGER] = 35;
  LL1Table[NontmlType.VarDecMore][-LexType.CHAR] = 35;
  LL1Table[NontmlType.VarDecMore][-LexType.ARRAY] = 35;
  LL1Table[NontmlType.VarDecMore][-LexType.RECORD] = 35;
  LL1Table[NontmlType.VarDecMore][-LexType.ID] = 35;

  LL1Table[NontmlType.VarIdList][-LexType.ID] = 36;

  LL1Table[NontmlType.VarIdMore][-LexType.SEMI] = 37;

  LL1Table[NontmlType.VarIdMore][-LexType.COMMA] = 38;

  LL1Table[NontmlType.ProcDec][-LexType.BEGIN] = 39;

  LL1Table[NontmlType.ProcDec][-LexType.PROCEDURE] = 40;

  LL1Table[NontmlType.ProcDeclaration][-LexType.PROCEDURE] = 41;

  LL1Table[NontmlType.ProcDecMore][-LexType.BEGIN] = 42;

  LL1Table[NontmlType.ProcDecMore][-LexType.PROCEDURE] = 43;

  LL1Table[NontmlType.ProcDecMore][-LexType.DOT] = 42;
  
  LL1Table[NontmlType.ProcName][-LexType.ID] = 44;

  LL1Table[NontmlType.ParamList][-LexType.RPAREN] = 45;

  LL1Table[NontmlType.ParamList][-LexType.INTEGER] = 46;
  LL1Table[NontmlType.ParamList][-LexType.CHAR] = 46;
  LL1Table[NontmlType.ParamList][-LexType.ARRAY] = 46;
  LL1Table[NontmlType.ParamList][-LexType.RECORD] = 46;
  LL1Table[NontmlType.ParamList][-LexType.ID] = 46;
  LL1Table[NontmlType.ParamList][-LexType.VAR] = 46;

  LL1Table[NontmlType.ParamDecList][-LexType.INTEGER] = 47;
  LL1Table[NontmlType.ParamDecList][-LexType.CHAR] = 47;
  LL1Table[NontmlType.ParamDecList][-LexType.ARRAY] = 47;
  LL1Table[NontmlType.ParamDecList][-LexType.RECORD] = 47;
  LL1Table[NontmlType.ParamDecList][-LexType.ID] = 47;
  LL1Table[NontmlType.ParamDecList][-LexType.VAR] = 47;

  LL1Table[NontmlType.ParamMore][-LexType.RPAREN] = 48;

  LL1Table[NontmlType.ParamMore][-LexType.SEMI] = 49;

  LL1Table[NontmlType.Param][-LexType.INTEGER] = 50;
  LL1Table[NontmlType.Param][-LexType.CHAR] = 50;
  LL1Table[NontmlType.Param][-LexType.ARRAY] = 50;
  LL1Table[NontmlType.Param][-LexType.RECORD] = 50;
  LL1Table[NontmlType.Param][-LexType.ID] = 50;

  LL1Table[NontmlType.Param][-LexType.VAR] = 51;

  LL1Table[NontmlType.FormList][-LexType.ID] = 52;

  LL1Table[NontmlType.FidMore][-LexType.SEMI] = 53;
  LL1Table[NontmlType.FidMore][-LexType.RPAREN] = 53;

  LL1Table[NontmlType.FidMore][-LexType.COMMA] = 54;

  LL1Table[NontmlType.ProcDecPart][-LexType.TYPE] = 55;
  LL1Table[NontmlType.ProcDecPart][-LexType.VAR] = 55;
  LL1Table[NontmlType.ProcDecPart][-LexType.PROCEDURE] = 55;
  LL1Table[NontmlType.ProcDecPart][-LexType.BEGIN] = 55;

  LL1Table[NontmlType.ProcBody][-LexType.BEGIN] = 56;

  LL1Table[NontmlType.ProgramBody][-LexType.BEGIN] = 57;

  LL1Table[NontmlType.StmList][-LexType.ID] = 58;
  LL1Table[NontmlType.StmList][-LexType.IF] = 58;
  LL1Table[NontmlType.StmList][-LexType.WHILE] = 58;
  LL1Table[NontmlType.StmList][-LexType.RETURN] = 58;
  LL1Table[NontmlType.StmList][-LexType.READ] = 58;
  LL1Table[NontmlType.StmList][-LexType.WRITE] = 58;

  LL1Table[NontmlType.StmMore][-LexType.END] = 59;
  LL1Table[NontmlType.StmMore][-LexType.ENDWH] = 59;
  LL1Table[NontmlType.StmMore][-LexType.ELSE] = 59;
  LL1Table[NontmlType.StmMore][-LexType.FI] = 59;

  LL1Table[NontmlType.StmMore][-LexType.SEMI] = 60;

  LL1Table[NontmlType.Stm][-LexType.IF] = 61;

  LL1Table[NontmlType.Stm][-LexType.WHILE] = 62;

  LL1Table[NontmlType.Stm][-LexType.READ] = 63;

  LL1Table[NontmlType.Stm][-LexType.WRITE] = 64;

  LL1Table[NontmlType.Stm][-LexType.RETURN] = 65;

  LL1Table[NontmlType.Stm][-LexType.ID] = 66;

  LL1Table[NontmlType.AssCall][-LexType.ASSIGN] = 67;
  LL1Table[NontmlType.AssCall][-LexType.LMIDPAREN] = 67;
  LL1Table[NontmlType.AssCall][-LexType.DOT] = 67;

  LL1Table[NontmlType.AssCall][-LexType.LPAREN] = 68;

  LL1Table[NontmlType.AssignmentRest][-LexType.ASSIGN] = 69;
  LL1Table[NontmlType.AssignmentRest][-LexType.LMIDPAREN] = 69;
  LL1Table[NontmlType.AssignmentRest][-LexType.DOT] = 69;

  LL1Table[NontmlType.ConditionalStm][-LexType.IF] = 70;

  LL1Table[NontmlType.LoopStm][-LexType.WHILE] = 71;

  LL1Table[NontmlType.InputStm][-LexType.READ] = 72;

  LL1Table[NontmlType.InVar][-LexType.ID] = 73;

  LL1Table[NontmlType.OutputStm][-LexType.WRITE] = 74;

  LL1Table[NontmlType.ReturnStm][-LexType.RETURN] = 75;

  LL1Table[NontmlType.CallStmRest][-LexType.LPAREN] = 76;

  LL1Table[NontmlType.ActParamList][-LexType.RPAREN] = 77;

  LL1Table[NontmlType.ActParamList][-LexType.ID] = 78;
  LL1Table[NontmlType.ActParamList][-LexType.INTC] = 78;
  LL1Table[NontmlType.ActParamList][-LexType.LPAREN] = 78;

  LL1Table[NontmlType.ActParamMore][-LexType.RPAREN] = 79;

  LL1Table[NontmlType.ActParamMore][-LexType.COMMA] = 80;

  LL1Table[NontmlType.RelExp][-LexType.LPAREN] = 81;
  LL1Table[NontmlType.RelExp][-LexType.INTC] = 81;
  LL1Table[NontmlType.RelExp][-LexType.ID] = 81;

  LL1Table[NontmlType.OtherRelE][-LexType.LT] = 82;
  LL1Table[NontmlType.OtherRelE][-LexType.EQ] = 82;

  LL1Table[NontmlType.Exp][-LexType.LPAREN] = 83;
  LL1Table[NontmlType.Exp][-LexType.INTC] = 83;
  LL1Table[NontmlType.Exp][-LexType.ID] = 83;

  LL1Table[NontmlType.OtherTerm][-LexType.LT] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.EQ] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.THEN] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.DO] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.RPAREN] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.END] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.SEMI] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.COMMA] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.ENDWH] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.ELSE] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.FI] = 84;
  LL1Table[NontmlType.OtherTerm][-LexType.RMIDPAREN] = 84;

  LL1Table[NontmlType.OtherTerm][-LexType.PLUS] = 85;
  LL1Table[NontmlType.OtherTerm][-LexType.MINUS] = 85;

  LL1Table[NontmlType.Term][-LexType.LPAREN] = 86;
  LL1Table[NontmlType.Term][-LexType.INTC] = 86;
  LL1Table[NontmlType.Term][-LexType.ID] = 86;

  LL1Table[NontmlType.OtherFactor][-LexType.PLUS] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.MINUS] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.LT] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.EQ] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.THEN] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.ELSE] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.FI] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.DO] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.ENDWH] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.RPAREN] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.END] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.SEMI] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.COMMA] = 87;
  LL1Table[NontmlType.OtherFactor][-LexType.RMIDPAREN] = 87;

  LL1Table[NontmlType.OtherFactor][-LexType.TIMES] = 88;
  LL1Table[NontmlType.OtherFactor][-LexType.OVER] = 88;

  LL1Table[NontmlType.Factor][-LexType.LPAREN] = 89;

  LL1Table[NontmlType.Factor][-LexType.INTC] = 90;

  LL1Table[NontmlType.Factor][-LexType.ID] = 91;

  LL1Table[NontmlType.Variable][-LexType.ID] = 92;

  LL1Table[NontmlType.VariMore][-LexType.ASSIGN] = 93;
  LL1Table[NontmlType.VariMore][-LexType.TIMES] = 93;
  LL1Table[NontmlType.VariMore][-LexType.OVER] = 93;
  LL1Table[NontmlType.VariMore][-LexType.PLUS] = 93;
  LL1Table[NontmlType.VariMore][-LexType.MINUS] = 93;
  LL1Table[NontmlType.VariMore][-LexType.LT] = 93;
  LL1Table[NontmlType.VariMore][-LexType.EQ] = 93;
  LL1Table[NontmlType.VariMore][-LexType.THEN] = 93;
  LL1Table[NontmlType.VariMore][-LexType.ELSE] = 93;
  LL1Table[NontmlType.VariMore][-LexType.FI] = 93;
  LL1Table[NontmlType.VariMore][-LexType.DO] = 93;
  LL1Table[NontmlType.VariMore][-LexType.ENDWH] = 93;
  LL1Table[NontmlType.VariMore][-LexType.RPAREN] = 93;
  LL1Table[NontmlType.VariMore][-LexType.END] = 93;
  LL1Table[NontmlType.VariMore][-LexType.SEMI] = 93;
  LL1Table[NontmlType.VariMore][-LexType.COMMA] = 93;
  LL1Table[NontmlType.VariMore][-LexType.RMIDPAREN] = 93;

  LL1Table[NontmlType.VariMore][-LexType.LMIDPAREN] = 94;

  LL1Table[NontmlType.VariMore][-LexType.DOT] = 95;

  LL1Table[NontmlType.FieldVar][-LexType.ID] = 96;

  LL1Table[NontmlType.FieldVarMore][-LexType.ASSIGN] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.TIMES] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.OVER] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.PLUS] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.MINUS] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.LT] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.EQ] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.THEN] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.ELSE] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.FI] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.DO] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.ENDWH] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.RPAREN] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.END] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.SEMI] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.COMMA] = 97;
  LL1Table[NontmlType.FieldVarMore][-LexType.LMIDPAREN] = 98;
  LL1Table[NontmlType.CmpOp][-LexType.LT] = 99;
  LL1Table[NontmlType.CmpOp][-LexType.EQ] = 100;
  LL1Table[NontmlType.AddOp][-LexType.PLUS] = 101;
  LL1Table[NontmlType.AddOp][-LexType.MINUS] = 102;
  LL1Table[NontmlType.MultOp][-LexType.TIMES] = 103;
  LL1Table[NontmlType.MultOp][-LexType.OVER] = 104;
 }

 public Node ParseProcess() {
  Program program = new Program();

  createLL1Table();
  signStack.push(NontmlType.Program);
  synTreeStack.push(program);

  Token token = scanner.getNextToken();
  ActionFactory factory = new ActionFactory();
  
  while (!signStack.isEmpty()) {
   int i = signStack.pop();
   if (isNontmlType(i)) {
    int num = LL1Table[i][0 - token.getLex()];
    if(num == 0){
     errorList.addError(new Error("Syntax Error>>>Unexpected token "
       + token.getSem(), token.getLineNum()));
    }else{
    Action actionInstance = factory.createActionInstance(num);
    predict(actionInstance);
    }
    
   } else if (match(token, i)) {
    Node node = synTreeStack.pop();
    if(node instanceof NodeToken){
       NodeToken n = (NodeToken) node;
       n.tokenString = token.getSem();
       n.lexType = token.getLex();
       n.lineNum = token.getLineNum();
       token = scanner.getNextToken();
    }
   }
  }
  return program;
 }

 protected boolean isNontmlType(int i) {
  return i > 0 ? true : false;
 }

 protected boolean match(Token expected, int lexType) {
  if (expected.getLex() == lexType)
   return true;
  else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
   return false;
  }
 }

 protected void predict(Action action) {
  action.execute(signStack, synTreeStack);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.CmpOp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process100Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.EQ);

  NodeToken nodeToken = new NodeToken();
  CmpOp cmpOp = (CmpOp) synTreeStack.pop();

  cmpOp.nodeChoice = new NodeChoice(nodeToken, 2);

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.AddOp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process101Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.PLUS);

  NodeToken nodeToken = new NodeToken();
  AddOp addOp = (AddOp) synTreeStack.pop();

  addOp.nodeChoice = new NodeChoice(nodeToken, 1);

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.AddOp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process102Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.MINUS);

  NodeToken nodeToken = new NodeToken();
  AddOp addOp = (AddOp) synTreeStack.pop();

  addOp.nodeChoice = new NodeChoice(nodeToken, 1);

  synTreeStack.push(nodeToken);
 }

}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.AddOp;
import edu.jlu.fuliang.yufa.Recursion.MultOp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process103Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.TIMES);

  NodeToken nodeToken = new NodeToken();
  MultOp multOp = (MultOp) synTreeStack.pop();

  multOp.nodeChoice = new NodeChoice(nodeToken, 1);

  synTreeStack.push(nodeToken);
 }

}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.MultOp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process104Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.OVER);

  NodeToken nodeToken = new NodeToken();
  MultOp multOp = (MultOp) synTreeStack.pop();

  multOp.nodeChoice = new NodeChoice(nodeToken, 1);

  synTreeStack.push(nodeToken);
 }

}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.TypeDecList;
import edu.jlu.fuliang.yufa.Recursion.TypeDecMore;

public class Process10Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.TypeDecList);

  TypeDecList typeDecList = new TypeDecList();
  TypeDecMore typeDecMore = (TypeDecMore) synTreeStack.pop();
  typeDecMore.nodeOptional.addNode(typeDecList);

  synTreeStack.push(typeDecList);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.TypeId;

public class Process11Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();

  TypeId typeId = (TypeId) synTreeStack.pop();
  typeId.nodeToken = nodeToken;

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.BaseType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.TypeDef;

public class Process12Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.BaseType);

  BaseType baseType = new BaseType();

  TypeDef typeDef = (TypeDef) synTreeStack.pop();
  typeDef.nodeChoice = new NodeChoice(baseType, 1);

  synTreeStack.push(baseType);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.StructureType;
import edu.jlu.fuliang.yufa.Recursion.TypeDef;

public class Process13Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.StructureType);

  StructureType structureType = new StructureType();

  TypeDef typeDef = (TypeDef) synTreeStack.pop();
  typeDef.nodeChoice = new NodeChoice(structureType, 2);

  synTreeStack.push(structureType);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.TypeDef;

public class Process14Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();

  TypeDef typeDef = (TypeDef) synTreeStack.pop();
  typeDef.nodeChoice = new NodeChoice(nodeToken, 3);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.BaseType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process15Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.INTEGER);

  NodeToken nodeToken = new NodeToken();

  BaseType baseType = (BaseType) synTreeStack.pop();
  baseType.nodeChoice = new NodeChoice(nodeToken, 1);

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.BaseType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process16Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.CHAR);

  NodeToken nodeToken = new NodeToken();

  BaseType baseType = (BaseType) synTreeStack.pop();
  baseType.nodeChoice = new NodeChoice(nodeToken, 1);

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.ArrayType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.StructureType;

public class Process17Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ArrayType);

  ArrayType arrayType = new ArrayType();

  StructureType structureType = (StructureType) synTreeStack.pop();
  structureType.nodeChoice = new NodeChoice(arrayType, 1);

  synTreeStack.push(arrayType);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.RecType;
import edu.jlu.fuliang.yufa.Recursion.StructureType;

public class Process18Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.RecType);

  RecType recType = new RecType();

  StructureType structureType = (StructureType) synTreeStack.pop();
  structureType.nodeChoice = new NodeChoice(recType, 2);

  synTreeStack.push(recType);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.ArrayType;
import edu.jlu.fuliang.yufa.Recursion.BaseType;
import edu.jlu.fuliang.yufa.Recursion.Low;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.Top;

public class Process19Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.BaseType);
  signStack.push(LexType.OF);
  signStack.push(LexType.RMIDPAREN);
  signStack.push(NontmlType.Top);
  signStack.push(LexType.UNDERANGE);
  signStack.push(NontmlType.Low);
  signStack.push(LexType.LMIDPAREN);
  signStack.push(LexType.ARRAY);

  NodeToken nodeToken1 = new NodeToken();
  NodeToken nodeToken2 = new NodeToken();
  NodeToken nodeToken3 = new NodeToken();
  Low low = new Low();
  NodeToken nodeToken4 = new NodeToken();
  Top top = new Top();
  NodeToken nodeToken5 = new NodeToken();
  BaseType baseType = new BaseType();

  ArrayType arrayType = (ArrayType) synTreeStack.pop();
  arrayType.nodeToken1 = nodeToken1;
  arrayType.nodeToken2 = nodeToken2;
  arrayType.nodeToken3 = nodeToken3;
  arrayType.low = low;
  arrayType.nodeToken4 = nodeToken4;
  arrayType.top = top;
  arrayType.nodeToken5 = nodeToken5;
  arrayType.baseType = baseType;

  synTreeStack.push(baseType);
  synTreeStack.push(nodeToken5);
  synTreeStack.push(top);
  synTreeStack.push(nodeToken4);
  synTreeStack.push(low);
  synTreeStack.push(nodeToken3);
  synTreeStack.push(nodeToken2);
  synTreeStack.push(nodeToken1);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.*;

public class Process1Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  //signStack.push(NontmlType.ProgramBody);
  signStack.push(NontmlType.DeclarePart);
  signStack.push(NontmlType.ProgramHead);

  
  ProgramBody programBody = new ProgramBody();
  DeclarePart declarePart = new DeclarePart();
  ProgramHeader programHeader = new ProgramHeader();
  //NodeToken nodeToken = new NodeToken();
  
  Program program = (Program) synTreeStack.pop();
  program.programHeader = programHeader;
  program.declarePart = declarePart;
  program.programBody = programBody;

  //synTreeStack.push(nodeToken);
  //synTreeStack.push(programBody);
  synTreeStack.push(declarePart);
  synTreeStack.push(programHeader);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Low;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process20Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.INTC);

  NodeToken nodeToken = new NodeToken();
  Low low = (Low) synTreeStack.pop();
  low.nodeToken = nodeToken;

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.Top;

public class Process21Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.INTC);

  NodeToken nodeToken = new NodeToken();
  Top top = (Top) synTreeStack.pop();
  top.nodeToken = nodeToken;

  synTreeStack.push(nodeToken);
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.FieldDecList;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.RecType;

public class Process22Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.END);
  signStack.push(NontmlType.FieldDecList);
  signStack.push(LexType.RECORD);

  NodeToken nodeToken1 = new NodeToken();
  FieldDecList fieldDecList = new FieldDecList();
  NodeToken nodeToken2 = new NodeToken();

  RecType recType = (RecType) synTreeStack.pop();
  recType.nodeToken1 = nodeToken1;
  recType.fieldDecList = fieldDecList;
  recType.nodeToken2 = nodeToken2;

  synTreeStack.push(nodeToken2);
  synTreeStack.push(fieldDecList);
  synTreeStack.push(nodeToken1);
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.BaseType;
import edu.jlu.fuliang.yufa.Recursion.FieldDecList;
import edu.jlu.fuliang.yufa.Recursion.FieldDecMore;
import edu.jlu.fuliang.yufa.Recursion.IdList;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process23Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.FieldDecMore);
  signStack.push(LexType.SEMI);
  signStack.push(NontmlType.IdList);
  signStack.push(NontmlType.BaseType);

  BaseType baseType = new BaseType();
  IdList idList = new IdList();
  NodeToken nodeToken = new NodeToken();
  FieldDecMore fieldDecMore = new FieldDecMore();

  FieldDecList fieldDecList = (FieldDecList) synTreeStack.pop();
  fieldDecList.nodeList.addNode(baseType);
  fieldDecList.nodeList.addNode(idList);
  fieldDecList.nodeList.addNode(nodeToken);
  fieldDecList.nodeList.addNode(fieldDecMore);

  synTreeStack.push(fieldDecMore);
  synTreeStack.push(nodeToken);
  synTreeStack.push(idList);
  synTreeStack.push(baseType);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.ArrayType;
import edu.jlu.fuliang.yufa.Recursion.FieldDecList;
import edu.jlu.fuliang.yufa.Recursion.FieldDecMore;
import edu.jlu.fuliang.yufa.Recursion.IdList;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process24Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.FieldDecMore);
  signStack.push(LexType.SEMI);
  signStack.push(NontmlType.IdList);
  signStack.push(NontmlType.ArrayType);

  ArrayType arrayType = new ArrayType();
  IdList idList = new IdList();
  NodeToken nodeToken = new NodeToken();
  FieldDecMore fieldDecMore = new FieldDecMore();

  FieldDecList fieldDecList = (FieldDecList) synTreeStack.pop();
  fieldDecList.nodeList.addNode(arrayType);
  fieldDecList.nodeList.addNode(idList);
  fieldDecList.nodeList.addNode(nodeToken);
  fieldDecList.nodeList.addNode(fieldDecMore);

  synTreeStack.push(fieldDecMore);
  synTreeStack.push(nodeToken);
  synTreeStack.push(idList);
  synTreeStack.push(arrayType);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process25Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.FieldDecList;
import edu.jlu.fuliang.yufa.Recursion.FieldDecMore;
import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process26Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.FieldDecList);

  FieldDecList fieldDecList = new FieldDecList();
  FieldDecMore fieldDecMore = (FieldDecMore)synTreeStack.pop();
  fieldDecMore.nodeOptional.addNode(fieldDecList);

  synTreeStack.push(fieldDecList);
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.IdList;
import edu.jlu.fuliang.yufa.Recursion.IdMore;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process27Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.IdMore);
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();
  IdMore idMore = new IdMore();

  IdList idList = (IdList) synTreeStack.pop();
  idList.nodeToken = nodeToken;
  idList.idMore = idMore;

  synTreeStack.push(idMore);
  synTreeStack.push(nodeToken);
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process28Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.IdList;
import edu.jlu.fuliang.yufa.Recursion.IdMore;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process29Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.IdList);
  signStack.push(LexType.COMMA);

  NodeToken nodeToken = new NodeToken();
  IdList idList = new IdList();

  IdMore idMore = (IdMore) synTreeStack.pop();
  idMore.nodeListOptional.addNode(nodeToken);
  idMore.nodeListOptional.addNode(idList);

  synTreeStack.push(idList);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.*;

public class Process2Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ProgramName);
  signStack.push(LexType.PROGRAM);

  NodeToken nodeToken = new NodeToken();
  ProgramName programName = new ProgramName();

  ProgramHeader programHeader = (ProgramHeader) synTreeStack.pop();

  programHeader.nodeToken = nodeToken;
  programHeader.programName = programName;

  synTreeStack.push(programName);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process30Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.VarDec;
import edu.jlu.fuliang.yufa.Recursion.VarDecPart;

public class Process31Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.VarDeclaration);

  VarDec varDec = new VarDec();

  VarDecPart varDecPart = (VarDecPart) synTreeStack.pop();
  varDecPart.nodeOptional.addNode(varDec);

  synTreeStack.push(varDec);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.VarDec;
import edu.jlu.fuliang.yufa.Recursion.VarDecList;

public class Process32Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.VarDecList);
  signStack.push(LexType.VAR);

  NodeToken nodeToken = new NodeToken();
  VarDecList varDecList = new VarDecList();

  VarDec varDec = (VarDec) synTreeStack.pop();
  varDec.nodeToken = nodeToken;
  varDec.varDecList = varDecList;

  synTreeStack.push(varDecList);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.TypeDef;
import edu.jlu.fuliang.yufa.Recursion.VarDecList;
import edu.jlu.fuliang.yufa.Recursion.VarDecMore;
import edu.jlu.fuliang.yufa.Recursion.VarIdList;

public class Process33Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.VarDecMore);
  signStack.push(LexType.SEMI);
  signStack.push(NontmlType.VarIdList);
  signStack.push(NontmlType.TypeName);

  TypeDef typeDef = new TypeDef();
  VarIdList varIdList = new VarIdList();
  NodeToken nodeToken = new NodeToken();
  VarDecMore varDecMore = new VarDecMore();

  VarDecList varDecList = (VarDecList) synTreeStack.pop();
  varDecList.typeDef = typeDef;
  varDecList.varIdList = varIdList;
  varDecList.nodeToken = nodeToken;
  varDecList.varDecMore = varDecMore;

  synTreeStack.push(varDecMore);
  synTreeStack.push(nodeToken);
  synTreeStack.push(varIdList);
  synTreeStack.push(typeDef);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process34Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.VarDecList;
import edu.jlu.fuliang.yufa.Recursion.VarDecMore;

public class Process35Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.VarDecList);

  VarDecList varDecList = new VarDecList();
  VarDecMore varDecMore = (VarDecMore) synTreeStack.pop();
    
   varDecMore.nodeOptional.addNode(varDecList);
   synTreeStack.push(varDecList);
       
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.VarIdList;
import edu.jlu.fuliang.yufa.Recursion.VarIdMore;

public class Process36Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.VarIdMore);
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();
  VarIdMore varIdMore = new VarIdMore();

  VarIdList varIdList = (VarIdList) synTreeStack.pop();
  
  varIdList.nodeToken = nodeToken;
  varIdList.varIdMore = varIdMore;

  synTreeStack.push(varIdMore);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process37Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.VarIdList;
import edu.jlu.fuliang.yufa.Recursion.VarIdMore;

public class Process38Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.VarIdList);
  signStack.push(LexType.COMMA);

  NodeToken nodeToken = new NodeToken();
  VarIdList varIdList = new VarIdList();

  VarIdMore varIdMore = (VarIdMore) synTreeStack.pop();
  varIdMore.nodeListOptional.addNode(nodeToken);
  varIdMore.nodeListOptional.addNode(varIdList);

  synTreeStack.push(varIdList);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process39Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.*;

public class Process3Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();
  ProgramName programName = (ProgramName)synTreeStack.pop();
  programName.nodeToken = nodeToken;

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.ProcDec;
import edu.jlu.fuliang.yufa.Recursion.ProcDeclarePart;

public class Process40Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ProcDeclaration);

  ProcDec procDec = new ProcDec();
  ProcDeclarePart procDeclarePart = (ProcDeclarePart) synTreeStack.pop();

  procDeclarePart.nodeOptional.addNode(procDec);

  synTreeStack.push(procDec);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.ParamList;
import edu.jlu.fuliang.yufa.Recursion.ProcBody;
import edu.jlu.fuliang.yufa.Recursion.ProcDec;
import edu.jlu.fuliang.yufa.Recursion.ProcDecMore;
import edu.jlu.fuliang.yufa.Recursion.ProcDecPart;
import edu.jlu.fuliang.yufa.Recursion.ProcName;

public class Process41Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ProcDecMore);
  signStack.push(NontmlType.ProcBody);
  signStack.push(NontmlType.ProcDecPart);
  signStack.push(LexType.SEMI);
  signStack.push(LexType.RPAREN);
  signStack.push(NontmlType.ParamList);
  signStack.push(LexType.LPAREN);
  signStack.push(NontmlType.ProcName);
  signStack.push(LexType.PROCEDURE);

  NodeToken nodeToken1 = new NodeToken();
  ProcName procName = new ProcName();
  NodeToken nodeToken2 = new NodeToken();
  ParamList paramList = new ParamList();
  NodeToken nodeToken3 = new NodeToken();
  NodeToken nodeToken4 = new NodeToken();
  ProcDecPart procDecPart = new ProcDecPart();
  ProcBody procBody = new ProcBody();
  ProcDecMore procDecMore = new ProcDecMore();

  ProcDec procDec = (ProcDec) synTreeStack.pop();
  procDec.nodeToken1 = nodeToken1;
  procDec.procName = procName;
  procDec.nodeToken2 = nodeToken2;
  procDec.paramList = paramList;
  procDec.nodeToken3 = nodeToken3;
  procDec.nodeToken4 = nodeToken4;
  procDec.procDecPart = procDecPart;
  procDec.procBody = procBody;
  procDec.procDecMore = procDecMore;

  synTreeStack.push(procDecMore);
  synTreeStack.push(procBody);
  synTreeStack.push(procDecPart);
  synTreeStack.push(nodeToken4);
  synTreeStack.push(nodeToken3);
  synTreeStack.push(paramList);
  synTreeStack.push(nodeToken2);
  synTreeStack.push(procName);
  synTreeStack.push(nodeToken1);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process42Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.ProcDec;
import edu.jlu.fuliang.yufa.Recursion.ProcDecMore;

public class Process43Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ProcDeclaration);

  ProcDec procDec = new ProcDec();

  ProcDecMore procDecMore = (ProcDecMore) synTreeStack.pop();
  procDecMore.nodeOptional.addNode(procDec);

  synTreeStack.push(procDec);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.ProcName;

public class Process44Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();

  ProcName procName = (ProcName) synTreeStack.pop();
  procName.nodeToken = nodeToken;

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process45Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.ParamDecList;
import edu.jlu.fuliang.yufa.Recursion.ParamList;

public class Process46Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ParamDecList);

  ParamDecList paramDecList = new ParamDecList();

  ParamList paramList = (ParamList) synTreeStack.pop();
  paramList.nodeOptional.addNode(paramDecList);

  synTreeStack.push(paramDecList);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.Param;
import edu.jlu.fuliang.yufa.Recursion.ParamDecList;
import edu.jlu.fuliang.yufa.Recursion.ParamMore;

public class Process47Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ParamMore);
  signStack.push(NontmlType.Param);

  Param param = new Param();
  ParamMore paramMore = new ParamMore();

  ParamDecList paramDecList =  (ParamDecList)synTreeStack.pop();
  paramDecList.param = param;
  paramDecList.paramMore = paramMore;

  synTreeStack.push(paramMore);
  synTreeStack.push(param);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process48Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.ParamDecList;
import edu.jlu.fuliang.yufa.Recursion.ParamMore;

public class Process49Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ParamDecList);
  signStack.push(LexType.SEMI);

  NodeToken nodeToken = new NodeToken();
  ParamDecList paramDecList = new ParamDecList();

  ParamMore paramMore = (ParamMore) synTreeStack.pop();
  paramMore.nodeListOptional.addNode(nodeToken);
  paramMore.nodeListOptional.addNode(paramDecList);

  synTreeStack.push(paramDecList);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.*;

public class Process4Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ProcDec);
  signStack.push(NontmlType.VarDec);
  signStack.push(NontmlType.TypeDec);

  TypeDecPart typeDecPart = new TypeDecPart();
  VarDecPart varDecPart = new VarDecPart();
  ProcDeclarePart procDeclarePart = new ProcDeclarePart();

  DeclarePart declarePart = (DeclarePart) synTreeStack.pop();
  declarePart.typeDecPart = typeDecPart;
  declarePart.varDecPart = varDecPart;
  declarePart.proclareDecPart = procDeclarePart;

  synTreeStack.push(procDeclarePart);
  synTreeStack.push(varDecPart);
  synTreeStack.push(typeDecPart);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.FormList;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.Param;
import edu.jlu.fuliang.yufa.Recursion.TypeDef;

public class Process50Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.FormList);
  signStack.push(NontmlType.TypeName);

  TypeDef typeDef = new TypeDef();
  FormList formList = new FormList();

  Param param = (Param) synTreeStack.pop();
  param.nodeList.addNode(typeDef);
  param.nodeList.addNode(formList);

  synTreeStack.push(formList);
  synTreeStack.push(typeDef);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.FormList;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.Param;
import edu.jlu.fuliang.yufa.Recursion.TypeDef;

public class Process51Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.FormList);
  signStack.push(NontmlType.TypeName);
  signStack.push(LexType.VAR);

  NodeToken nodeToken = new NodeToken();
  TypeDef typeDef = new TypeDef();
  FormList formList = new FormList();

  Param param = (Param) synTreeStack.pop();
  param.nodeList.addNode(nodeToken);
  param.nodeList.addNode(typeDef);
  param.nodeList.addNode(formList);

  synTreeStack.push(formList);
  synTreeStack.push(typeDef);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.FidMore;
import edu.jlu.fuliang.yufa.Recursion.FormList;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process52Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.FidMore);
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();
  FidMore fidMore = new FidMore();

  FormList formList = (FormList) synTreeStack.pop();
  formList.nodeToken = nodeToken;
  formList.fidMore = fidMore;

  synTreeStack.push(fidMore);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process53Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.FidMore;
import edu.jlu.fuliang.yufa.Recursion.FormList;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process54Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.FormList);
  signStack.push(LexType.COMMA);

  NodeToken nodeToken = new NodeToken();
  FormList formList = new FormList();

  FidMore fidMore = (FidMore) synTreeStack.pop();
  fidMore.nodeListOptional.addNode(nodeToken);
  fidMore.nodeListOptional.addNode(formList);

  synTreeStack.push(formList);
  synTreeStack.push(nodeToken);
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.DeclarePart;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.ProcDecPart;

public class Process55Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.DeclarePart);

  DeclarePart declarePart = new DeclarePart();

  ProcDecPart procDecPart = (ProcDecPart) synTreeStack.pop();
  procDecPart.declarePart = declarePart;

  synTreeStack.push(declarePart);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.ProcBody;
import edu.jlu.fuliang.yufa.Recursion.ProgramBody;

public class Process56Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ProgramBody);

  ProgramBody programBody = new ProgramBody();

  ProcBody procBody = (ProcBody) synTreeStack.pop();
  procBody.programBody = programBody;

  synTreeStack.push(programBody);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.ProgramBody;
import edu.jlu.fuliang.yufa.Recursion.StmList;

public class Process57Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.END);
  signStack.push(NontmlType.StmList);
  signStack.push(LexType.BEGIN);

  NodeToken nodeToken1 = new NodeToken();
  StmList stmList = new StmList();
  NodeToken nodeToken2 = new NodeToken();

  ProgramBody programBody = (ProgramBody) synTreeStack.pop();
  programBody.nodeToken1 = nodeToken1;
  programBody.stmList = stmList;
  programBody.nodeToken2 = nodeToken2;

  synTreeStack.push(nodeToken2);
  synTreeStack.push(stmList);
  synTreeStack.push(nodeToken1);
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.Stm;
import edu.jlu.fuliang.yufa.Recursion.StmList;
import edu.jlu.fuliang.yufa.Recursion.StmMore;

public class Process58Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.StmMore);
  signStack.push(NontmlType.Stm);

  Stm stm = new Stm();
  StmMore stmMore = new StmMore();

  StmList stmList = (StmList) synTreeStack.pop();
  stmList.stm = stm;
  stmList.stmMore = stmMore;

  synTreeStack.push(stmMore);
  synTreeStack.push(stm);
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process59Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process5Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.StmList;
import edu.jlu.fuliang.yufa.Recursion.StmMore;

public class Process60Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.StmList);
  signStack.push(LexType.SEMI);

  NodeToken nodeToken = new NodeToken();
  StmList stmList = new StmList();

  StmMore stmMore = (StmMore) synTreeStack.pop();
  stmMore.nodeListOptional.addNode(nodeToken);
  stmMore.nodeListOptional.addNode(stmList);

  synTreeStack.push(stmList);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.ConditionalStm;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.Stm;

public class Process61Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ConditionalStm);

  ConditionalStm conditionalStm = new ConditionalStm();

  Stm stm = (Stm) synTreeStack.pop();
  stm.nodeList.addNode(conditionalStm);

  synTreeStack.push(conditionalStm);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.LoopStm;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.Stm;

public class Process62Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.LoopStm);

  LoopStm loopStm = new LoopStm();

  Stm stm = (Stm) synTreeStack.pop();
  stm.nodeList.addNode(stm);

  synTreeStack.push(loopStm);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.InputStm;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.Stm;

public class Process63Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.InputStm);

  InputStm inputStm = new InputStm();

  Stm stm = (Stm) synTreeStack.pop();
  stm.nodeList.addNode(inputStm);

  synTreeStack.push(inputStm);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.OutputStm;
import edu.jlu.fuliang.yufa.Recursion.Stm;

public class Process64Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.OutputStm);

  OutputStm outputStm = new OutputStm();

  Stm stm = (Stm) synTreeStack.pop();
  stm.nodeList.addNode(outputStm);

  synTreeStack.push(outputStm);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.ReturnStm;
import edu.jlu.fuliang.yufa.Recursion.Stm;

public class Process65Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ReturnStm);

  ReturnStm returnStm = new ReturnStm();

  Stm stm = (Stm) synTreeStack.pop();
  stm.nodeList.addNode(returnStm);

  synTreeStack.push(returnStm);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.AssCall;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.Stm;

public class Process66Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.AssCall);
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();
  AssCall assCall = new AssCall();

  Stm stm = (Stm) synTreeStack.pop();
  stm.nodeList.addNode(nodeToken);
  stm.nodeList.addNode(assCall);

  synTreeStack.push(assCall);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.AssCall;
import edu.jlu.fuliang.yufa.Recursion.AssignmentRest;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;

public class Process67Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.AssignmentRest);

  AssignmentRest assignmentRest = new AssignmentRest();

  AssCall assCall = (AssCall) synTreeStack.pop();
  assCall.nodeChoice = new NodeChoice(assignmentRest, 1);

  synTreeStack.push(assignmentRest);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.AssCall;
import edu.jlu.fuliang.yufa.Recursion.CallStmRest;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;

public class Process68Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.CallStmRest);

  CallStmRest callStmRest = new CallStmRest();

  AssCall assCall = (AssCall) synTreeStack.pop();
  assCall.nodeChoice = new NodeChoice(callStmRest, 2);

  synTreeStack.push(callStmRest);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.AssignmentRest;
import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.VariMore;

public class Process69Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.Exp);
  signStack.push(LexType.ASSIGN);
  signStack.push(NontmlType.VariMore);

  VariMore variMore = new VariMore();
  NodeToken nodeToken = new NodeToken();
  Exp exp = new Exp();

  AssignmentRest assignmentRest = (AssignmentRest)synTreeStack.pop();
  assignmentRest.variMore = variMore;
  assignmentRest.nodeToken = nodeToken;
  assignmentRest.exp = exp;

  synTreeStack.push(exp);
  synTreeStack.push(nodeToken);
  synTreeStack.push(variMore);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.*;

public class Process6Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.TypeDeclaration);

  TypeDec typeDec = new TypeDec();
  TypeDecPart typeDecPart = (TypeDecPart) synTreeStack.pop();

  typeDecPart.nodeOptional.addNode(typeDec);
  synTreeStack.push(typeDec);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.ConditionalStm;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.RelExp;
import edu.jlu.fuliang.yufa.Recursion.StmList;

public class Process70Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.FI);
  signStack.push(NontmlType.StmList);
  signStack.push(LexType.ELSE);
  signStack.push(NontmlType.StmList);
  signStack.push(LexType.THEN);
  signStack.push(NontmlType.RelExp);
  signStack.push(LexType.IF);

  NodeToken nodeToken1 = new NodeToken();
  RelExp relExp = new RelExp();
  NodeToken nodeToken2 = new NodeToken();
  StmList stmList1 = new StmList();
  NodeToken nodeToken3 = new NodeToken();
  StmList stmList2 = new StmList();
  NodeToken nodeToken4 = new NodeToken();

  ConditionalStm conditionalStm =(ConditionalStm)synTreeStack.pop();
  conditionalStm.nodeToken1 = nodeToken1;
  conditionalStm.relExp = relExp;
  conditionalStm.nodeToken2 = nodeToken2;
  conditionalStm.stmList1 = stmList1;
  conditionalStm.nodeToken3 = nodeToken3;
  conditionalStm.stmList2 = stmList2;
  conditionalStm.nodeToken4 = nodeToken4;

  synTreeStack.push(nodeToken4);
  synTreeStack.push(stmList2);
  synTreeStack.push(nodeToken3);
  synTreeStack.push(stmList1);
  synTreeStack.push(nodeToken2);
  synTreeStack.push(relExp);
  synTreeStack.push(nodeToken1);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.LoopStm;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.RelExp;
import edu.jlu.fuliang.yufa.Recursion.StmList;

public class Process71Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.ENDWH);
  signStack.push(NontmlType.StmList);
  signStack.push(LexType.DO);
  signStack.push(NontmlType.RelExp);
  signStack.push(LexType.WHILE);

  NodeToken nodeToken1 = new NodeToken();
  RelExp relExp = new RelExp();
  NodeToken nodeToken2 = new NodeToken();
  StmList stmList = new StmList();
  NodeToken nodeToken3 = new NodeToken();

  LoopStm loopStm = (LoopStm) synTreeStack.pop();
  loopStm.nodeToken1 = nodeToken1;
  loopStm.relExp = relExp;
  loopStm.nodeToken2 = nodeToken2;
  loopStm.stmList = stmList;
  loopStm.nodeToken3 = nodeToken3;

  synTreeStack.push(nodeToken3);
  synTreeStack.push(stmList);
  synTreeStack.push(nodeToken2);
  synTreeStack.push(relExp);
  synTreeStack.push(nodeToken1);
  synTreeStack.push(loopStm);
 }

}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.InVar;
import edu.jlu.fuliang.yufa.Recursion.InputStm;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process72Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.RPAREN);
  signStack.push(NontmlType.InVar);
  signStack.push(LexType.LPAREN);
  signStack.push(LexType.READ);

  NodeToken nodeToken1 = new NodeToken();
  NodeToken nodeToken2 = new NodeToken();
  InVar inVar = new InVar();
  NodeToken nodeToken3 = new NodeToken();

  InputStm inputStm = (InputStm) synTreeStack.pop();
  inputStm.nodeToken1 = nodeToken1;
  inputStm.nodeToken2 = nodeToken2;
  inputStm.inVar = inVar;
  inputStm.nodeToken3 = nodeToken3;

  synTreeStack.push(nodeToken3);
  synTreeStack.push(inVar);
  synTreeStack.push(nodeToken2);
  synTreeStack.push(nodeToken1);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.InVar;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process73Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();

  InVar inVar = (InVar) synTreeStack.pop();
  inVar.nodeToken = nodeToken;

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.OutputStm;

public class Process74Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.RPAREN);
  signStack.push(NontmlType.Exp);
  signStack.push(LexType.LPAREN);
  signStack.push(LexType.WRITE);

  NodeToken nodeToken1 = new NodeToken();
  NodeToken nodeToken2 = new NodeToken();
  Exp exp = new Exp();
  NodeToken nodeToken3 = new NodeToken();

  OutputStm outputStm = (OutputStm) synTreeStack.pop();
  outputStm.nodeToken1 = nodeToken1;
  outputStm.nodeToken2 = nodeToken2;
  outputStm.exp = exp;
  outputStm.nodeToken3 = nodeToken3;

  synTreeStack.push(nodeToken3);
  synTreeStack.push(exp);
  synTreeStack.push(nodeToken2);
  synTreeStack.push(nodeToken1);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.ReturnStm;

public class Process75Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.RETURN);

  NodeToken nodeToken = new NodeToken();

  ReturnStm returnStm = (ReturnStm) synTreeStack.pop();
  returnStm.nodeToken = nodeToken;

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.ActParamList;
import edu.jlu.fuliang.yufa.Recursion.CallStmRest;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process76Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.RPAREN);
  signStack.push(NontmlType.ActParamList);
  signStack.push(LexType.LPAREN);

  NodeToken nodeToken1 = new NodeToken();
  ActParamList actParamList = new ActParamList();
  NodeToken nodeToken2 = new NodeToken();

  CallStmRest callStmRest = (CallStmRest)synTreeStack.pop();
  callStmRest.nodeToken1 = nodeToken1;
  callStmRest.actParamList = actParamList;
  callStmRest.nodeToken2 = nodeToken2;

  synTreeStack.push(nodeToken2);
  synTreeStack.push(actParamList);
  synTreeStack.push(nodeToken1);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process77Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.ActParamList;
import edu.jlu.fuliang.yufa.Recursion.ActParamMore;
import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process78Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ActParamMore);
  signStack.push(NontmlType.Exp);

  Exp exp = new Exp();
  ActParamMore actParamMore = new ActParamMore();

  ActParamList actParamList = (ActParamList) synTreeStack.pop();
  actParamList.nodeListOptional.addNode(exp);
  actParamList.nodeListOptional.addNode(actParamMore);

  synTreeStack.push(actParamMore);
  synTreeStack.push(exp);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process79Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.*;

public class Process7Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.TypeDecList);
  signStack.push(LexType.TYPE);

  NodeToken nodeToken = new NodeToken();
  TypeDecList typeDecList = new TypeDecList();

  TypeDec typeDec = (TypeDec) synTreeStack.pop();
  typeDec.nodeToken = nodeToken;
  typeDec.typeDecList = typeDecList;

  synTreeStack.push(typeDecList);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.ActParamList;
import edu.jlu.fuliang.yufa.Recursion.ActParamMore;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process80Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.ActParamList);
  signStack.push(LexType.COMMA);

  NodeToken nodeToken = new NodeToken();
  ActParamList actParamList = new ActParamList();

  ActParamMore actParamMore = (ActParamMore) synTreeStack.pop();
  actParamMore.nodeListOptional.addNode(nodeToken);
  actParamMore.nodeListOptional.addNode(actParamList);

  synTreeStack.push(actParamList);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.OtherRelE;
import edu.jlu.fuliang.yufa.Recursion.RelExp;

public class Process81Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.OtherRelE);
  signStack.push(NontmlType.Exp);

  OtherRelE otherRelE = new OtherRelE();
  Exp exp = new Exp();

  RelExp relExp = (RelExp) synTreeStack.pop();
  relExp.exp = exp;
  relExp.otherRelE = otherRelE;

  synTreeStack.push(otherRelE);
  synTreeStack.push(exp);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.CmpOp;
import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.OtherRelE;

public class Process82Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.Exp);
  signStack.push(NontmlType.CmpOp);

  CmpOp cmpOp = new CmpOp();
  Exp exp = new Exp();
  OtherRelE otherRelE = (OtherRelE) synTreeStack.pop();

  otherRelE.cmpOp = cmpOp;
  otherRelE.exp = exp;

  synTreeStack.push(exp);
  synTreeStack.push(cmpOp);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.OtherTerm;
import edu.jlu.fuliang.yufa.Recursion.Term;

public class Process83Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.OtherTerm);
  signStack.push(NontmlType.Term);

  Term term = new Term();
  OtherTerm otherTerm = new OtherTerm();

  Exp exp = (Exp) synTreeStack.pop();
  exp.term = term;
  exp.otherTerm = otherTerm;

  synTreeStack.push(otherTerm);
  synTreeStack.push(term);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process84Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.AddOp;
import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.OtherTerm;

public class Process85Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.Exp);
  signStack.push(NontmlType.AddOp);

  AddOp addOp = new AddOp();
  Exp exp = new Exp();

  OtherTerm otherTerm = (OtherTerm) synTreeStack.pop();
  otherTerm.nodeListOptional.addNode(addOp);
  otherTerm.nodeListOptional.addNode(exp);

  synTreeStack.push(exp);
  synTreeStack.push(addOp);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Factor;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.OtherFactor;
import edu.jlu.fuliang.yufa.Recursion.Term;

public class Process86Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.OtherFactor);
  signStack.push(NontmlType.Factor);

  Factor factor = new Factor();
  OtherFactor otherFactor = new OtherFactor();

  Term term = (Term) synTreeStack.pop();
  term.factor = factor;
  term.otherFactor = otherFactor;

  synTreeStack.push(otherFactor);
  synTreeStack.push(factor);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process87Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.MultOp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.OtherFactor;
import edu.jlu.fuliang.yufa.Recursion.Term;

public class Process88Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.Term);
  signStack.push(NontmlType.MultOp);

  MultOp multOp = new MultOp();
  Term term = new Term();

  OtherFactor otherFactor = (OtherFactor) synTreeStack.pop();
  otherFactor.nodeListOptional.addNode(multOp);
  otherFactor.nodeListOptional.addNode(term);

  synTreeStack.push(term);
  synTreeStack.push(multOp);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.Factor;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process89Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.RPAREN);
  signStack.push(NontmlType.Exp);
  signStack.push(LexType.LPAREN);

  NodeToken nodeToken1 = new NodeToken();
  Exp exp = new Exp();
  NodeToken nodeToken2 = new NodeToken();

  Factor factor = (Factor) synTreeStack.pop();
  factor.nodeList.addNode(nodeToken1);
  factor.nodeList.addNode(exp);
  factor.nodeList.addNode(nodeToken2);

  synTreeStack.push(nodeToken2);
  synTreeStack.push(exp);
  synTreeStack.push(nodeToken1);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.*;

public class Process8Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.TypeDecMore);
  signStack.push(LexType.SEMI);
  signStack.push(NontmlType.TypeName);
  signStack.push(LexType.EQ);
  signStack.push(NontmlType.TypeId);

  TypeId typeId = new TypeId();
  NodeToken nodeToken1 = new NodeToken();
  TypeDef typeDef = new TypeDef();
  NodeToken nodeToken2 = new NodeToken();
  TypeDecMore typeDecMore = new TypeDecMore();

  TypeDecList typeDecList = (TypeDecList) synTreeStack.pop();
  typeDecList.typeId = typeId;
  typeDecList.nodeToken1 = nodeToken1;
  typeDecList.typeDef = typeDef;
  typeDecList.nodeToken2 = nodeToken2;
  typeDecList.typeDecMore = typeDecMore;

  synTreeStack.push(typeDecMore);
  synTreeStack.push(nodeToken2);
  synTreeStack.push(typeDef);
  synTreeStack.push(nodeToken1);
  synTreeStack.push(typeId);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Factor;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process90Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.INTC);

  NodeToken nodeToken = new NodeToken();

  Factor factor = (Factor) synTreeStack.pop();
  factor.nodeList.addNode(nodeToken);

  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Factor;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.Variable;

public class Process91Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.Variable);

  Variable variable = new Variable();

  Factor factor = (Factor) synTreeStack.pop();
  factor.nodeList.addNode(variable);

  synTreeStack.push(variable);
 }

}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.VariMore;
import edu.jlu.fuliang.yufa.Recursion.Variable;

public class Process92Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.VariMore);
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();
  VariMore variMore = new VariMore();

  Variable variable = (Variable) synTreeStack.pop();
  variable.nodeToken = nodeToken;
  variable.variMore = variMore;

  synTreeStack.push(variMore);
  synTreeStack.push(nodeToken);
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process93Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.VariMore;

public class Process94Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.RMIDPAREN);
  signStack.push(NontmlType.Exp);
  signStack.push(LexType.LMIDPAREN);

  NodeToken nodeToken1 = new NodeToken();
  Exp exp = new Exp();
  NodeToken nodeToken2 = new NodeToken();

  VariMore variMore = (VariMore) synTreeStack.pop();
  variMore.nodeListOptional.addNode(nodeToken1);
  variMore.nodeListOptional.addNode(exp);
  variMore.nodeListOptional.addNode(nodeToken2);

  synTreeStack.push(nodeToken2);
  synTreeStack.push(exp);
  synTreeStack.push(nodeToken1);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.FieldVar;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;
import edu.jlu.fuliang.yufa.Recursion.VariMore;

public class Process95Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.FieldVar);
  signStack.push(LexType.DOT);

  NodeToken nodeToken = new NodeToken();
  FieldVar fieldVar = new FieldVar();

  VariMore variMore = (VariMore) synTreeStack.pop();
  variMore.nodeListOptional.addNode(nodeToken);
  variMore.nodeListOptional.addNode(fieldVar);

  synTreeStack.push(fieldVar);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.FieldVar;
import edu.jlu.fuliang.yufa.Recursion.FieldVarMore;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process96Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(NontmlType.FieldVarMore);
  signStack.push(LexType.ID);

  NodeToken nodeToken = new NodeToken();
  FieldVarMore fieldVarMore = new FieldVarMore();

  FieldVar fieldVar = (FieldVar) synTreeStack.pop();
  fieldVar.nodeToken = nodeToken;
  fieldVar.fieldVarMore = fieldVarMore;

  synTreeStack.push(fieldVarMore);
  synTreeStack.push(nodeToken);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process97Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.Exp;
import edu.jlu.fuliang.yufa.Recursion.FieldVarMore;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process98Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.RMIDPAREN);
  signStack.push(NontmlType.Exp);
  signStack.push(LexType.LMIDPAREN);

  NodeToken nodeToken1 = new NodeToken();
  Exp exp = new Exp();
  NodeToken nodeToken2 = new NodeToken();

  FieldVarMore fieldVarMore = (FieldVarMore)synTreeStack.pop();
  fieldVarMore.nodeListOptional.addNode(nodeToken1);
  fieldVarMore.nodeListOptional.addNode(exp);
  fieldVarMore.nodeListOptional.addNode(nodeToken2);

  synTreeStack.push(nodeToken2);
  synTreeStack.push(exp);
  synTreeStack.push(nodeToken1);
 }
}
package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.yufa.Recursion.CmpOp;
import edu.jlu.fuliang.yufa.Recursion.Node;
import edu.jlu.fuliang.yufa.Recursion.NodeChoice;
import edu.jlu.fuliang.yufa.Recursion.NodeToken;

public class Process99Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  signStack.push(LexType.LT);

  NodeToken nodeToken = new NodeToken();
  CmpOp cmpOp = (CmpOp) synTreeStack.pop();

  cmpOp.nodeChoice = new NodeChoice(nodeToken, 1);

  synTreeStack.push(nodeToken);
 }
}package edu.jlu.fuliang.yufa.LL1;

import edu.jlu.fuliang.yufa.Recursion.Node;

public class Process9Action implements Action {

 public void execute(Stack<Integer> signStack, Stack<Node> synTreeStack) {
  synTreeStack.pop();
 }
}
package edu.jlu.fuliang.yufa.LL1;

import java.util.*;

public class Stack<T> {
 private ArrayList<T> arrayList;

 public Stack() {
  arrayList = new ArrayList<T>();
 }

 public void push(T i) {
  arrayList.add(i);
 }

 public T peek() {
  if(! arrayList.isEmpty())
   return arrayList.get(arrayList.size() - 1);
  return null;
 }

 public T pop() {
  if(! arrayList.isEmpty()){
     T i = arrayList.get(arrayList.size() - 1);
     arrayList.remove(arrayList.size() - 1);
     return i;
  }
    return null;
 }

 public boolean isEmpty() {
  return arrayList.isEmpty();
 }
}package edu.jlu.fuliang.yufa.Recursion;

public class ActParamList implements Node {
 public NodeListOptional nodeListOptional;

 public ActParamList() {
  nodeListOptional = new NodeListOptional();
 }

 public ActParamList(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitActParamList(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式ActParamMore ::= ε  |,ActParamList
 */
public class ActParamMore implements Node {
 public NodeListOptional nodeListOptional;

 public ActParamMore() {
  nodeListOptional = new NodeListOptional();
 }

 public ActParamMore(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitActParamMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式AddOp ::= + | -
 */
public class AddOp implements Node {
 public NodeChoice nodeChoice;

 public AddOp() {

 }

 public AddOp(NodeChoice nodeChoice) {
  this.nodeChoice = nodeChoice;
 }

 public void accept(Visitor v) {
  v.visitAddOp(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

/*
 * 产生式 < arrayType > ::=  ARRAY [low..top] OF baseType
 */

public class ArrayType implements Node {

 public NodeToken nodeToken1;

 public NodeToken nodeToken2;

 public Low low;

 public NodeToken nodeToken3;

 public Top top;

 public NodeToken nodeToken4;

 public NodeToken nodeToken5;

 public BaseType baseType;

 public ArrayType() {

 }

 public ArrayType(NodeToken nodeToken1, NodeToken nodeToken2, Low low,
   NodeToken nodeToken3, Top top, NodeToken nodeToken4,
   NodeToken nodeToken5, BaseType baseType) {
  this.nodeToken1 = nodeToken1;
  this.nodeToken2 = nodeToken2;
  this.low = low;
  this.nodeToken3 = nodeToken3;
  this.top = top;
  this.nodeToken4 = nodeToken4;
  this.nodeToken5 = nodeToken5;
  this.baseType = baseType;
 }

 public void accept(Visitor v) {
  v.visitArrayType(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < assCall > ::=   assignmentRest   {:=,LMIDPAREN,DOT}    
 *                        | callStmRest     {(}  
 */
public class AssCall implements Node {
 public NodeChoice nodeChoice;

 public AssCall() {

 }

 public AssCall(NodeChoice nodeChoice) {
  this.nodeChoice = nodeChoice;
 }

 public void accept(Visitor v) {
  v.visitAssCall(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < assignmentRest > ::=  variMore : = exp
 */
public class AssignmentRest implements Node {
 public VariMore variMore;

 public NodeToken nodeToken;

 public Exp exp;

 public AssignmentRest() {

 }

 public AssignmentRest(VariMore variMore, NodeToken nodeToken, Exp exp) {
  this.variMore = variMore;
  this.nodeToken = nodeToken;
  this.exp = exp;
 }

 public void accept(Visitor v) {
  v.visitAssignmentRest(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < baseType > ::=  INTEGER | CHAR
 */
public class BaseType implements Node {
 public NodeChoice nodeChoice;

 public BaseType() {

 }

 public BaseType(NodeChoice nodeChoice) {
  this.nodeChoice = nodeChoice;
 }

 public void accept(Visitor v) {
  v.visitBaseType(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

public interface Builder {
 
 public Node getTreeRoot();
 
 public Node buildActParamList(NodeListOptional nodeListOptional);
  
 public Node buildActParamMore(NodeListOptional nodeListOptional);
   
    public Node buildArrayType(NodeToken nodeToken1, NodeToken nodeToken2,
    Low low, NodeToken nodeToken3, Top top, NodeToken nodeToken4,
    NodeToken nodeToken5, BaseType baseType);

 public Node buildAssCall(NodeChoice nodeChoice);

  public Node buildAssignmentRest(VariMore variMore, NodeToken nodeToken,
    Exp exp);

  public Node buildBaseType(NodeChoice nodeChoice);

  public Node buildCallStmRest(NodeToken nodeToken1,
    ActParamList actParamList, NodeToken nodeToken2);

  public Node buildCmpOp(NodeChoice nodeChoice) ;
  

  public Node buildConditonalStm(NodeToken nodeToken1, RelExp relExp,
    NodeToken nodeToken2, StmList stmList1, NodeToken nodeToken3,
    StmList stmList2, NodeToken nodeToken4) ;
   

  public Node buildDeclarePart(TypeDecPart typeDecPart,
    VarDecPart varDecPart, ProcDeclarePart procDeclarePart);

  public Node buildProcDeclarePart(NodeOptional nodeOptional);

  public Node buildExp(Term term, OtherTerm otherTerm);

  public Node buildFactor(NodeList nodeList);

  public Node buildFidMore(NodeListOptional nodeListOptional);

  public Node buildFieldDecList(NodeList nodeList);

  public Node buildFieldDecMore(NodeOptional nodeOptional);

  public Node buildFieldVar(NodeToken nodeToken, FieldVarMore fieldVarMore);

  public Node buildFieldVarMore(NodeListOptional nodeListOptional);

  public Node buildFormList(NodeToken nodeToken, FidMore fidMore);

  public Node buildIdList(NodeToken nodeToken, IdMore idMore);

  public Node buildIdMore(NodeListOptional nodeListOptional);

  public Node buildInputStm(NodeToken nodeToken1, NodeToken nodeToken2,
    InVar inVar, NodeToken nodeToken3);

  public Node buildInVar(NodeToken nodeToken);

  public Node buildLoopStm(NodeToken nodeToken1, RelExp relExp,
    NodeToken nodeToken2, StmList stmList, NodeToken nodeToken3); 

  public Node buildMultOp(NodeChoice nodeChoice);

  public Node buildOtherFactor(NodeListOptional nodeListOptional);

  public Node buildOtherRelE(CmpOp cmpOp, Exp exp);

  public Node buildOtherTerm(NodeListOptional nodeListOptional);

  public Node buildOutputStm(NodeToken nodeToken1, NodeToken nodeToken2,
    Exp exp, NodeToken nodeToken3);

  public Node buildParam(NodeList nodeList);

  public Node buildParamDecList(Param param, ParamMore paramMore);

  public Node buildParamList(NodeOptional nodeOptional);

  public Node buildParamMore(NodeListOptional nodeListOptional);

  public Node buildProcDec(NodeToken nodeToken1, ProcName procName,
    NodeToken nodeToken2, ParamList paramList, NodeToken nodeToken3,
    NodeToken nodeToken4, ProcDecPart procDecPart, ProcBody procBody,
    ProcDecMore procDecMore);

  public Node buildProcBody(ProgramBody programBody);

  public Node buildProcDecMore(NodeOptional nodeOptional);

  public Node buildProcDecPart(DeclarePart declarePart);

  public Node buildProcName(NodeToken nodeToken);

  public Node buildProgram(ProgramHeader programHeader,
    DeclarePart declarePart, ProgramBody programBody);

  public Node buildProgramHeader(NodeToken nodeToken, ProgramName programName);

  public Node buildProgramName(NodeToken nodeToken);

  public Node buildProgramBody(NodeToken nodeToken1, StmList stmList,
    NodeToken nodeToken2);

  public Node buildRecType(NodeToken nodeToken1, FieldDecList fieldDecList,
    NodeToken nodeToken2);

  public Node buildRelExp(Exp exp, OtherRelE otherRelE);

  public Node buildReturnStm(NodeToken nodeToken);

  public Node buildStm(NodeList nodeList);

  public Node buildStmList(Stm stm, StmMore stmMore);

  public Node buildStmMore(NodeListOptional nodeListOptional);

  public Node buildStructureType(NodeChoice nodeChoice);

  public Node buildTerm(Factor factor, OtherFactor otherFactor);

  public Node buildTop(NodeToken nodeToken);

  public Node buildTypeDecList(TypeId typeId, NodeToken nodeToken1,
    TypeDef typeDef, NodeToken nodeToken2, TypeDecMore typeDecMore);

  public Node buildTypeDecMore(NodeOptional nodeOptional);

  public Node buildTypeDecPart(NodeOptional nodeOptional);

  public Node buildTypeDef(NodeChoice nodeChoice);

  public Node buildTypeId(NodeToken nodeToken);

  public Node buildVarDec(NodeToken nodeToken, VarDecList varDecList);

  public Node buildVarDecList(TypeDef typeDef, VarIdList varIdList,
    NodeToken nodeToken, VarDecMore varDecMore);

  public Node buildVarDecMore(NodeOptional nodeOptional);

  public Node buildVarDecPart(NodeOptional nodeOptional);

  public Node buildVariable(NodeToken nodeToken, VariMore variMore);

  public Node buildVarIdList(NodeToken nodeToken, VarIdMore varIdMore);

  public Node buildVarIdMore(NodeListOptional nodeListOptional);

  public Node buildVariMore(NodeListOptional nodeListOptional);

  public Node buildAddOp(NodeChoice nodeChoice);

  public Node buildLow(NodeToken nodeToken);

  public Node buildTypeDec(NodeToken nodeToken, TypeDecList typeDecList);

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < callStmRest > ::=  (actParamList)
 */
public class CallStmRest implements Node {
 public NodeToken nodeToken1;

 public ActParamList actParamList;

 public NodeToken nodeToken2;

 public CallStmRest() {

 }

 public CallStmRest(NodeToken nodeToken1, ActParamList actParamList,
   NodeToken nodeToken2) {
  this.nodeToken1 = nodeToken1;
  this.actParamList = actParamList;
  this.nodeToken2 = nodeToken2;
 }

 public void accept(Visitor v) {
  v.visitCallStmRest(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式CompOp ::= < | =
 */
public class CmpOp implements Node {
 public NodeChoice nodeChoice;

 public CmpOp() {

 }

 public CmpOp(NodeChoice nodeChoice) {
  this.nodeChoice = nodeChoice;
 }

 public void accept(Visitor v) {
  v.visitCmpOp(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < conditionalStm > ::= IF exp THEN stmList ELSE stmList FI
 */
public class ConditionalStm implements Node {

 public NodeToken nodeToken1;

 public RelExp relExp;

 public NodeToken nodeToken2;

 public StmList stmList1;

 public NodeToken nodeToken3;

 public StmList stmList2;

 public NodeToken nodeToken4;

 public ConditionalStm() {

 }

 public ConditionalStm(NodeToken nodeToken1, RelExp relExp,
   NodeToken nodeToken2, StmList stmList1, NodeToken nodeToken3,
   StmList stmList2, NodeToken nodeToken4) {
  this.nodeToken1 = nodeToken1;
  this.relExp = relExp;
  this.nodeToken2 = nodeToken2;
  this.stmList1 = stmList1;
  this.nodeToken3 = nodeToken3;
  this.stmList2 = stmList2;
  this.nodeToken4 = nodeToken4;
 }

 public void accept(Visitor v) {
  v.visitConditionalStm(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;

/*
 * 产生式 < declarePart > ::= typeDec  varDec  procDec
 */

public class DeclarePart implements Node {
 public TypeDecPart typeDecPart;

 public VarDecPart varDecPart;

 public ProcDeclarePart proclareDecPart;

 public DeclarePart() {

 }

 public DeclarePart(TypeDecPart typeDecPart, VarDecPart varDecPart,
   ProcDeclarePart proclareDecPart) {
  this.typeDecPart = typeDecPart;
  this.varDecPart = varDecPart;
  this.proclareDecPart = proclareDecPart;
 }

 public void accept(Visitor v) {
  v.visitDeclarePart(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式Exp := Term OtherTerm
 */
public class Exp implements Node {
 public Term term;

 public OtherTerm otherTerm;

 public Exp() {

 }

 public Exp(Term term, OtherTerm otherTerm) {
  this.term = term;
  this.otherTerm = otherTerm;
 }

 public void accept(Visitor v) {
  v.visitExp(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式Factor ::=(Exp) | INTC | Variable
 */
public class Factor implements Node {
 public NodeList nodeList;

 public Factor() {
  nodeList = new NodeList();
 }

 public Factor(NodeList nodeList) {
  this.nodeList = nodeList;
 }

 public void accept(Visitor v) {
  v.visitFactor(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < fidMore > ::=   ε |  , formList
 */
public class FidMore implements Node {
 public NodeListOptional nodeListOptional;

 public FidMore() {
  nodeListOptional = new NodeListOptional();
 }

 public FidMore(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitFidMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < fieldDecList > ::=   baseType idList ; fieldDecMore   
 *                             | arrayType idList; fieldDecMore
 */
public class FieldDecList implements Node {

 public NodeList nodeList;

 public FieldDecList() {
  nodeList = new NodeList();
 }

 public FieldDecList(NodeList nodeList) {
  this.nodeList = nodeList;
 }

 public void accept(Visitor v) {
  v.visitFieldDecList(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < fieldDecMore > ::=  ε | fieldDecList
 */
public class FieldDecMore implements Node {
 public NodeOptional nodeOptional;

 public FieldDecMore() {
  nodeOptional = new NodeOptional();
 }

 public FieldDecMore(NodeOptional nodeOptional) {
  this.nodeOptional = nodeOptional;
 }

 public void accept(Visitor v) {
  v.visitFieldDecMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式FieldVar ::= ID FieldVarMore
 */
public class FieldVar implements Node {
 public NodeToken nodeToken;

 public FieldVarMore fieldVarMore;

 public FieldVar() {

 }

 public FieldVar(NodeToken nodeToken, FieldVarMore fieldVarMore) {
  this.nodeToken = nodeToken;
  this.fieldVarMore = fieldVarMore;
 }

 public void accept(Visitor v) {
  v.visitFieldVar(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式FieldVarMore ::= ε | [Exp]
 */
public class FieldVarMore implements Node {
 public NodeListOptional nodeListOptional;

 public FieldVarMore() {
  nodeListOptional = new NodeListOptional();
 }

 public FieldVarMore(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitFieldVarMore(this);
 }
}package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < formList > ::=  id  fidMore
 */
public class FormList implements Node {

 public NodeToken nodeToken;

 public FidMore fidMore;

 public FormList() {

 }

 public FormList(NodeToken nodeToken, FidMore fidMore) {
  this.nodeToken = nodeToken;
  this.fidMore = fidMore;
 }

 public void accept(Visitor v) {
  v.visitFormList(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < idList > ::=  id  idMore
 */
public class IdList implements Node {
 public NodeToken nodeToken;

 public IdMore idMore;

 public IdList() {

 }

 public IdList(NodeToken nodeToken, IdMore idMore) {
  this.nodeToken = nodeToken;
  this.idMore = idMore;
 }

 public void accept(Visitor v) {
  v.visitIdList(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < idMore > ::=  ε |  , idList
 */
public class IdMore implements Node {

 public NodeListOptional nodeListOptional;

 public IdMore() {
  nodeListOptional = new NodeListOptional();
 }

 public IdMore(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitIdMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < inputStm > ::=    READ(id)
 */
public class InputStm implements Node {

 public NodeToken nodeToken1;

 public NodeToken nodeToken2;

 public InVar inVar;

 public NodeToken nodeToken3;

 public InputStm() {

 }

 public InputStm(NodeToken nodeToken1, NodeToken nodeToken2, InVar inVar,
   NodeToken nodeToken3) {
  this.nodeToken1 = nodeToken1;
  this.nodeToken2 = nodeToken2;
  this.inVar = inVar;
  this.nodeToken3 = nodeToken3;
 }

 public void accept(Visitor v) {
  v.visitInputStm(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;

public class InVar implements Node {
 public NodeToken nodeToken;

 public InVar() {

 }

 public InVar(NodeToken nodeToken) {
  this.nodeToken = nodeToken;
 }

 public void accept(Visitor v) {
  v.visitInVar(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 *  产生式 < loopStm > ::=      WHILE exp DO stmList ENDWH
 */
public class LoopStm implements Node {

 public NodeToken nodeToken1;

 public RelExp relExp;

 public NodeToken nodeToken2;

 public StmList stmList;

 public NodeToken nodeToken3;

 public LoopStm() {

 }

 public LoopStm(NodeToken nodeToken1, RelExp relExp, NodeToken nodeToken2,
   StmList stmList, NodeToken nodeToken3) {
  this.nodeToken1 = nodeToken1;
  this.relExp = relExp;
  this.nodeToken2 = nodeToken2;
  this.stmList = stmList;
  this.nodeToken3 = nodeToken3;
 }

 public void accept(Visitor v) {
  v.visitLoopStm(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 *  产生式 Low ::= INTC
 */
public class Low implements Node {
 public NodeToken nodeToken;

 public Low() {

 }

 public Low(NodeToken nodeToken) {
  this.nodeToken = nodeToken;
 }

 public void accept(Visitor v) {
  v.visitLow(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式MultOp ::= * | /
 */
public class MultOp implements Node {
 public NodeChoice nodeChoice;

 public MultOp() {

 }

 public MultOp(NodeChoice nodeChoice) {
  this.nodeChoice = nodeChoice;
 }

 public void accept(Visitor v) {
  v.visitMultOp(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

/*
 * composite(组合)模式的基类
 */
public interface Node {
 /*
  * 抽象方法accept,Visitor(访问)模式中Visitor 可以通过accept方法,访问该节点
  */
 public void accept(Visitor v);
}
package edu.jlu.fuliang.yufa.Recursion;

public class NodeChoice implements Node {
 public Node choice;
 public int which;

 public NodeChoice() {

 }

 public NodeChoice(Node node, int whichChoice) {
  choice = node;
  which = whichChoice;
 }

 public void accept(Visitor v) {
  choice.accept(v);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

import java.util.ArrayList;
import java.util.Iterator;

public class NodeList implements Node {
 public ArrayList nodes;

 public NodeList() {
  nodes = new ArrayList();
 }

 public void accept(Visitor v) {
  v.visitNodeList(this);
 }

 public void addNode(Node node) {
  if(node != null)
  nodes.add(node);
 }

 public Iterator elements() {
  return nodes.iterator();
 }

 public Node getChild(int i) {
  return (Node) nodes.get(i);
 }

 public int size() {
  return nodes.size();
 }
}
package edu.jlu.fuliang.yufa.Recursion;

import java.util.ArrayList;
import java.util.Iterator;

public class NodeListOptional implements Node {
 public ArrayList nodes;

 public NodeListOptional() {
  nodes = new ArrayList();
 }

 public void addNode(Node node) {
  if(node != null)
  nodes.add(node);
 }

 public Node getChild(int i) {
  return (Node) nodes.get(i);
 }

 public Iterator elements() {
  return nodes.iterator();
 }

 public int size() {
  return nodes.size();
 }

 public boolean present() {
  return nodes.size() != 0;
 }

 public void accept(Visitor v) {
  v.visitNodeListOptional(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

public class NodeOptional implements Node {
 public Node node;

 public NodeOptional() {
  node = null;
 }

 public void addNode(Node node) {
  if (this.node != null)
   throw new RuntimeException("Attempt to set optional node twice!");
  if(node != null)
     this.node = node;
 }

 public void accept(Visitor v) {
  v.visitNodeOptional(this);
 }

 public boolean present() {
  return node != null;
 }
}
package edu.jlu.fuliang.yufa.Recursion;

public class NodeToken implements Node {
 public String tokenString;

 public int lexType;

 public int lineNum;

 public NodeToken() {

 }

 public NodeToken(String tokenString, int lexType, int lineNum) {
  this.tokenString = tokenString;
  this.lexType = lexType;
  this.lineNum = lineNum;
 }

 public String toString() {
  return tokenString;
 }

 public void accept(Visitor v) {
  v.visitNodeToken(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 OtherFactor := ε | MultOp Term
 */
public class OtherFactor implements Node {
 public NodeListOptional nodeListOptional;

 public OtherFactor() {
  nodeListOptional = new NodeListOptional();
 }

 public OtherFactor(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitOtherFactor(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式OtherRelE := CmpOp Exp
 */
public class OtherRelE implements Node {
 public CmpOp cmpOp;

 public Exp exp;

 public OtherRelE() {

 }

 public OtherRelE(CmpOp cmpOp, Exp exp) {
  this.cmpOp = cmpOp;
  this.exp = exp;
 }

 public void accept(Visitor v) {
  v.visitOtherRelE(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式OtherTerm := ε | AddOp Exp
 */
public class OtherTerm implements Node {
 public NodeListOptional nodeListOptional;

 public OtherTerm() {
  nodeListOptional = new NodeListOptional();
 }

 public OtherTerm(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitOtherTerm(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < outputStm > ::=   WRITE(exp)
 */
public class OutputStm implements Node {
 public NodeToken nodeToken1;

 public NodeToken nodeToken2;

 public Exp exp;

 public NodeToken nodeToken3;

 public OutputStm() {

 }

 public OutputStm(NodeToken nodeToken1, NodeToken nodeToken2, Exp exp,
   NodeToken nodeToken3) {
  this.nodeToken1 = nodeToken1;
  this.nodeToken2 = nodeToken2;
  this.exp = exp;
  this.nodeToken3 = nodeToken3;
 }

 public void accept(Visitor v) {
  v.visitOutputStm(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < param > ::=  typeName formList | VAR typeName formList
 */
public class Param implements Node {
 public NodeList nodeList;

 public Param() {
  nodeList = new NodeList();
 }

 public Param(NodeList nodeList) {
  this.nodeList = nodeList;
 }

 public void accept(Visitor v) {
  v.visitParam(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 *  产生式 < paramDecList > ::=  param  paramMore
 */
public class ParamDecList implements Node {
 public Param param;

 public ParamMore paramMore;

 public ParamDecList() {

 }

 public ParamDecList(Param param, ParamMore paramMore) {
  this.param = param;
  this.paramMore = paramMore;
 }

 public void accept(Visitor v) {
  v.visitParamDecList(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < paramList > ::=  ε |  paramDecList
 */
public class ParamList implements Node {

 public NodeOptional nodeOptional;

 public ParamList() {
  nodeOptional = new NodeOptional();
 }

 public ParamList(NodeOptional nodeOptional) {
  this.nodeOptional = nodeOptional;
 }

 public void accept(Visitor v) {
  v.visitParamList(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < paramMore > ::=  ε | ; paramDecList
 */
public class ParamMore implements Node {
 public NodeListOptional nodeListOptional;

 public ParamMore() {
  nodeListOptional = new NodeListOptional();
 }

 public ParamMore(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitParamMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

import java.io.*;
import java.util.ArrayList;

import edu.jlu.fuliang.ErrorList;
import edu.jlu.fuliang.Error;
import edu.jlu.fuliang.LexType;
import edu.jlu.fuliang.cifa.Scanner;
import edu.jlu.fuliang.cifa.Token;
/*
 * SNL语法分析---递归下降法的实现,
 * 主要完成语法树的构建和错误检查
 */
public class Parser {
 private Scanner scanner;

 private Builder builder;

 private Token expected;

 private ErrorList errorList;
 
 private PrintWriter out;
 
/*
 * 构造函数,除了完成成员初始化外,调用newProgram完成整个语法树的
 * 构建,以及错误的捕获工作
 */
 public Parser(Scanner scanner, Builder builder,
   OutputStream output) {
  out = new PrintWriter(output,true);
  this.scanner = scanner;
  this.builder = builder;
  errorList = new ErrorList();
  expected = scanner.getNextToken();
  newProgram();
  if (expected.getLex() != LexType.ENDFILE) {
   new Error("Code ends before file/n ", expected.getLineNum());
  }
 }
/*
 * 判断语法分析过程是否发现文法错误(如果发现,只会输出错误信息,而
 * 不进行语法树的打印工作
 */
 public boolean isNoErrors() {
  return errorList.getErrorNum() == 0;
 }

 public void PrintErrors() {
  int errorNum = errorList.getErrorNum();
  out.println("语法分析有:" + errorNum + " 个错误:");
  ArrayList<Error> errors = errorList.getErrors();
  for (int i = 0; i < errorNum; i++) {
     out.println("Error " + (i + 1) + " in line "
     + (errors.get(i).getLineNum()) + ": "
     + errors.get(i).getErrorInfo() + " ;");
  }
 }
 /*
  *产生式 < program > ::= programHead declarePart programBody
  *函数根据文法产生式,调用相应的递归处理函数,生成语法树节点programHead
  *declarePart programBody
  */
 public Node newProgram() {
  if (expected.getLex() == LexType.PROGRAM) {
   ProgramHeader programHeader = (ProgramHeader) newProgramHeader();
   DeclarePart declarePart = (DeclarePart) newDeclarePart();
   ProgramBody programBody = (ProgramBody) newProgramBody();

   return builder
     .buildProgram(programHeader, declarePart, programBody);
  } else
   return null;
 }
 /*
 *产生式 < programHead > ::= PROGRAM  ProgramName                  */
 /* 函数根据文法产生式,调用相应的递归处理函数,生成语法树节点
 */
 public Node newProgramHeader() {

  NodeToken nodeToken = null;

  if (match(expected, LexType.PROGRAM)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.PROGRAM,
     expected.getLineNum());
   expected = scanner.getNextToken();
   ProgramName programName = (ProgramName) newProgramName();
   return builder.buildProgramHeader(nodeToken, programName);
  } else
   return null;
 }
/*
 * 产生式programName ::= ID
 */
 public Node newProgramName() {

  NodeToken nodeToken = null;

  if (match(expected, LexType.ID)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.ID, expected
     .getLineNum());
   expected = scanner.getNextToken();
   return builder.buildProgramName(nodeToken);
  } else
   return null;

 }
 /*
  * 产生式 < declarePart > ::= typeDec  varDec  procDec
  */
 public Node newDeclarePart() {
  switch (expected.getLex()) {
  case LexType.TYPE:
  case LexType.VAR:
  case LexType.PROCEDURE:
  case LexType.BEGIN:
   TypeDecPart typeDecPart = (TypeDecPart) newTypeDecPart();
   VarDecPart varDecPart = (VarDecPart) newVarDecPart();
   ProcDeclarePart procDeclarePart = (ProcDeclarePart) newProcDeclarePart();
   return builder.buildDeclarePart(typeDecPart, varDecPart,
     procDeclarePart);
  default:
   return null;
  }
 }
 /*
  * ProcDeclarePart ::= ε | ProcDec
  */
 public Node newProcDeclarePart() {
  NodeOptional nodeOptional = new NodeOptional();
  if (expected.getLex() == LexType.PROCEDURE) {
   ProcDec procDec = (ProcDec) newProcDec();
   nodeOptional.addNode(procDec);
   return builder.buildProcDeclarePart(nodeOptional);
  } else if (expected.getLex() == LexType.BEGIN) {

  } else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
 /*
  * 产生式< typeDec > ::= ε | TypeDeclaration
  */
 public Node newTypeDecPart() {
  NodeOptional nodeOptional = new NodeOptional();
  switch (expected.getLex()) {
  case LexType.TYPE:
   nodeOptional.addNode(newTypeDec());
   return builder.buildTypeDecPart(nodeOptional);
  case LexType.VAR:
  case LexType.PROCEDURE:
  case LexType.BEGIN:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;

 }
 /*
  * 产生式< TypeDec > ::= TYPE  TypeDecList
  */
 public Node newTypeDec() {
  NodeToken nodeToken = null;
  if (match(expected, LexType.TYPE)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.TYPE, expected
     .getLineNum());
   expected = scanner.getNextToken();
   TypeDecList typeDecList = (TypeDecList) newTypeDecList();
   return builder.buildTypeDec(nodeToken, typeDecList);
  }
  return null;

 }
/*
 * 产生式< TypeDecList > ::= typeId = typeName ; typeDecMore
 */
 public Node newTypeDecList() {

  TypeId typeId = (TypeId) newTypeId();
  NodeToken nodeToken1 = null, nodeToken2 = null;

  if (match(expected, LexType.EQ)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.EQ, expected
     .getLineNum());
   expected = scanner.getNextToken();

   TypeDef typeDef = (TypeDef) newTypeDef();
   if (match(expected, LexType.SEMI)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.SEMI,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }

   TypeDecMore typeDecMore = (TypeDecMore) newTypeDecMore();
   return builder.buildTypeDecList(typeId, nodeToken1, typeDef,
     nodeToken2, typeDecMore);
  }

  return null;

 }
 /*
  *产生式 < typeDecMore > ::=    ε | TypeDecList
  */
 public Node newTypeDecMore() {

  NodeOptional nodeOptional = new NodeOptional();

  switch (expected.getLex()) {
  case LexType.ID:
   TypeDecList typeDecList = (TypeDecList) newTypeDecList();
   nodeOptional.addNode(typeDecList);
   return builder.buildTypeDecMore(nodeOptional);
  case LexType.VAR:
  case LexType.PROCEDURE:
  case LexType.BEGIN:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
 * < typeId > ::= id
 */
 public Node newTypeId() {
  NodeToken nodeToken = null;

  if (match(expected, LexType.ID)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.ID, expected
     .getLineNum());
   expected = scanner.getNextToken();
   return builder.buildTypeId(nodeToken);
  }
  return null;
 }
/*
 * < typeDef > ::= baseType | structureType | id
 */
 public Node newTypeDef() {
  NodeChoice nodeChoice = null;
  switch (expected.getLex()) {
  case LexType.INTEGER:
  case LexType.CHAR:
   BaseType baseType = (BaseType) newBaseType();
   nodeChoice = new NodeChoice(baseType, 1);
   return builder.buildTypeDef(nodeChoice);
  case LexType.ARRAY:
  case LexType.RECORD:
   StructureType structureType = (StructureType) newStructureType();
   nodeChoice = new NodeChoice(structureType, 2);
   return builder.buildTypeDef(nodeChoice);
  case LexType.ID:
   NodeToken nodeToken = new NodeToken(expected.getSem(), LexType.ID,
     expected.getLineNum());
   nodeChoice = new NodeChoice(nodeToken, 3);
   expected = scanner.getNextToken();
   return builder.buildTypeDef(nodeChoice);
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
   break;
  }
  return null;
 }
/*
 * 产生式 < baseType > ::=  INTEGER | CHAR
 */
 public Node newBaseType() {
  NodeChoice nodeChoice = null;
  NodeToken nodeToken = null;
  switch (expected.getLex()) {
  case LexType.INTEGER:
   nodeToken = new NodeToken(expected.getSem(), LexType.INTEGER,
     expected.getLineNum());
   expected = scanner.getNextToken();
   nodeChoice = new NodeChoice(nodeToken, 1);
   return builder.buildBaseType(nodeChoice);
  case LexType.CHAR:
   nodeToken = new NodeToken(expected.getSem(), LexType.CHAR, expected
     .getLineNum());
   expected = scanner.getNextToken();
   nodeChoice = new NodeChoice(nodeToken, 2);
   return builder.buildBaseType(nodeChoice);
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;

 }
/*
 * 产生式 < structureType > ::=  arrayType | recType
 */
 public Node newStructureType() {

  NodeChoice nodeChoice = null;
  switch (expected.getLex()) {
  case LexType.ARRAY:
   ArrayType arrayType = (ArrayType) newArrayType();
   nodeChoice = new NodeChoice(arrayType, 1);
   return builder.buildStructureType(nodeChoice);
  case LexType.RECORD:
   RecType recType = (RecType) newRecType();
   nodeChoice = new NodeChoice(recType, 2);
   return builder.buildStructureType(nodeChoice);
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
   break;
  }
  return null;

 }
/*
 * 产生式 < arrayType > ::=  ARRAY [low..top] OF baseType
 */
 public Node newArrayType() {
  NodeToken nodeToken1 = null, nodeToken2 = null, nodeToken3 = null, nodeToken4 = null, nodeToken5 = null;

  if (match(expected, LexType.ARRAY)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.ARRAY,
     expected.getLineNum());
   expected = scanner.getNextToken();
   if (match(expected, LexType.LMIDPAREN)) {
    nodeToken2 = new NodeToken(expected.getSem(),
      LexType.LMIDPAREN, expected.getLineNum());
    expected = scanner.getNextToken();
   }
   Low low = (Low) newLow();

   if (match(expected, LexType.UNDERANGE)) {
    nodeToken3 = new NodeToken(expected.getSem(),
      LexType.UNDERANGE, expected.getLineNum());
    expected = scanner.getNextToken();
   }

   Top top = (Top) newTop();

   if (match(expected, LexType.RMIDPAREN)) {
    nodeToken4 = new NodeToken(expected.getSem(),
      LexType.RMIDPAREN, expected.getLineNum());
    expected = scanner.getNextToken();
   }

   if (match(expected, LexType.OF)) {
    nodeToken5 = new NodeToken(expected.getSem(), LexType.OF,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }

   BaseType baseType = (BaseType) newBaseType();

   return builder.buildArrayType(nodeToken1, nodeToken2, low,
     nodeToken3, top, nodeToken4, nodeToken5, baseType);

  }

  return null;

 }
/*
 *  产生式 Low ::= INTC
 */
 public Node newLow() {
  NodeToken nodeToken = null;
  if (match(expected, LexType.INTC)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.INTC, expected
     .getLineNum());
   expected = scanner.getNextToken();
   return builder.buildLow(nodeToken);
  }
  return null;
 }
/*
 * 产生式Top ::= INTC
 */
 public Node newTop() {
  NodeToken nodeToken = null;
  if (match(expected, LexType.INTC)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.INTC, expected
     .getLineNum());
   expected = scanner.getNextToken();
   return builder.buildTop(nodeToken);
  }
  return null;
 }
/*
 * 产生式 < recType > ::=  RECORD fieldDecList END
 */
 public Node newRecType() {
  NodeToken nodeToken1 = null, nodeToken2 = null;

  if (match(expected, LexType.RECORD)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.RECORD,
     expected.getLineNum());
   expected = scanner.getNextToken();
   FieldDecList fieldDecList = (FieldDecList) newFieldDecList();

   if (match(expected, LexType.END)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.END,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }

   return builder.buildRecType(nodeToken1, fieldDecList, nodeToken2);
  }

  return null;
 }
/*
 * 产生式 < fieldDecList > ::=   baseType idList ; fieldDecMore   
 *                             | arrayType idList; fieldDecMore
 */
 public Node newFieldDecList() {
  NodeToken nodeToken = null;
  FieldDecMore fieldDecMore = null;
  IdList idList = null;
  NodeList nodeList = new NodeList();

  switch (expected.getLex()) {
  case LexType.INTEGER:
  case LexType.CHAR:
   BaseType baseType = (BaseType) newBaseType();
   nodeList.addNode(baseType);

   idList = (IdList) newIdList();
   nodeList.addNode(idList);

   if (match(expected, LexType.SEMI)) {
    nodeToken = new NodeToken(expected.getSem(), LexType.SEMI,
      expected.getLineNum());
    expected = scanner.getNextToken();
    nodeList.addNode(nodeToken);
   }
   fieldDecMore = (FieldDecMore) newFieldDecMore();
   nodeList.addNode(fieldDecMore);
   return builder.buildFieldDecList(nodeList);
  case LexType.ARRAY:
   ArrayType arrayType = (ArrayType) newArrayType();
   nodeList.addNode(arrayType);

   idList = (IdList) newIdList();
   nodeList.addNode(idList);

   if (match(expected, LexType.SEMI)) {
    nodeToken = new NodeToken(expected.getSem(), LexType.SEMI,
      expected.getLineNum());
    expected = scanner.getNextToken();
    nodeList.addNode(nodeToken);
   }
   fieldDecMore = (FieldDecMore) newFieldDecMore();
   nodeList.addNode(fieldDecMore);
   return builder.buildFieldDecList(nodeList);
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
   break;
  }
  return null;

 }
 /*
  * 产生式 < fieldDecMore > ::=  ε | fieldDecList
  */
 public Node newFieldDecMore() {
  NodeOptional nodeOptional = new NodeOptional();
  switch (expected.getLex()) {
  case LexType.INTEGER:
  case LexType.ARRAY:
  case LexType.CHAR:
   FieldDecList fieldDecList = (FieldDecList) newFieldDecList();
   nodeOptional.addNode(fieldDecList);
   return builder.buildFieldDecMore(nodeOptional);
  case LexType.END:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
 /*
  * 产生式 < idList > ::=  id  idMore
  */
 public Node newIdList() {
  NodeToken nodeToken = null;

  if (match(expected, LexType.ID)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.ID, expected
     .getLineNum());
   expected = scanner.getNextToken();
   IdMore idMore = (IdMore) newIdMore();
   return builder.buildIdList(nodeToken, idMore);
  }
  return null;
 }
/*
 * 产生式 < idMore > ::=  ε |  , idList
 */
 public Node newIdMore() {
  NodeListOptional nodeListOptional = new NodeListOptional();
  NodeToken nodeToken = null;
  if (expected.getLex() == LexType.COMMA) {
   nodeToken = new NodeToken(expected.getSem(), LexType.COMMA,
     expected.getLineNum());
   expected = scanner.getNextToken();
   nodeListOptional.addNode(nodeToken);
   IdList idList = (IdList) newIdList();
   nodeListOptional.addNode(idList);
   return builder.buildIdMore(nodeListOptional);
  } else if (expected.getLex() == LexType.SEMI) {

  } else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }

  return null;
 }
 /*
  * 产生式 < varDecPart > ::=  ε |  varDec
  */
 public Node newVarDecPart() {
  NodeOptional nodeOptional = new NodeOptional();
  switch (expected.getLex()) {
  case LexType.VAR:
   VarDec varDec = (VarDec) newVarDec();
   nodeOptional.addNode(varDec);
   return builder.buildVarDecPart(nodeOptional);
  case LexType.PROCEDURE:
  case LexType.BEGIN:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
 /*
  * 产生式 < varDec> ::=  VAR  varDecList
  */
 public Node newVarDec() {
  NodeToken nodeToken = null;
  if (match(expected, LexType.VAR)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.VAR, expected
     .getLineNum());
   expected = scanner.getNextToken();
   VarDecList varDecList = (VarDecList) newVarDecList();
   return builder.buildVarDec(nodeToken, varDecList);
  }
  return null;
 }
 /*
  * < varDecList > ::=  typeName varIdList; varDecMore
  */
 public Node newVarDecList() {
  NodeToken nodeToken = null;
  TypeDef typeDef = null;
  VarIdList varIdList = null;

  if (expected.getLex() == LexType.INTEGER
    || expected.getLex() == LexType.CHAR
    || expected.getLex() == LexType.ARRAY
    || expected.getLex() == LexType.RECORD
    || expected.getLex() == LexType.ID) {
   typeDef = (TypeDef) newTypeDef();
   varIdList = (VarIdList) newVarIdList();
   if (match(expected, LexType.SEMI)) {
    nodeToken = new NodeToken(expected.getSem(), LexType.SEMI,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }
   VarDecMore varDecMore = (VarDecMore) newVarDecMore();

   return builder.buildVarDecList(typeDef, varIdList, nodeToken,
     varDecMore);
  }
  return null;
 }
/*
 * 产生式 < varDecMore > ::=  ε |  varDecList
 */
 public Node newVarDecMore() {
  NodeOptional nodeOptional = new NodeOptional();
  switch (expected.getLex()) {
  case LexType.INTEGER:
  case LexType.CHAR:
  case LexType.ARRAY:
  case LexType.ID:
  case LexType.RECORD:
   VarDecList varDecList = (VarDecList) newVarDecList();
   nodeOptional.addNode(varDecList);
   return builder.buildVarDecMore(nodeOptional);
  case LexType.PROCEDURE:
  case LexType.BEGIN:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
 /*
  *  产生式 < varIdList > ::=  id  varIdMore 
  */
 public Node newVarIdList() {
  NodeToken nodeToken = null;

  if (match(expected, LexType.ID)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.ID, expected
     .getLineNum());
   expected = scanner.getNextToken();
   VarIdMore varIdMore = (VarIdMore) newVarIdMore();

   return builder.buildVarIdList(nodeToken, varIdMore);
  }
  return null;
 }
/*
 * 产生式 < varIdMore > ::=  ε |  , varIdList
 */
 public Node newVarIdMore() {
  NodeListOptional nodeListOptional = new NodeListOptional();
  switch (expected.getLex()) {
  case LexType.COMMA:
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.COMMA, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeListOptional.addNode(nodeToken);

   VarIdList varIdList = (VarIdList) newVarIdList();
   nodeListOptional.addNode(varIdList);
   return builder.buildVarIdMore(nodeListOptional);
  case LexType.SEMI:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
 * < procDec> ::=  PROCEDURE                       
 *                 ProcName(paramList);            
 *                 procDecPart                     
 *                 procBody                        
 *                 procDec
 */
 public Node newProcDec() {

  NodeToken nodeToken1 = null, nodeToken2 = null, nodeToken3 = null, nodeToken4 = null;
  ProcName procName = null;
  ParamList paramList = null;

  if (match(expected, LexType.PROCEDURE)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.PROCEDURE,
     expected.getLineNum());
   expected = scanner.getNextToken();

   procName = (ProcName) newProcName();

   if (match(expected, LexType.LPAREN)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.LPAREN,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }

   paramList = (ParamList) newParamList();
   if (match(expected, LexType.RPAREN)) {
    nodeToken3 = new NodeToken(expected.getSem(), LexType.RPAREN,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }

   if (match(expected, LexType.SEMI)) {
    nodeToken4 = new NodeToken(expected.getSem(), LexType.SEMI,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }

   ProcDecPart procDecPart = (ProcDecPart) newProcDecPart();
   ProcBody procBody = (ProcBody) newProcBody();
   ProcDecMore procDecMore = (ProcDecMore) newProcDecMore();

   return builder.buildProcDec(nodeToken1, procName, nodeToken2,
     paramList, nodeToken3, nodeToken4, procDecPart, procBody,
     procDecMore);
  }
  return null;

 }
/*
 * ProcDecPart ::= DeclarePart
 */
 public Node newProcDecPart() {
  switch (expected.getLex()) {
  case LexType.TYPE:
  case LexType.VAR:
  case LexType.PROCEDURE:
  case LexType.BEGIN:
   DeclarePart declarePart = (DeclarePart) newDeclarePart();
   return builder.buildProcDecPart(declarePart);
  default:
   return null;
  }
 }
/*
 * 产生式ProcDecMore ::= ε | ,VarIdList
 */
 public Node newProcDecMore() {
  NodeOptional nodeOptional = new NodeOptional();
  switch (expected.getLex()) {
  case LexType.PROCEDURE:
   ProcDec procDec = (ProcDec) newProcDec();
   nodeOptional.addNode(procDec);
   return builder.buildProcDecMore(nodeOptional);
  case LexType.BEGIN:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
 * 产生式 ProcName ::= ID
 */
 public Node newProcName() {
  NodeToken nodeToken = null;

  if (match(expected, LexType.ID)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.ID, expected
     .getLineNum());
   expected = scanner.getNextToken();
   return builder.buildProcName(nodeToken);
  }
  return null;
 }
/*
 * 产生式 < paramList > ::=  ε |  paramDecList
 */
 public Node newParamList() {
  NodeOptional nodeOptional = new NodeOptional();
  switch (expected.getLex()) {
  case LexType.INTEGER:
  case LexType.CHAR:
  case LexType.ARRAY:
  case LexType.RECORD:
  case LexType.ID:
  case LexType.VAR:
   ParamDecList paramDecList = (ParamDecList) newParamDecList();
   nodeOptional.addNode(paramDecList);
   return builder.buildParamList(nodeOptional);
  case LexType.LPAREN:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
 *  产生式 < paramDecList > ::=  param  paramMore
 */
 public Node newParamDecList() {
  switch (expected.getLex()) {
  case LexType.INTEGER:
  case LexType.CHAR:
  case LexType.ARRAY:
  case LexType.RECORD:
  case LexType.ID:
  case LexType.VAR:
   Param param = (Param) newParam();
   ParamMore paramMore = (ParamMore) newParamMore();

   return builder.buildParamDecList(param, paramMore);
  default:
   return null;
  }
 }
/*
 * 产生式 < paramMore > ::=  ε | ; paramDecList
 */
 public Node newParamMore() {
  NodeListOptional nodeListOptional = new NodeListOptional();
  if (expected.getLex() == LexType.SEMI) {
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.SEMI, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeListOptional.addNode(nodeToken);

   ParamList paramList = (ParamList) newParamList();
   nodeListOptional.addNode(paramList);
   return builder.buildParamMore(nodeListOptional);
  } else if (expected.getLex() == LexType.RPAREN) {

  } else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;

 }
/*
 * 产生式 < param > ::=  typeName formList | VAR typeName formList
 */
 public Node newParam() {
  NodeList nodeList = new NodeList();
  TypeDef typeDef = null;
  FormList formList = null;

  switch (expected.getLex()) {
  case LexType.INTEGER:
  case LexType.CHAR:
  case LexType.ARRAY:
  case LexType.RECORD:
  case LexType.ID:
   typeDef = (TypeDef) newTypeDef();
   nodeList.addNode(typeDef);
   formList = (FormList) newFormList();
   nodeList.addNode(formList);
   return builder.buildParam(nodeList);
  case LexType.VAR:
   NodeToken nodeToken = new NodeToken(expected.getSem(), LexType.VAR,
     expected.getLineNum());
   expected = scanner.getNextToken();
   nodeList.addNode(nodeToken);

   typeDef = (TypeDef) newTypeDef();
   nodeList.addNode(typeDef);
   formList = (FormList) newFormList();
   nodeList.addNode(formList);
   return builder.buildParam(nodeList);
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
 * 产生式 < formList > ::=  id  fidMore
 */
 public Node newFormList() {
  NodeToken nodeToken = null;
  FidMore fidMore = null;

  if (match(expected, LexType.ID)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.ID, expected
     .getLineNum());
   expected = scanner.getNextToken();
   fidMore = (FidMore) newFidMore();
   return builder.buildFormList(nodeToken, fidMore);
  }
  return null;
 }
/*
 * 产生式 < fidMore > ::=   ε |  , formList
 */
 public Node newFidMore() {
  NodeListOptional nodeListOptional = new NodeListOptional();

  if (expected.getLex() == LexType.COMMA) {
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.COMMA, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeListOptional.addNode(nodeToken);

   FormList formList = (FormList) newFormList();
   nodeListOptional.addNode(formList);
   return builder.buildFidMore(nodeListOptional);
  } else if (expected.getLex() == LexType.SEMI
    || expected.getLex() == LexType.RPAREN) {
  } else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;

 }
/*
 * 产生式 < procBody > ::=  programBody
 */
 public Node newProcBody() {
  if (expected.getLex() == LexType.BEGIN) {
   ProgramBody programBody = (ProgramBody) newProgramBody();
   return builder.buildProcBody(programBody);
  }
  return null;
 }
/*
 *  产生式 < programBody > ::=  BEGIN  stmList   END
 */
 public Node newProgramBody() {
  NodeToken nodeToken1 = null, nodeToken2 = null;
  StmList stmList = null;
  if (match(expected, LexType.BEGIN)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.BEGIN,
     expected.getLineNum());
   expected = scanner.getNextToken();
   stmList = (StmList) newStmList();

   if (match(expected, LexType.END)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.END,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }
   return builder.buildProgramBody(nodeToken1, stmList, nodeToken2);
  }
  return null;
 }
/*
 * 产生式 < stmList > ::=  stm    stmMore  
 */
 public Node newStmList() {
  switch (expected.getLex()) {
  case LexType.ID:
  case LexType.IF:
  case LexType.WHILE:
  case LexType.RETURN:
  case LexType.READ:
  case LexType.WRITE:
   Stm stm = (Stm) newStm();
   StmMore stmMore = (StmMore) newStmMore();
   return builder.buildStmList(stm, stmMore);
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
 *  产生式 < stmMore > ::=   ε |  ; stmList
 */
 public Node newStmMore() {
  NodeListOptional nodeListOptional = new NodeListOptional();
  if (expected.getLex() == LexType.SEMI) {
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.SEMI, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeListOptional.addNode(nodeToken);

   StmList stmList = (StmList) newStmList();
   nodeListOptional.addNode(stmList);
   return builder.buildStmMore(nodeListOptional);
  } else if (expected.getLex() == LexType.ELSE
    || expected.getLex() == LexType.FI
    || expected.getLex() == LexType.END
    || expected.getLex() == LexType.ENDWH) {

  } else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
/* 产生式 < stm > ::=   conditionalStm   {IF}                      
/*                    | loopStm          {WHILE}                   
/*                    | inputStm         {READ}                    
/*                    | outputStm        {WRITE}                   
/*                    | returnStm        {RETURN}                 
/*                    | id  assCall      {id}  
 */
 public Node newStm() {
  NodeList nodeList = new NodeList();
  switch (expected.getLex()) {
  case LexType.IF:
   ConditionalStm conditionalStm = (ConditionalStm) newConditionalStm();
   nodeList.addNode(conditionalStm);
   return builder.buildStm(nodeList);
  case LexType.WHILE:
   LoopStm loopStm = (LoopStm) newLoopStm();
   nodeList.addNode(loopStm);
   return builder.buildStm(nodeList);
  case LexType.READ:
   InputStm inputStm = (InputStm) newInputStm();
   nodeList.addNode(inputStm);
   return builder.buildStm(nodeList);
  case LexType.WRITE:
   OutputStm outputStm = (OutputStm) newOutputStm();
   nodeList.addNode(outputStm);
   return builder.buildStm(nodeList);
  case LexType.RETURN:
   ReturnStm returnStm = (ReturnStm) newReturnStm();
   nodeList.addNode(returnStm);
   return builder.buildStm(nodeList);
  case LexType.ID:
   NodeToken nodeToken = new NodeToken(expected.getSem(), LexType.ID,
     expected.getLineNum());
   expected = scanner.getNextToken();
   nodeList.addNode(nodeToken);

   AssCall assCall = (AssCall) newAssCall();
   nodeList.addNode(assCall);
   return builder.buildStm(nodeList);
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;

 }
/*
 * 产生式 < assCall > ::=   assignmentRest   {:=,LMIDPAREN,DOT}    
 *                        | callStmRest     {(}  
 */
 public Node newAssCall() {
  NodeChoice nodeChoice = null;
  switch (expected.getLex()) {
  case LexType.ASSIGN:
  case LexType.LMIDPAREN:
  case LexType.DOT:
   AssignmentRest assignmentRest = (AssignmentRest) newAssignmentRest();
   nodeChoice = new NodeChoice(assignmentRest, 1);
   return builder.buildAssCall(nodeChoice);
  case LexType.LPAREN:
   CallStmRest callStmRest = (CallStmRest) newCallStmRest();
   nodeChoice = new NodeChoice(callStmRest, 2);
   return builder.buildAssCall(nodeChoice);
  default:
   break;
  }
  return null;
 }
/*
 * 产生式 < assignmentRest > ::=  variMore : = exp
 */
 public Node newAssignmentRest() {
  NodeToken nodeToken = null;
  VariMore variMore = null;
  Exp exp = null;
  switch (expected.getLex()) {
  case LexType.LMIDPAREN:
  case LexType.DOT:
  case LexType.ASSIGN:
   variMore = (VariMore) newVariMore();
   if (match(expected, LexType.ASSIGN)) {
    nodeToken = new NodeToken(expected.getSem(), LexType.ASSIGN,
      expected.getLineNum());
    expected = scanner.getNextToken();

   }
   exp = (Exp) newExp();
   return builder.buildAssignmentRest(variMore, nodeToken, exp);
  default:
   return null;
  }
 }
/*
 * 产生式 < conditionalStm > ::= IF exp THEN stmList ELSE stmList FI
 */
 public Node newConditionalStm() {
  NodeToken nodeToken1 = null, nodeToken2 = null, nodeToken3 = null, nodeToken4 = null;
  RelExp relExp;
  StmList stmList1, stmList2;

  if (match(expected, LexType.IF)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.IF, expected
     .getLineNum());
   expected = scanner.getNextToken();

   relExp = (RelExp) newRelExp();

   if (match(expected, LexType.THEN)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.THEN,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }
   stmList1 = (StmList) newStmList();

   if (match(expected, LexType.ELSE)) {
    nodeToken3 = new NodeToken(expected.getSem(), LexType.ELSE,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }

   stmList2 = (StmList) newStmList();

   if (match(expected, LexType.FI)) {
    nodeToken4 = new NodeToken(expected.getSem(), LexType.FI,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }
   return builder.buildConditonalStm(nodeToken1, relExp, nodeToken2,
     stmList1, nodeToken3, stmList2, nodeToken4);
  }
  return null;
 }
/*
 *  产生式 < loopStm > ::=      WHILE exp DO stmList ENDWH
 */
 public Node newLoopStm() {
  NodeToken nodeToken1 = null, nodeToken2 = null, nodeToken3 = null;
  RelExp relExp;
  StmList stmList;

  if (match(expected, LexType.WHILE)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.WHILE,
     expected.getLineNum());
   expected = scanner.getNextToken();
   relExp = (RelExp) newRelExp();

   if (match(expected, LexType.DO)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.WHILE,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }

   stmList = (StmList) newStmList();

   if (match(expected, LexType.ENDWH)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.ENDWH,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }
   return builder.buildLoopStm(nodeToken1, relExp, nodeToken2,
     stmList, nodeToken3);
  }
  return null;
 }
/*
 * 产生式 < inputStm > ::=    READ(id)
 */
 public Node newInputStm() {
  NodeToken nodeToken1 = null, nodeToken2 = null, nodeToken3 = null;
  InVar inVar;

  if (match(expected, LexType.READ)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.READ,
     expected.getLineNum());
   expected = scanner.getNextToken();
   if (match(expected, LexType.LPAREN)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.LPAREN,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }

   inVar = (InVar) newInVar();

   if (match(expected, LexType.RPAREN)) {
    nodeToken3 = new NodeToken(expected.getSem(), LexType.RPAREN,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }
   return builder.buildInputStm(nodeToken1, nodeToken2, inVar,
     nodeToken3);
  }
  return null;
 }
/*
 * 产生式 InVar ::= ID
 */
 public Node newInVar() {
  NodeToken nodeToken = null;

  if (match(expected, LexType.ID)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.ID, expected
     .getLineNum());
   expected = scanner.getNextToken();
   return builder.buildInVar(nodeToken);
  }
  return null;
 }
 /*
  * 产生式 < outputStm > ::=   WRITE(exp)
  */

 public Node newOutputStm() {
  NodeToken nodeToken1 = null, nodeToken2 = null, nodeToken3 = null;
  Exp exp;

  if (match(expected, LexType.WRITE)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.WRITE,
     expected.getLineNum());
   expected = scanner.getNextToken();
   if (match(expected, LexType.LPAREN)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.LPAREN,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }
   exp = (Exp) newExp();

   if (match(expected, LexType.RPAREN)) {
    nodeToken3 = new NodeToken(expected.getSem(), LexType.RPAREN,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }
   return builder.buildOutputStm(nodeToken1, nodeToken2, exp,
     nodeToken3);
  }
  return null;
 }
 /*
  * 产生式 < returnStm > ::=   RETURN
  */
 public Node newReturnStm() {
  NodeToken nodeToken = null;

  if (match(expected, LexType.RETURN)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.RETURN,
     expected.getLineNum());
   expected = scanner.getNextToken();
   return builder.buildReturnStm(nodeToken);
  }
  return null;
 }
 /*
  * 产生式 < callStmRest > ::=  (actParamList)
  */
 public Node newCallStmRest() {
  NodeToken nodeToken1 = null, nodeToken2 = null;

  if (match(expected, LexType.LPAREN)) {
   nodeToken1 = new NodeToken(expected.getSem(), LexType.LPAREN,
     expected.getLineNum());
   expected = scanner.getNextToken();
   ActParamList actParamList = (ActParamList) newActParamList();

   if (match(expected, LexType.RPAREN)) {
    nodeToken2 = new NodeToken(expected.getSem(), LexType.RPAREN,
      expected.getLineNum());
    expected = scanner.getNextToken();
   }
   return builder.buildCallStmRest(nodeToken1, actParamList,
     nodeToken2);
  }
  return null;
 }
 /*
  *
  * 产生式 < actParamList > ::=     ε |  exp actParamMore
  *
  */
 public Node newActParamList() {
  NodeListOptional nodeListOptional = new NodeListOptional();

  switch (expected.getLex()) {
  case LexType.LPAREN:
  case LexType.INTC:
  case LexType.ID:
   Exp exp = (Exp) newExp();
   nodeListOptional.addNode(exp);
   ActParamMore actParamMore = (ActParamMore) newActParamMore();
   nodeListOptional.addNode(actParamMore);
   return builder.buildActParamList(nodeListOptional);
  case LexType.RPAREN:
   break;
  default:
   break;
  }
  return null;
 }
 /*
  * 产生式ActParamMore ::= ε  |,ActParamList
  */
 public Node newActParamMore() {
  NodeListOptional nodeListOptional = new NodeListOptional();

  if (expected.getLex() == LexType.COMMA) {
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.COMMA, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeListOptional.addNode(nodeToken);

   ActParamList actParamList = (ActParamList) newActParamList();
   nodeListOptional.addNode(actParamList);
   return builder.buildActParamMore(nodeListOptional);
  } else if (expected.getLex() == LexType.RPAREN) {

  } else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
 * 产生式RelExp := Exp OtherRelE
 */
 public Node newRelExp() {
  switch (expected.getLex()) {
  case LexType.LPAREN:
  case LexType.INTC:
  case LexType.ID:
   Exp exp = (Exp) newExp();
   OtherRelE otherRelE = (OtherRelE) newOtherRelE();

   return builder.buildRelExp(exp, otherRelE);
  default:
   return null;
  }
 }
/*
 * 产生式OtherRelE := CmpOp Exp
 */
 public Node newOtherRelE() {
  switch (expected.getLex()) {
  case LexType.LT:
  case LexType.EQ:
   CmpOp cmpOp = (CmpOp) newCmpOp();
   Exp exp = (Exp) newExp();
   return builder.buildOtherRelE(cmpOp, exp);
  default:
   return null;
  }
 }
/*
 * 产生式Exp := Term OtherTerm
 */
 public Node newExp() {
  switch (expected.getLex()) {
  case LexType.LPAREN:
  case LexType.INTC:
  case LexType.ID:
   Term term = (Term) newTerm();
   OtherTerm otherTerm = (OtherTerm) newOtherTerm();
   return builder.buildExp(term, otherTerm);
  default:
   return null;
  }
 }
/*
 * 产生式OtherTerm := ε | AddOp Exp
 */
 public Node newOtherTerm() {
  NodeListOptional nodeListOptional = new NodeListOptional();

  switch (expected.getLex()) {
  case LexType.PLUS:
  case LexType.MINUS:
   AddOp addOp = (AddOp) newAddOp();
   nodeListOptional.addNode(addOp);
   Exp exp = (Exp) newExp();
   nodeListOptional.addNode(exp);
   return builder.buildOtherTerm(nodeListOptional);
  case LexType.LT:
  case LexType.EQ:
  case LexType.RMIDPAREN:
  case LexType.THEN:
  case LexType.ELSE:
  case LexType.FI:
  case LexType.DO:
  case LexType.ENDWH:
  case LexType.RPAREN:
  case LexType.END:
  case LexType.SEMI:
  case LexType.COMMA:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));

  }
  return null;
 }
/*
 * 产生式Term := Factor OtherFactor
 */
 public Node newTerm() {
  switch (expected.getLex()) {
  case LexType.LPAREN:
  case LexType.INTC:
  case LexType.ID:
   Factor factor = (Factor) newFactor();
   OtherFactor otherFactor = (OtherFactor) newOtherFactor();
   return builder.buildTerm(factor, otherFactor);
  default:
   return null;
  }

 }
/*
 * 产生式 OtherFactor := ε | MultOp Term
 */
 public Node newOtherFactor() {
  NodeListOptional nodeListOptional = new NodeListOptional();

  switch (expected.getLex()) {
  case LexType.OVER:
  case LexType.TIMES:
   MultOp multOp = (MultOp) newMultOp();
   Term term = (Term) newTerm();
   nodeListOptional.addNode(multOp);
   nodeListOptional.addNode(term);
   return builder.buildOtherFactor(nodeListOptional);
  case LexType.PLUS:
  case LexType.MINUS:
  case LexType.LT:
  case LexType.EQ:
  case LexType.RMIDPAREN:
  case LexType.THEN:
  case LexType.ELSE:
  case LexType.FI:
  case LexType.DO:
  case LexType.ENDWH:
  case LexType.RPAREN:
  case LexType.END:
  case LexType.SEMI:
  case LexType.COMMA:
   break;
  default:
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
 * 产生式Factor ::=(Exp) | INTC | Variable
 */
 public Node newFactor() {
  NodeList nodeList = new NodeList();

  if (expected.getLex() == LexType.LPAREN) {
   NodeToken nodeToken1 = new NodeToken(expected.getSem(),
     LexType.LPAREN, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeList.addNode(nodeToken1);

   Exp exp = (Exp) newExp();
   nodeList.addNode(exp);

   if (match(expected, LexType.RPAREN)) {
    NodeToken nodeToken2 = new NodeToken(expected.getSem(),
      LexType.RPAREN, expected.getLineNum());
    expected = scanner.getNextToken();
    nodeList.addNode(nodeToken2);
   }
   return builder.buildFactor(nodeList);
  } else if (expected.getLex() == LexType.INTC) {
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.INTC, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeList.addNode(nodeToken);
   return builder.buildFactor(nodeList);
  } else if (expected.getLex() == LexType.ID) {
   Variable variable = (Variable) newVariable();
   nodeList.addNode(variable);
   return builder.buildFactor(nodeList);
  }
  return null;
 }
/*
 * 产生式Variable ::= ID VariMore
 */
 public Node newVariable() {
  NodeToken nodeToken = null;
  VariMore variMore = null;

  if (match(expected, LexType.ID)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.ID, expected
     .getLineNum());
   expected = scanner.getNextToken();
   variMore = (VariMore) newVariMore();
   return builder.buildVariable(nodeToken, variMore);
  }
  return null;
 }
/*
 * 产生式 VariMore ::= ε | [Exp] |.FieldVar
 */
 public Node newVariMore() {
  NodeListOptional nodeListOptional = new NodeListOptional();

  if (expected.getLex() == LexType.LMIDPAREN) {
   NodeToken nodeToken1 = new NodeToken(expected.getSem(),
     LexType.LMIDPAREN, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeListOptional.addNode(nodeToken1);

   Exp exp = (Exp) newExp();
   nodeListOptional.addNode(exp);

   if (match(expected, LexType.RMIDPAREN)) {
    NodeToken nodeToken2 = new NodeToken(expected.getSem(),
      LexType.RMIDPAREN, expected.getLineNum());
    expected = scanner.getNextToken();
    nodeListOptional.addNode(nodeToken2);
   }
   return builder.buildVariMore(nodeListOptional);
  } else if (expected.getLex() == LexType.DOT) {
   NodeToken nodeToken = new NodeToken(expected.getSem(), LexType.DOT,
     expected.getLineNum());
   expected = scanner.getNextToken();
   nodeListOptional.addNode(nodeToken);

   FieldVar fieldVar = (FieldVar) newFieldVar();
   nodeListOptional.addNode(fieldVar);
   return builder.buildVariMore(nodeListOptional);
  } else if (expected.getLex() == LexType.ASSIGN
    || expected.getLex() == LexType.TIMES
    || expected.getLex() == LexType.OVER
    || expected.getLex() == LexType.PLUS
    || expected.getLex() == LexType.MINUS
    || expected.getLex() == LexType.LT
    || expected.getLex() == LexType.EQ
    || expected.getLex() == LexType.THEN
    || expected.getLex() == LexType.ELSE
    || expected.getLex() == LexType.FI
    || expected.getLex() == LexType.DO
    || expected.getLex() == LexType.RMIDPAREN
    || expected.getLex() == LexType.ENDWH
    || expected.getLex() == LexType.RPAREN
    || expected.getLex() == LexType.END
    || expected.getLex() == LexType.SEMI
    || expected.getLex() == LexType.COMMA) {

  } else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }

  return null;
 }
/*
 * 产生式FieldVar ::= ID FieldVarMore
 */
 public Node newFieldVar() {
  NodeToken nodeToken = null;

  if (match(expected, LexType.ID)) {
   nodeToken = new NodeToken(expected.getSem(), LexType.ID, expected
     .getLineNum());
   expected = scanner.getNextToken();
   FieldVarMore fieldVarMore = (FieldVarMore) newFieldVarMore();
   return builder.buildFieldVar(nodeToken, fieldVarMore);
  }
  return null;
 }
/*
 * 产生式FieldVarMore ::= ε | [Exp]
 */
 public Node newFieldVarMore() {
  NodeListOptional nodeListOptional = new NodeListOptional();

  if (expected.getLex() == LexType.LMIDPAREN) {
   NodeToken nodeToken1 = new NodeToken(expected.getSem(),
     LexType.LMIDPAREN, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeListOptional.addNode(nodeToken1);
   Exp exp = (Exp) newExp();
   nodeListOptional.addNode(exp);

   if (match(expected, LexType.RMIDPAREN)) {
    NodeToken nodeToken2 = new NodeToken(expected.getSem(),
      LexType.RMIDPAREN, expected.getLineNum());
    expected = scanner.getNextToken();
    nodeListOptional.addNode(nodeToken2);
   }
   return builder.buildFieldVarMore(nodeListOptional);
  } else if (expected.getLex() == LexType.ASSIGN
    || expected.getLex() == LexType.TIMES
    || expected.getLex() == LexType.OVER
    || expected.getLex() == LexType.PLUS
    || expected.getLex() == LexType.MINUS
    || expected.getLex() == LexType.LT
    || expected.getLex() == LexType.EQ
    || expected.getLex() == LexType.THEN
    || expected.getLex() == LexType.ELSE
    || expected.getLex() == LexType.FI
    || expected.getLex() == LexType.DO
    || expected.getLex() == LexType.ENDWH
    || expected.getLex() == LexType.RPAREN
    || expected.getLex() == LexType.END
    || expected.getLex() == LexType.SEMI
    || expected.getLex() == LexType.COMMA) {

  } else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
  }
  return null;
 }
/*
 * 产生式CompOp ::= < | =
 */
 public Node newCmpOp() {
  NodeChoice nodeChoice = null;

  if (expected.getLex() == LexType.LT) {
   NodeToken nodeToken = new NodeToken(expected.getSem(), LexType.LT,
     expected.getLineNum());
   expected = scanner.getNextToken();
   nodeChoice = new NodeChoice(nodeToken, 1);
   return builder.buildCmpOp(nodeChoice);
  } else if (expected.getLex() == LexType.EQ) {
   NodeToken nodeToken = new NodeToken(expected.getSem(), LexType.EQ,
     expected.getLineNum());
   expected = scanner.getNextToken();
   nodeChoice = new NodeChoice(nodeToken, 2);
   return builder.buildCmpOp(nodeChoice);
  }
  return null;
 }
/*
 * 产生式AddOp ::= + | -
 */
 public Node newAddOp() {
  NodeChoice nodeChoice = null;

  if (expected.getLex() == LexType.PLUS) {
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.PLUS, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeChoice = new NodeChoice(nodeToken, 1);
   return builder.buildAddOp(nodeChoice);
  } else if (expected.getLex() == LexType.MINUS) {
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.MINUS, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeChoice = new NodeChoice(nodeToken, 2);
   return builder.buildAddOp(nodeChoice);
  }
  return null;
 }
/*
 * 产生式MultOp ::= * | /
 */
 public Node newMultOp() {
  NodeChoice nodeChoice = null;

  if (expected.getLex() == LexType.TIMES) {
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.TIMES, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeChoice = new NodeChoice(nodeToken, 1);
   return builder.buildMultOp(nodeChoice);
  } else if (expected.getLex() == LexType.OVER) {
   NodeToken nodeToken = new NodeToken(expected.getSem(),
     LexType.OVER, expected.getLineNum());
   expected = scanner.getNextToken();
   nodeChoice = new NodeChoice(nodeToken, 2);
   return builder.buildMultOp(nodeChoice);
  }
  return null;
 }
 
   /*
 *功  能 终极符匹配处理函数          
 * 说  明 函数参数expected给定期望单词符号与当前单词符号token相匹配 
 *        如果不匹配,则将非期望单词语法错误放入错误列表 
 *
 */  
 private boolean match(Token expected, int lexType) {
  if (expected.getLex() == lexType)
   return true;
  else {
   errorList.addError(new Error("Syntax Error>>>Unexpected token "
     + expected.getSem(), expected.getLineNum()));
   return false;
  }

 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < procBody > ::=  programBody
 */
public class ProcBody implements Node {
 public ProgramBody programBody;

 public ProcBody() {

 }

 public ProcBody(ProgramBody programBody) {
  this.programBody = programBody;
 }

 public void accept(Visitor v) {
  v.visitProcDecBody(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * < procDec> ::=  PROCEDURE                       
 *                 ProcName(paramList);            
 *                 procDecPart                     
 *                 procBody                        
 *                 procDec
 */
public class ProcDec implements Node {
 public NodeToken nodeToken1;

 public ProcName procName;

 public NodeToken nodeToken2;

 public ParamList paramList;

 public NodeToken nodeToken3;

 public NodeToken nodeToken4;

 public ProcDecPart procDecPart;

 public ProcBody procBody;

 public ProcDecMore procDecMore = null;

 public ProcDec() {

 }

 public ProcDec(NodeToken nodeToken1, ProcName procName,
   NodeToken nodeToken2, ParamList paramList, NodeToken nodeToken3,
   NodeToken nodeToken4, ProcDecPart procDecPart, ProcBody procBody,
   ProcDecMore procDecMore) {
  this.nodeToken1 = nodeToken1;
  this.procName = procName;
  this.nodeToken2 = nodeToken2;
  this.paramList = paramList;
  this.nodeToken3 = nodeToken3;
  this.nodeToken4 = nodeToken4;
  this.procDecPart = procDecPart;
  this.procBody = procBody;
  this.procDecMore = procDecMore;
 }

 public void accept(Visitor v) {
  v.visitProcDec(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

/*
 * ProcDeclarePart ::= ε | ProcDec
 */

public class ProcDeclarePart implements Node {

 public NodeOptional nodeOptional = new NodeOptional();

 public ProcDeclarePart() {
  nodeOptional = new NodeOptional();
 }

 public ProcDeclarePart(NodeOptional nodeOptional) {
  this.nodeOptional = nodeOptional;
 }

 public void accept(Visitor v) {
  v.visitProcDeclarePart(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式ProcDecMore ::= ε | ,VarIdList
 */
public class ProcDecMore implements Node {
 public NodeOptional nodeOptional;

 public ProcDecMore() {
  nodeOptional = new NodeOptional();
 }

 public ProcDecMore(NodeOptional nodeOptional) {
  this.nodeOptional = nodeOptional;
 }

 public void accept(Visitor v) {
  v.visitProcDecMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * ProcDecPart ::= DeclarePart
 */
public class ProcDecPart implements Node {
 public DeclarePart declarePart;

 public ProcDecPart() {

 }

 public ProcDecPart(DeclarePart declarePart) {
  this.declarePart = declarePart;
 }

 public void accept(Visitor v) {
  v.visitProcDecPart(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 ProcName ::= ID
 */
public class ProcName implements Node {
 public NodeToken nodeToken;

 public ProcName() {

 }

 public ProcName(NodeToken nodeToken) {
  this.nodeToken = nodeToken;
 }

 public void accept(Visitor v) {
  v.visitProcName(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

/*
 * 产生式 < program > ::= programHead declarePart programBody
 */
public class Program implements Node {
 public ProgramHeader programHeader;

 public DeclarePart declarePart;

 public ProgramBody programBody;

 public Program() {

 }

 public Program(ProgramHeader programHeader, DeclarePart declarePart,
   ProgramBody programBody) {
  this.programHeader = programHeader;
  this.declarePart = declarePart;
  this.programBody = programBody;
 }

 public void accept(Visitor v) {
  v.visitProgram(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 *  产生式 < programBody > ::=  BEGIN  stmList   END
 */
public class ProgramBody implements Node {

 public NodeToken nodeToken1;

 public StmList stmList;

 public NodeToken nodeToken2;

 public ProgramBody() {

 }

 public ProgramBody(NodeToken nodeToken1, StmList stmList,
   NodeToken nodeToken2) {
  this.nodeToken1 = nodeToken1;
  this.stmList = stmList;
  this.nodeToken2 = nodeToken2;
 }

 public void accept(Visitor v) {
  v.visitProgramBody(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 *产生式 < programHead > ::= PROGRAM  ProgramName
 */
public class ProgramHeader implements Node {
 public NodeToken nodeToken;

 public ProgramName programName;

 public ProgramHeader() {

 }

 public ProgramHeader(NodeToken nodeToken, ProgramName programName) {
  this.nodeToken = nodeToken;
  this.programName = programName;
 }

 public void accept(Visitor v) {
  v.visitProgramHeader(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式programName ::= ID
 */
public class ProgramName implements Node {
 public NodeToken nodeToken;

 public ProgramName(NodeToken nodeToken) {
  this.nodeToken = nodeToken;
 }

 public ProgramName() {
 }

 public void accept(Visitor v) {
  v.visitProgramName(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

public class ProgramNodeBuilder implements Builder{
 
 private Node treeRoot;
 public Node getTreeRoot(){
    return treeRoot; 
 }
 public Node buildActParamList(NodeListOptional nodeListOptional) {
  return new ActParamList(nodeListOptional);
 }

 public Node buildActParamMore(NodeListOptional nodeListOptional) {
  return new ActParamMore(nodeListOptional);
 }

 public Node buildAddOp(NodeChoice nodeChoice) {
  return new AddOp(nodeChoice);
 }

 public Node buildArrayType(NodeToken nodeToken1, NodeToken nodeToken2,
   Low low, NodeToken nodeToken3, Top top, NodeToken nodeToken4,
   NodeToken nodeToken5, BaseType baseType) {
  return new ArrayType(nodeToken1, nodeToken2, low, nodeToken3, top,
    nodeToken4, nodeToken5, baseType);
 }

 public Node buildAssCall(NodeChoice nodeChoice) {
  return new AssCall(nodeChoice);
 }

 public Node buildAssignmentRest(VariMore variMore, NodeToken nodeToken,
   Exp exp) {
  return new AssignmentRest(variMore, nodeToken, exp);
 }

 public Node buildBaseType(NodeChoice nodeChoice) {
  return new BaseType(nodeChoice);
 }

 public Node buildCallStmRest(NodeToken nodeToken1,
   ActParamList actParamList, NodeToken nodeToken2) {
  return new CallStmRest(nodeToken1, actParamList, nodeToken2);
 }

 public Node buildCmpOp(NodeChoice nodeChoice) {
  return new CmpOp(nodeChoice);
 }

 public Node buildConditonalStm(NodeToken nodeToken1, RelExp relExp,
   NodeToken nodeToken2, StmList stmList1, NodeToken nodeToken3,
   StmList stmList2, NodeToken nodeToken4) {
  return new ConditionalStm(nodeToken1, relExp, nodeToken2, stmList1,
    nodeToken3, stmList2, nodeToken4);
 }

 public Node buildDeclarePart(TypeDecPart typeDecPart,
   VarDecPart varDecPart, ProcDeclarePart procDeclarePart) {
  return new DeclarePart(typeDecPart, varDecPart, procDeclarePart);
 }

 public Node buildProcDeclarePart(NodeOptional nodeOptional) {
  return new ProcDeclarePart(nodeOptional);
 }

 public Node buildExp(Term term, OtherTerm otherTerm) {
  return new Exp(term, otherTerm);
 }

 public Node buildFactor(NodeList nodeList) {
  return new Factor(nodeList);
 }

 public Node buildFidMore(NodeListOptional nodeListOptional) {
  return new FidMore(nodeListOptional);
 }

 public Node buildFieldDecList(NodeList nodeList) {
  return new FieldDecList(nodeList);
 }

 public Node buildFieldDecMore(NodeOptional nodeOptional) {
  return new FieldDecMore(nodeOptional);
 }

 public Node buildFieldVar(NodeToken nodeToken, FieldVarMore fieldVarMore) {
  return new FieldVar(nodeToken, fieldVarMore);
 }

 public Node buildFieldVarMore(NodeListOptional nodeListOptional) {
  return new FieldVarMore(nodeListOptional);
 }

 public Node buildFormList(NodeToken nodeToken, FidMore fidMore) {
  return new FormList(nodeToken, fidMore);
 }

 public Node buildIdList(NodeToken nodeToken, IdMore idMore) {
  return new IdList(nodeToken, idMore);
 }

 public Node buildIdMore(NodeListOptional nodeListOptional) {
  return new IdMore(nodeListOptional);
 }

 public Node buildInputStm(NodeToken nodeToken1, NodeToken nodeToken2,
   InVar inVar, NodeToken nodeToken3) {
  return new InputStm(nodeToken1, nodeToken2, inVar, nodeToken3);
 }

 public Node buildInVar(NodeToken nodeToken) {
  return new InVar(nodeToken);
 }

 public Node buildLoopStm(NodeToken nodeToken1, RelExp relExp,
   NodeToken nodeToken2, StmList stmList, NodeToken nodeToken3) {
  return new LoopStm(nodeToken1, relExp, nodeToken2, stmList, nodeToken3);
 }

 public Node buildLow(NodeToken nodeToken) {
  return new Low(nodeToken);
 }

 public Node buildMultOp(NodeChoice nodeChoice) {
  return new MultOp(nodeChoice);
 }

 public Node buildOtherFactor(NodeListOptional nodeListOptional) {
  return new OtherFactor(nodeListOptional);
 }

 public Node buildOtherRelE(CmpOp cmpOp, Exp exp) {
  return new OtherRelE(cmpOp, exp);
 }

 public Node buildOtherTerm(NodeListOptional nodeListOptional) {
  return new OtherTerm(nodeListOptional);
 }

 public Node buildOutputStm(NodeToken nodeToken1, NodeToken nodeToken2,
   Exp exp, NodeToken nodeToken3) {
  return new OutputStm(nodeToken1, nodeToken2, exp, nodeToken3);
 }

 public Node buildParam(NodeList nodeList) {
  return new Param(nodeList);
 }

 public Node buildParamDecList(Param param, ParamMore paramMore) {
  return new ParamDecList(param, paramMore);
 }

 public Node buildParamList(NodeOptional nodeOptional) {
  return new ParamList(nodeOptional);
 }

 public Node buildParamMore(NodeListOptional nodeListOptional) {
  return new ParamMore(nodeListOptional);
 }

 public Node buildProcDec(NodeToken nodeToken1, ProcName procName,
   NodeToken nodeToken2, ParamList paramList, NodeToken nodeToken3,
   NodeToken nodeToken4, ProcDecPart procDecPart, ProcBody procBody,
   ProcDecMore procDecMore) {
  return new ProcDec(nodeToken1, procName, nodeToken2, paramList,
    nodeToken3, nodeToken4, procDecPart, procBody, procDecMore);
 }

 public Node buildProcBody(ProgramBody programBody) {
  return new ProcBody(programBody);
 }

 public Node buildProcDecMore(NodeOptional nodeOptional) {
  return new ProcDecMore(nodeOptional);
 }

 public Node buildProcDecPart(DeclarePart declarePart) {
  return new ProcDecPart(declarePart);
 }

 public Node buildProcName(NodeToken nodeToken) {
  return new ProcName(nodeToken);
 }

 public Node buildProgram(ProgramHeader programHeader,
   DeclarePart declarePart, ProgramBody programBody) {
  treeRoot = new Program(programHeader, declarePart, programBody);
     return treeRoot;
 }

 public Node buildProgramHeader(NodeToken nodeToken, ProgramName programName) {
  return new ProgramHeader(nodeToken, programName);
 }

 public Node buildProgramName(NodeToken nodeToken) {
  return new ProgramName(nodeToken);
 }

 public Node buildProgramBody(NodeToken nodeToken1, StmList stmList,
   NodeToken nodeToken2) {
  return new ProgramBody(nodeToken1, stmList, nodeToken2);
 }

 public Node buildRecType(NodeToken nodeToken1, FieldDecList fieldDecList,
   NodeToken nodeToken2) {
  return new RecType(nodeToken1, fieldDecList, nodeToken2);
 }

 public Node buildRelExp(Exp exp, OtherRelE otherRelE) {
  return new RelExp(exp, otherRelE);
 }

 public Node buildReturnStm(NodeToken nodeToken) {
  return new ReturnStm(nodeToken);
 }

 public Node buildStm(NodeList nodeList) {
  return new Stm(nodeList);
 }

 public Node buildStmList(Stm stm, StmMore stmMore) {
  return new StmList(stm, stmMore);
 }

 public Node buildStmMore(NodeListOptional nodeListOptional) {
  return new StmMore(nodeListOptional);
 }

 public Node buildStructureType(NodeChoice nodeChoice) {
  return new StructureType(nodeChoice);
 }

 public Node buildTerm(Factor factor, OtherFactor otherFactor) {
  return new Term(factor, otherFactor);
 }

 public Node buildTop(NodeToken nodeToken) {
  
  return new Top(nodeToken);
 }

 public Node buildTypeDec(NodeToken nodeToken, TypeDecList typeDecList) {
  return new TypeDec(nodeToken, typeDecList);
 }

 public Node buildTypeDecList(TypeId typeId, NodeToken nodeToken1,
   TypeDef typeDef, NodeToken nodeToken2, TypeDecMore typeDecMore) {
  return new TypeDecList(typeId, nodeToken1, typeDef, nodeToken2,
    typeDecMore);
 }

 public Node buildTypeDecMore(NodeOptional nodeOptional) {
  return new TypeDecMore(nodeOptional);
 }

 public Node buildTypeDecPart(NodeOptional nodeOptional) {
  return new TypeDecPart(nodeOptional);
 }

 public Node buildTypeDef(NodeChoice nodeChoice) {
  return new TypeDef(nodeChoice);
 }

 public Node buildTypeId(NodeToken nodeToken) {
  return new TypeId(nodeToken);
 }

 public Node buildVarDec(NodeToken nodeToken, VarDecList varDecList) {
  return new VarDec(nodeToken, varDecList);
 }

 public Node buildVarDecList(TypeDef typeDef, VarIdList varIdList,
   NodeToken nodeToken, VarDecMore varDecMore) {
  return new VarDecList(typeDef, varIdList, nodeToken, varDecMore);
 }

 public Node buildVarDecMore(NodeOptional nodeOptional) {
  return new VarDecMore(nodeOptional);
 }

 public Node buildVarDecPart(NodeOptional nodeOptional) {
  return new VarDecPart(nodeOptional);
 }

 public Node buildVariable(NodeToken nodeToken, VariMore variMore) {
  return new Variable(nodeToken, variMore);
 }

 public Node buildVarIdList(NodeToken nodeToken, VarIdMore varIdMore) {
  return new VarIdList(nodeToken, varIdMore);
 }

 public Node buildVarIdMore(NodeListOptional nodeListOptional) {
  return new VarIdMore(nodeListOptional);
 }

 public Node buildVariMore(NodeListOptional nodeListOptional) {
  return new VariMore(nodeListOptional);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < recType > ::=  RECORD fieldDecList END
 */
public class RecType implements Node {

 public NodeToken nodeToken1;

 public FieldDecList fieldDecList;

 public NodeToken nodeToken2;

 public RecType() {

 }

 public RecType(NodeToken nodeToken1, FieldDecList fieldDecList,
   NodeToken nodeToken2) {
  this.nodeToken1 = nodeToken1;
  this.fieldDecList = fieldDecList;
  this.nodeToken2 = nodeToken2;
 }

 public void accept(Visitor v) {
  v.visitRecType(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式RelExp := Exp OtherRelE
 */
public class RelExp implements Node {
 public Exp exp;

 public OtherRelE otherRelE;

 public RelExp() {

 }

 public RelExp(Exp exp, OtherRelE otherRelE) {
  this.exp = exp;
  this.otherRelE = otherRelE;
 }

 public void accept(Visitor v) {
  v.visitRelExp(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < returnStm > ::=   RETURN
 */
public class ReturnStm implements Node {
 public NodeToken nodeToken;

 public ReturnStm() {

 }

 public ReturnStm(NodeToken nodeToken) {
  this.nodeToken = nodeToken;
 }

 public void accept(Visitor v) {
  v.visitReturnStm(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Iterator;
import edu.jlu.fuliang.Spacing;

public class SNLPrinter extends Visitor {
 protected PrintWriter out;

 protected int nestLevel = 0;

 protected Spacing space;

 public SNLPrinter() {
  out = new PrintWriter(System.out, true);
 }

 public SNLPrinter(Writer Out) {
  this.out = new PrintWriter(out, true);
 }

 public SNLPrinter(Writer Out, Spacing space) {
  this.out = new PrintWriter(out, true);
  this.space = space;
 }

 public SNLPrinter(OutputStream out) {
  this.out = new PrintWriter(out, true);
  space = new Spacing(3);
 }

 public SNLPrinter(OutputStream out, Spacing space) {
  this.out = new PrintWriter(out, true);
  this.space = space;
 }

 public void flushWriter() {
  out.flush();
 }

 public void visitNodeList(NodeList n) {
  for (Iterator it = n.elements(); it.hasNext();) {
   ((Node) it.next()).accept(this);
  }
 }

 public void visitNodeOptional(NodeOptional n) {
  if (n.present()) {
   n.node.accept(this);
  }
 }

 public void visitNodeListOptional(NodeListOptional n) {
  if (n.present())
   for (Iterator it = n.elements(); it.hasNext();) {
    if (it != null)
     ((Node) it.next()).accept(this);
   }
 }

 public void visitNodeToken(NodeToken n) {
  out.print(space);
  out.println(n.tokenString);
 }

 public void visitProgram(Program p) {
  out.println("Program");

  space.updateSpc(1);
  if (p.programHeader != null) {
   p.programHeader.accept(this);
  }
  if (p.declarePart != null) {
   p.declarePart.accept(this);
  }
  if (p.programBody != null) {
   p.programBody.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitProgramHeader(ProgramHeader ph) {
  out.print(space);
  out.println("ProgramHeader");

  space.updateSpc(1);

  if (ph.nodeToken != null) {
   ph.nodeToken.accept(this);
  }

  if (ph.programName != null) {
   ph.programName.accept(this);
  }

  space.updateSpc(-1);
 }

 public void visitProgramName(ProgramName pn) {
  out.print(space);
  out.println("ProgramName");

  space.updateSpc(1);
  if (pn.nodeToken != null) {
   pn.nodeToken.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitDeclarePart(DeclarePart dp) {

  out.print(space);
  out.println("DeclarePart");

  space.updateSpc(1);
  if (dp.typeDecPart != null) {
   dp.typeDecPart.accept(this);
  }
  if (dp.varDecPart != null) {
   dp.varDecPart.accept(this);
  }

  if (dp.proclareDecPart != null) {
   dp.proclareDecPart.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitTypeDecPart(TypeDecPart tp) {
  out.print(space);
  out.println("TypeDecPart");

  space.updateSpc(1);
  tp.nodeOptional.accept(this);
  space.updateSpc(-1);
 }

 public void visitTypeDec(TypeDec td) {
  out.print(space);
  out.println("TypeDec");

  space.updateSpc(1);
  if (td.typeDecList != null) {
   td.nodeToken.accept(this);
   td.typeDecList.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitTypeDecList(TypeDecList tl) {

  out.print(space);
  out.println("TypeDecList");

  space.updateSpc(1);

  if (tl.typeId != null) {
   tl.typeId.accept(this);
  }

  if (tl.nodeToken1 != null) {
   tl.nodeToken1.accept(this);
  }

  if (tl.typeDef != null) {
   tl.typeDef.accept(this);
  }

  if (tl.nodeToken2 != null) {
   tl.nodeToken2.accept(this);
  }

  if (tl.typeDecMore != null) {
   tl.typeDecMore.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitTypeID(TypeId id) {
  out.print(space);
  out.println("TypeId");

  space.updateSpc(1);
  if (id.nodeToken != null) {
   id.nodeToken.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitTypeDef(TypeDef td) {
  out.print(space);
  out.println("TypeDef");

  space.updateSpc(1);
  td.nodeChoice.accept(this);
  space.updateSpc(-1);
 }

 public void visitTypeDecMore(TypeDecMore tm) {
  out.print(space);
  out.println("TypeDecMore");

  space.updateSpc(1);
  visitNodeOptional(tm.nodeOptional);
  space.updateSpc(-1);
 }

 public void visitBaseType(BaseType bt) {
  out.print(space);
  out.println("BaseType");
  space.updateSpc(1);
  bt.nodeChoice.accept(this);
  space.updateSpc(-1);
 }

 public void visitStructureType(StructureType st) {
  out.print(space);
  out.println("StructureType");

  space.updateSpc(1);
  st.nodeChoice.accept(this);
  space.updateSpc(-1);
 }

 public void visitArrayType(ArrayType at) {

  space.updateSpc(1);

  if (at.nodeToken1 != null) {
   at.nodeToken1.accept(this);
  }

  if (at.nodeToken2 != null) {
   at.nodeToken2.accept(this);
  }

  if (at.low != null) {
   at.low.accept(this);
  }

  if (at.nodeToken3 != null) {
   at.nodeToken3.accept(this);
  }

  if (at.top != null) {

   at.top.accept(this);
  }

  if (at.nodeToken4 != null) {
   at.nodeToken4.accept(this);
  }

  if (at.nodeToken4 != null) {
   at.nodeToken5.accept(this);
  }

  if (at.baseType != null) {
   at.baseType.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitLow(Low low) {
  out.print(space);
  out.println("Low");
  space.updateSpc(1);
  if (low.nodeToken != null) {
   low.nodeToken.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitTop(Top top) {
  out.print(space);
  out.println("Top");

  space.updateSpc(1);
  if (top.nodeToken != null) {
   top.nodeToken.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitRecType(RecType rt) {
  out.print(space);
  out.println("RecType");
  space.updateSpc(1);
  if (rt.nodeToken1 != null) {
   rt.nodeToken1.accept(this);
  }

  if (rt.fieldDecList != null) {
  rt.fieldDecList.accept(this);
  }

  if (rt.nodeToken2 != null) {
   rt.nodeToken2.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitFieldDecList(FieldDecList fl) {
  out.print(space);
  out.println("FieldDecList");

  space.updateSpc(1);
  visitNodeList(fl.nodeList);
  space.updateSpc(-1);
 }

 public void visitFieldDecMore(FieldDecMore fm) {
  out.print(space);
  out.println("FieldDecMore");
  space.updateSpc(1);
  visitNodeOptional(fm.nodeOptional);
  space.updateSpc(-1);
 }

 public void visitIdList(IdList id) {
  out.print(space);
  out.println("IdList");

  space.updateSpc(1);
  if (id.nodeToken != null) {
   id.nodeToken.accept(this);
  }
  if (id.idMore != null) {
   id.idMore.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitIdMore(IdMore im) {
  out.print(space);
  out.println("IdMore");

  space.updateSpc(1);
  visitNodeListOptional(im.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitVarDecPart(VarDecPart vp) {
  out.print(space);
  out.println("VarDecPart");

  space.updateSpc(1);
  visitNodeOptional(vp.nodeOptional);
  space.updateSpc(-1);
 }

 public void visitVarDec(VarDec vd) {
  out.print(space);
  out.println("VarDec");

  space.updateSpc(1);
  if (vd.nodeToken != null) {
   vd.nodeToken.accept(this);
  }
  if (vd.varDecList != null) {
   vd.varDecList.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitVarDecList(VarDecList vd) {
  out.print(space);
  out.println("VarDecList");

  space.updateSpc(1);
  if (vd.typeDef != null) {
   out.print(space);
   out.println("TypeDef");
   vd.typeDef.accept(this);
  }
  if (vd.varIdList != null) {
   vd.varIdList.accept(this);
  }
  if (vd.nodeToken != null) {
   vd.nodeToken.accept(this);
  }

  if (vd.varDecMore != null) {
   vd.varDecMore.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitVarDecMore(VarDecMore vd) {
  out.print(space);
  out.println("VarDecMore");

  space.updateSpc(1);
  visitNodeOptional(vd.nodeOptional);
  space.updateSpc(-1);
 }

 public void visitVarIdList(VarIdList vi) {
  out.print(space);
  out.println("VarIdList");

  space.updateSpc(1);
  if (vi.nodeToken != null) {
   vi.nodeToken.accept(this);
  }
  if (vi.varIdMore != null) {
   vi.varIdMore.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitVarIdMore(VarIdMore vi) {
  out.print(space);
  out.println("VarIdMore");

  space.updateSpc(1);
  visitNodeListOptional(vi.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitProcDecPart(ProcDecPart pd) {
  out.print(space);
  out.println("ProcDecPart");

  space.updateSpc(1);
  if (pd.declarePart != null) {

   pd.declarePart.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitProcDeclarePart(ProcDeclarePart pp) {
  out.print(space);
  out.println("ProcDeclarePart");

  space.updateSpc(1);
  visitNodeOptional(pp.nodeOptional);
  space.updateSpc(-1);
 }

 public void visitProcDec(ProcDec pd) {
  out.print(space);
  out.println("ProcDec");

  space.updateSpc(1);
  if (pd.nodeToken1 != null) {
      pd.nodeToken1.accept(this);
  }

  if (pd.procName != null) {
   pd.procName.accept(this);
  }

  if (pd.nodeToken2 != null) {
   pd.nodeToken2.accept(this);
  }

  if (pd.paramList != null) {

   pd.paramList.accept(this);
  }

  if (pd.nodeToken3 != null) {
   pd.nodeToken3.accept(this);
  }

  if (pd.nodeToken4 != null) {
   pd.nodeToken4.accept(this);
  }

  if (pd.procDecPart != null) {
   out.print(space);
   out.println("ProcDecPart");
   pd.procDecPart.accept(this);
  }

  if (pd.procBody != null) {
   out.print(space);
   out.println("ProcBody");
   pd.procBody.accept(this);
  }
  if (pd.procDecMore != null) {
   out.print(space);
   out.println("ProcDecMore");
   pd.procDecMore.accept(this);
  }
 }

 public void visitProcBody(ProcBody pd) {
  out.print(space);
  out.println("ProcBody");

  space.updateSpc(1);
  if (pd.programBody != null) {
   pd.programBody.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitProcDecMore(ProcDecMore pm) {
  out.print(space);
  out.println("ProcDecMore");

  space.updateSpc(1);
  visitNodeOptional(pm.nodeOptional);
  space.updateSpc(1);
 }

 public void visitProcName(ProcName pn) {
  out.print(space);
  out.println("ProcName");

  space.updateSpc(1);
  if (pn.nodeToken != null) {
   pn.nodeToken.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitParamList(ParamList pd) {
  out.print(space);
  out.println("ParamList");

  space.updateSpc(1);
  visitNodeOptional(pd.nodeOptional);
  space.updateSpc(-1);
 }

 public void visitParam(Param p) {
  out.print(space);
  out.println("Param");

  space.updateSpc(1);
  visitNodeList(p.nodeList);
  space.updateSpc(-1);
 }

 public void visitParamMore(ParamMore pm) {
  out.print(space);
  out.println("ParamMore");

  space.updateSpc(1);
  visitNodeListOptional(pm.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitFidMore(FidMore fm) {
  out.print(space);
  out.println("FidMore");

  space.updateSpc(1);
  visitNodeListOptional(fm.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitProcDecBody(ProcBody pd) {
  out.print(space);
  out.println("ProcBody");

  space.updateSpc(1);
  if (pd.programBody != null) {
   pd.programBody.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitProgramBody(ProgramBody pb) {
  out.print(space);
  out.println("ProgramBody");

  space.updateSpc(1);
  if (pb.nodeToken1 != null) {
   pb.nodeToken1.accept(this);
  }
  if (pb.stmList != null) {

   pb.stmList.accept(this);
  }
  if (pb.nodeToken2 != null) {
   pb.nodeToken2.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitStm(Stm s) {
  out.print(space);
  out.println("Stm");

  space.updateSpc(1);
  visitNodeList(s.nodeList);
  space.updateSpc(-1);
 }

 public void visitStmList(StmList sl) {
  out.print(space);
  out.println("StmList");

  space.updateSpc(1);
  if (sl.stm != null) {
       sl.stm.accept(this);
  }
  if (sl.stmMore != null) {
   sl.stmMore.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitAssCall(AssCall ac) {
  out.print(space);
  out.println("AssCall");

  space.updateSpc(1);
  ac.nodeChoice.accept(this);
  space.updateSpc(-1);
 }

 public void visitAssignmentRest(AssignmentRest ar) {
  out.print(space);
  out.println("AssignmentRest");

  space.updateSpc(1);
  if (ar.variMore != null) {
   ar.variMore.accept(this);
  }
  if (ar.nodeToken != null) {
   ar.nodeToken.accept(this);
  }
  if (ar.nodeToken != null) {
   ar.exp.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitConditionalStm(ConditionalStm cs) {
  out.print(space);
  out.println("ConditionalStm");

  space.updateSpc(1);
  if (cs.nodeToken1 != null) {
   cs.nodeToken1.accept(this);
  }
  if (cs.relExp != null) {
   cs.relExp.accept(this);
  }
  if (cs.nodeToken2 != null) {
   cs.nodeToken2.accept(this);
  }
  if (cs.stmList1 != null) {
   cs.stmList1.accept(this);
  }
  if (cs.nodeToken3 != null) {
   cs.nodeToken3.accept(this);
  }
  if (cs.stmList2 != null) {
   cs.stmList2.accept(this);
  }
  if (cs.nodeToken4 != null) {
   cs.nodeToken4.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitLoopStm(LoopStm ls) {
  out.print(space);
  out.println("LoopStm");

  space.updateSpc(1);

  if (ls.nodeToken1 != null) {
   ls.nodeToken1.accept(this);
  }

  if (ls.relExp != null) {
   ls.relExp.accept(this);
  }

  if (ls.nodeToken2 != null) {
   ls.nodeToken2.accept(this);
  }
  if (ls.stmList != null) {
   ls.stmList.accept(this);
  }
  if (ls.nodeToken3 != null) {
   ls.nodeToken3.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitInputStm(InputStm is) {
  out.print(space);
  out.println("InputStm");

  space.updateSpc(1);

  if (is.nodeToken1 != null) {
    is.nodeToken1.accept(this);
  }
  if (is.nodeToken2 != null) {
   is.nodeToken2.accept(this);
  }
  if (is.inVar != null) {
   is.inVar.accept(this);
  }
  if (is.nodeToken3 != null) {
   is.nodeToken3.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitInVar(InVar iv) {
  out.print(space);
  out.println("InVar");

  space.updateSpc(1);
  if (iv.nodeToken != null) {
   iv.nodeToken.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitOutputStm(OutputStm os) {
  out.print(space);
  out.println("OutputStm");

  space.updateSpc(1);
  if (os.nodeToken1 != null) {
   os.nodeToken1.accept(this);
  }
  if (os.nodeToken2 != null) {
   os.nodeToken2.accept(this);
  }
  if (os.exp != null) {
   os.exp.accept(this);
  }
  if (os.nodeToken3 != null) {
   os.nodeToken3.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitReturnStm(ReturnStm rs) {
  out.print(space);
  out.println("ReturnStm");

  space.updateSpc(1);
  if (rs.nodeToken != null) {
   rs.nodeToken.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitCallStmRest(CallStmRest cr) {
  out.print(space);
  out.println("CallStmRest");

  space.updateSpc(1);
  if (cr.nodeToken1 != null) {
   cr.nodeToken1.accept(this);
  }
  if (cr.actParamList != null) {
   cr.actParamList.accept(this);
  }
  if (cr.nodeToken2 != null) {
   cr.nodeToken2.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitActParamList(ActParamList al) {
  out.print(space);
  out.println("ActParamList");

  space.updateSpc(1);
  visitNodeListOptional(al.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitActParamMore(ActParamMore ap) {
  out.print(space);
  out.println("ActParamMore");

  space.updateSpc(1);
  visitNodeListOptional(ap.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitRelExp(RelExp re) {
  out.print(space);
  out.println("RelExp");

  space.updateSpc(1);
  if (re.exp != null) {
   re.exp.accept(this);
  }
  if (re.otherRelE != null) {
   re.otherRelE.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitExp(Exp e) {
  out.print(space);
  out.println("Exp");

  space.updateSpc(1);
  if (e.term != null) {
   e.term.accept(this);
  }
  if (e.otherTerm != null) {
   e.otherTerm.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitOtherTerm(OtherTerm ot) {
  out.print(space);
  out.println("OtherTerm");

  space.updateSpc(1);
  visitNodeListOptional(ot.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitTerm(Term t) {
  out.print(space);
  out.println("Term");

  space.updateSpc(1);
  if (t.factor != null) {
   t.factor.accept(this);
  }

  if (t.otherFactor != null) {
   t.otherFactor.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitFactor(Factor f) {
  out.print(space);
  out.println("Factor");

  space.updateSpc(1);
  visitNodeList(f.nodeList);
  space.updateSpc(-1);
 }

 public void visitOtherFactor(OtherFactor of) {
  out.print(space);
  out.println("OtherFactor");

  space.updateSpc(1);
  visitNodeListOptional(of.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitVariable(Variable v) {
  out.print(space);
  out.println("Variable");

  space.updateSpc(1);
  if (v.nodeToken != null) {
   v.nodeToken.accept(this);
  }
  if (v.variMore != null) {
   v.variMore.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitVariMore(VariMore vm) {
  out.print(space);
  out.println("VariMore");

  space.updateSpc(1);
  visitNodeListOptional(vm.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitFieldVar(FieldVar fv) {
  out.print(space);
  out.println("FieldVar");

  space.updateSpc(1);
  if (fv.nodeToken != null) {
   fv.nodeToken.accept(this);
  }
  if (fv.fieldVarMore != null) {
   fv.fieldVarMore.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitFieldVarMore(FieldVarMore fm) {
  out.print(space);
  out.println("FieldVarMore");

  space.updateSpc(1);
  visitNodeListOptional(fm.nodeListOptional);
  space.updateSpc(-1);
 }

 public void visitCmpOp(CmpOp co) {
  out.print(space);
  out.println("CmpOp");

  space.updateSpc(1);
  co.nodeChoice.accept(this);
  space.updateSpc(-1);
 }

 public void visitAddOp(AddOp ao) {
  out.print(space);
  out.println("AddOp");

  space.updateSpc(1);
  ao.nodeChoice.accept(this);
  space.updateSpc(-1);
 }

 public void visitMultOp(MultOp mo) {
  out.print(space);
  out.println("MultOp");

  space.updateSpc(1);
  mo.nodeChoice.accept(this);
  space.updateSpc(-1);
 }

 public void visitFormList(FormList fl) {
  out.print(space);
  out.println("FormList");

  space.updateSpc(1);
  if (fl.nodeToken != null) {
   fl.nodeToken.accept(this);
  }
  if (fl.fidMore != null) {
   fl.fidMore.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitOtherRelE(OtherRelE relE) {
  out.print(space);
  out.println("OtherRelE");

  space.updateSpc(1);
  if (relE.cmpOp != null) {
   relE.cmpOp.accept(this);
  }
  if (relE.exp != null) {
   relE.exp.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitParamDecList(ParamDecList list) {
  out.print(space);
  out.println("ParamDecList");

  space.updateSpc(1);
  if (list.param != null) {
   list.param.accept(this);
  }
  if (list.paramMore != null) {
   list.paramMore.accept(this);
  }
  space.updateSpc(-1);
 }

 public void visitStmMore(StmMore more) {
  out.print(space);
  out.println("StmMore");

  space.updateSpc(1);
  visitNodeListOptional(more.nodeListOptional);
  space.updateSpc(-1);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
/* 产生式 < stm > ::=   conditionalStm   {IF}                      
/*                    | loopStm          {WHILE}                   
/*                    | inputStm         {READ}                    
/*                    | outputStm        {WRITE}                   
/*                    | returnStm        {RETURN}                 
/*                    | id  assCall      {id}  
 */
public class Stm implements Node {

 public NodeList nodeList;

 public Stm() {
  nodeList = new NodeList();
 }

 public Stm(NodeList nodeList) {
  this.nodeList = nodeList;
 }

 public void accept(Visitor v) {
  v.visitStm(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < stmList > ::=  stm    stmMore  
 */
public class StmList implements Node {

 public Stm stm;

 public StmMore stmMore;

 public StmList() {

 }

 public StmList(Stm stm, StmMore stmMore) {
  this.stm = stm;
  this.stmMore = stmMore;
 }

 public void accept(Visitor v) {
  v.visitStmList(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 *  产生式 < stmMore > ::=   ε |  ; stmList
 */
public class StmMore implements Node {
 public NodeListOptional nodeListOptional;

 public StmMore() {
  nodeListOptional = new NodeListOptional();
 }

 public StmMore(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitStmMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < structureType > ::=  arrayType | recType
 */
public class StructureType implements Node {

 public NodeChoice nodeChoice;

 public StructureType() {

 }

 public StructureType(NodeChoice nodeChoice) {

  this.nodeChoice = nodeChoice;
 }

 public void accept(Visitor v) {
  v.visitStructureType(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式Term := Factor OtherFactor
 */
public class Term implements Node {
 public Factor factor;

 public OtherFactor otherFactor;

 public Term() {

 }

 public Term(Factor factor, OtherFactor otherFactor) {
  this.factor = factor;
  this.otherFactor = otherFactor;
 }

 public void accept(Visitor v) {
  v.visitTerm(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式Top ::= INTC
 */
public class Top implements Node {

 public NodeToken nodeToken;

 public Top() {

 }

 public Top(NodeToken nodeToken) {
  this.nodeToken = nodeToken;
 }

 public void accept(Visitor v) {
  v.visitTop(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;

/*
 * 产生式< TypeDec > ::= TYPE  TypeDecList
 */

public class TypeDec implements Node {
 public NodeToken nodeToken;

 public TypeDecList typeDecList;

 public TypeDec() {

 }

 public TypeDec(NodeToken nodeToken, TypeDecList typeDecList) {
  this.nodeToken = nodeToken;
  this.typeDecList = typeDecList;
 }

 public void accept(Visitor v) {
  v.visitTypeDec(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

/*
 * 产生式< TypeDecList > ::= typeId = typeName ; typeDecMore
 */

public class TypeDecList implements Node {
 public TypeId typeId;

 public NodeToken nodeToken1;

 public TypeDef typeDef;

 public NodeToken nodeToken2;

 public TypeDecMore typeDecMore;

 public TypeDecList() {

 }

 public TypeDecList(TypeId typeId, NodeToken nodeToken1, TypeDef typeDef,
   NodeToken nodeToken2, TypeDecMore typeDecMore) {
  this.typeId = typeId;
  this.nodeToken1 = nodeToken1;
  this.typeDef = typeDef;
  this.nodeToken2 = nodeToken2;
  this.typeDecMore = typeDecMore;
 }

 public void accept(Visitor v) {
  v.visitTypeDecList(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

/*
 *产生式 < typeDecMore > ::=    ε | TypeDecList
 */

public class TypeDecMore implements Node {

 public NodeOptional nodeOptional;

 public TypeDecMore() {
  nodeOptional = new NodeOptional();
 }

 public TypeDecMore(NodeOptional nodeOptional) {
  this.nodeOptional = nodeOptional;
 }

 public void accept(Visitor v) {
  v.visitTypeDecMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

/*
 * 产生式< typeDec > ::= ε | TypeDeclaration
 */

public class TypeDecPart implements Node {
 public NodeOptional nodeOptional;

 public TypeDecPart() {
  nodeOptional = new NodeOptional();
 }

 public TypeDecPart(NodeOptional nodeOptional) {
  this.nodeOptional = nodeOptional;
 }

 public void accept(Visitor v) {
  v.visitTypeDecPart(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 *
 * < typeDef > ::= baseType | structureType | id
 *
 */
public class TypeDef implements Node {
 public NodeChoice nodeChoice;

 public TypeDef() {

 }

 public TypeDef(NodeChoice nodeChoice) {
  this.nodeChoice = nodeChoice;
 }

 public void accept(Visitor v) {
  v.visitTypeDef(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

/*
 * < typeId > ::= id
 */

public class TypeId implements Node {
 public NodeToken nodeToken;

 public TypeId() {

 }

 public TypeId(NodeToken nodeToken) {
  this.nodeToken = nodeToken;
 }

 public void accept(Visitor v) {
  v.visitTypeID(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < varDec> ::=  VAR  varDecList
 */
public class VarDec implements Node {
 public NodeToken nodeToken;

 public VarDecList varDecList;

 public VarDec() {

 }

 public VarDec(NodeToken nodeToken, VarDecList varDecList) {
  this.nodeToken = nodeToken;
  this.varDecList = varDecList;
 }

 public void accept(Visitor v) {
  v.visitVarDec(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * < varDecList > ::=  typeName varIdList; varDecMore
 */
public class VarDecList implements Node {
 public TypeDef typeDef;

 public VarIdList varIdList;

 public NodeToken nodeToken;

 public VarDecMore varDecMore;

 public VarDecList() {

 }

 public VarDecList(TypeDef typeDef, VarIdList varIdList,
   NodeToken nodeToken, VarDecMore varDecMore) {
  this.typeDef = typeDef;
  this.varIdList = varIdList;
  this.nodeToken = nodeToken;
  this.varDecMore = varDecMore;
 }

 public void accept(Visitor v) {
  v.visitVarDecList(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < varDecMore > ::=  ε |  varDecList
 */
public class VarDecMore implements Node {

 public NodeOptional nodeOptional;

 public VarDecMore() {
       nodeOptional = new NodeOptional();
 }

 public VarDecMore(NodeOptional nodeOptional) {
  this.nodeOptional = nodeOptional;
 }

 public void accept(Visitor v) {
  v.visitVarDecMore(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < varDecPart > ::=  ε |  varDec
 */
public class VarDecPart implements Node {

 public NodeOptional nodeOptional;

 public VarDecPart() {
  nodeOptional = new NodeOptional();
 }

 public VarDecPart(NodeOptional nodeOptional) {
  this.nodeOptional = nodeOptional;
 }

 public void accept(Visitor v) {
  v.visitVarDecPart(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式Variable ::= ID VariMore
 */
public class Variable implements Node {
 public NodeToken nodeToken;

 public VariMore variMore;

 public Variable() {

 }

 public Variable(NodeToken nodeToken, VariMore variMore) {
  this.nodeToken = nodeToken;
  this.variMore = variMore;
 }

 public void accept(Visitor v) {
  v.visitVariable(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 *  产生式 < varIdList > ::=  id  varIdMore 
 */
public class VarIdList implements Node {

 public NodeToken nodeToken;

 public VarIdMore varIdMore;

 public VarIdList() {

 }

 public VarIdList(NodeToken nodeToken, VarIdMore varIdMore) {
  this.nodeToken = nodeToken;
  this.varIdMore = varIdMore;
 }

 public void accept(Visitor v) {
  v.visitVarIdList(this);
 }

}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 < varIdMore > ::=  ε |  , varIdList
 */
public class VarIdMore implements Node {
 public NodeListOptional nodeListOptional;

 public VarIdMore() {
  nodeListOptional = new NodeListOptional();
 }

 public VarIdMore(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitVarIdMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;
/*
 * 产生式 VariMore ::= ε | [Exp] |.FieldVar
 */
public class VariMore implements Node {
 public NodeListOptional nodeListOptional;

 public VariMore() {
  nodeListOptional = new NodeListOptional();
 }

 public VariMore(NodeListOptional nodeListOptional) {
  this.nodeListOptional = nodeListOptional;
 }

 public void accept(Visitor v) {
  v.visitVariMore(this);
 }
}
package edu.jlu.fuliang.yufa.Recursion;

import java.util.Iterator;

public class Visitor {

 public void visitNodeList(NodeList n) {
  for (Iterator it = n.elements(); it.hasNext();) {
   ((Node) it.next()).accept(this);
  }
 }

 public void visitNodeOptional(NodeOptional n) {
  if (n.present())
   n.node.accept(this);
 }

 public void visitNodeListOptional(NodeListOptional n) {
  if (n.present())
   for (Iterator it = n.elements(); it.hasNext();) {
    ((Node) it.next()).accept(this);
   }
 }

 public void visitNodeToken(NodeToken n) {

 }

 public void visitProgram(Program p) {
  p.programHeader.accept(this);
  p.declarePart.accept(this);
  p.programBody.accept(this);
 }

 public void visitProgramHeader(ProgramHeader ph) {
  ph.nodeToken.accept(this);
  ph.programName.accept(this);
 }

 public void visitProgramName(ProgramName pn) {
  pn.nodeToken.accept(this);
 }

 public void visitDeclarePart(DeclarePart dp) {
  dp.typeDecPart.accept(this);
  dp.varDecPart.accept(this);
  dp.proclareDecPart.accept(this);
 }

 public void visitTypeDecPart(TypeDecPart tp) {
  tp.nodeOptional.accept(this);
 }

 public void visitTypeDec(TypeDec td) {
  td.nodeToken.accept(this);
  td.typeDecList.accept(this);
 }

 public void visitTypeDecList(TypeDecList tl) {
  tl.typeId.accept(this);
  tl.nodeToken1.accept(this);
  tl.typeDef.accept(this);
  tl.nodeToken2.accept(this);
  tl.typeDecMore.accept(this);
 }

 public void visitTypeID(TypeId id) {

  id.nodeToken.accept(this);
 }

 public void visitTypeDef(TypeDef td) {
  td.nodeChoice.accept(this);
 }

 public void visitTypeDecMore(TypeDecMore tm) {
  tm.nodeOptional.accept(this);
 }

 public void visitBaseType(BaseType bt) {
  bt.nodeChoice.accept(this);
 }

 public void visitStructureType(StructureType st) {
  st.nodeChoice.accept(this);
 }

 public void visitArrayType(ArrayType at) {
  at.nodeToken1.accept(this);
  at.nodeToken2.accept(this);
  at.low.accept(this);
  at.nodeToken3.accept(this);
  at.top.accept(this);
  at.nodeToken4.accept(this);
  at.nodeToken5.accept(this);
  at.baseType.accept(this);
 }

 public void visitLow(Low low) {
  low.nodeToken.accept(this);
 }

 public void visitTop(Top top) {
  top.nodeToken.accept(this);
 }

 public void visitRecType(RecType rt) {
  rt.nodeToken1.accept(this);
  rt.fieldDecList.accept(this);
  rt.nodeToken2.accept(this);
 }

 public void visitFieldDecList(FieldDecList fl) {
  fl.nodeList.accept(this);
 }

 public void visitFieldDecMore(FieldDecMore fm) {
  fm.nodeOptional.accept(this);
 }

 public void visitIdList(IdList id) {
  id.nodeToken.accept(this);
  id.idMore.accept(this);
 }

 public void visitIdMore(IdMore im) {
  im.nodeListOptional.accept(this);
 }

 public void visitVarDecPart(VarDecPart vp) {
  vp.nodeOptional.accept(this);
 }

 public void visitVarDec(VarDec vd) {
  vd.nodeToken.accept(this);
  vd.varDecList.accept(this);
 }

 public void visitVarDecList(VarDecList vd) {
  vd.typeDef.accept(this);
  vd.varIdList.accept(this);
  vd.nodeToken.accept(this);
  vd.varDecMore.accept(this);
 }

 public void visitVarDecMore(VarDecMore vd) {
  vd.nodeOptional.accept(this);
 }

 public void visitVarIdList(VarIdList vi) {
  vi.nodeToken.accept(this);
  vi.varIdMore.accept(this);
 }

 public void visitVarIdMore(VarIdMore vi) {
  vi.nodeListOptional.accept(this);
 }

 public void visitProcDecPart(ProcDecPart pd) {
  pd.declarePart.accept(this);
 }

 public void visitProcDeclarePart(ProcDeclarePart pp) {
  pp.nodeOptional.accept(this);
 }

 public void visitProcDec(ProcDec pd) {
  pd.nodeToken1.accept(this);
  pd.procName.accept(this);
  pd.nodeToken2.accept(this);
  pd.paramList.accept(this);
  pd.nodeToken3.accept(this);
  pd.nodeToken4.accept(this);
  pd.procDecPart.accept(this);
  pd.procBody.accept(this);
  pd.procDecMore.accept(this);
 }

 public void visitProcBody(ProcBody pd) {
  pd.programBody.accept(this);
 }

 public void visitProcDecMore(ProcDecMore pm) {
  pm.nodeOptional.accept(this);
 }

 public void visitProcName(ProcName pn) {
  pn.nodeToken.accept(this);
 }

 public void visitParamList(ParamList pd) {
  pd.nodeOptional.accept(this);
 }

 public void visitParam(Param p) {
  p.nodeList.accept(this);
 }

 public void visitParamMore(ParamMore pm) {
  pm.nodeListOptional.accept(this);
 }

 public void visitFidMore(FidMore fm) {
  fm.nodeListOptional.accept(this);
 }

 public void visitProcDecBody(ProcBody pd) {
  pd.programBody.accept(this);
 }

 public void visitProgramBody(ProgramBody pb) {
  pb.nodeToken1.accept(this);
  pb.stmList.accept(this);
  pb.nodeToken2.accept(this);
 }

 public void visitStm(Stm s) {
  s.nodeList.accept(this);
 }

 public void visitStmList(StmList sl) {
  sl.stm.accept(this);
  sl.stmMore.accept(this);
 }

 public void visitAssCall(AssCall ac) {
  ac.nodeChoice.accept(this);
 }

 public void visitAssignmentRest(AssignmentRest ar) {
  ar.variMore.accept(this);
  ar.nodeToken.accept(this);
  ar.exp.accept(this);
 }

 public void visitConditionalStm(ConditionalStm cs) {
  cs.nodeToken1.accept(this);
  cs.relExp.accept(this);
  cs.nodeToken2.accept(this);
  cs.stmList1.accept(this);
  cs.nodeToken3.accept(this);
  cs.stmList2.accept(this);
  cs.nodeToken4.accept(this);
 }

 public void visitLoopStm(LoopStm ls) {
  ls.nodeToken1.accept(this);
  ls.relExp.accept(this);
  ls.nodeToken2.accept(this);
  ls.stmList.accept(this);
  ls.nodeToken3.accept(this);
 }

 public void visitInputStm(InputStm is) {
  is.nodeToken1.accept(this);
  is.nodeToken2.accept(this);
  is.inVar.accept(this);
  is.nodeToken3.accept(this);
 }

 public void visitInVar(InVar iv) {
  iv.nodeToken.accept(this);
 }

 public void visitOutputStm(OutputStm os) {
  os.nodeToken1.accept(this);
  os.nodeToken2.accept(this);
  os.exp.accept(this);
  os.nodeToken3.accept(this);
 }

 public void visitReturnStm(ReturnStm rs) {
  rs.nodeToken.accept(this);
 }

 public void visitCallStmRest(CallStmRest cr) {
  cr.nodeToken1.accept(this);
  cr.actParamList.accept(this);
  cr.nodeToken2.accept(this);
 }

 public void visitActParamList(ActParamList al) {
  al.nodeListOptional.accept(this);
 }

 public void visitActParamMore(ActParamMore ap) {
  ap.nodeListOptional.accept(this);
 }

 public void visitRelExp(RelExp re) {
  re.exp.accept(this);
  re.otherRelE.accept(this);
 }

 public void visitExp(Exp e) {
  e.term.accept(this);
  e.otherTerm.accept(this);
 }

 public void visitOtherTerm(OtherTerm ot) {
  ot.nodeListOptional.accept(this);
 }

 public void visitTerm(Term t) {
  t.factor.accept(this);
  t.otherFactor.accept(this);
 }

 public void visitFactor(Factor f) {
  f.nodeList.accept(this);
 }

 public void visitOtherFactor(OtherFactor of) {
  of.nodeListOptional.accept(this);
 }

 public void visitVariable(Variable v) {
  v.nodeToken.accept(this);
  v.variMore.accept(this);
 }

 public void visitVariMore(VariMore vm) {
  vm.nodeListOptional.accept(this);
 }

 public void visitFieldVar(FieldVar fv) {
  fv.nodeToken.accept(this);
  fv.fieldVarMore.accept(this);
 }

 public void visitFieldVarMore(FieldVarMore fm) {
  fm.nodeListOptional.accept(this);
 }

 public void visitCmpOp(CmpOp co) {
  co.nodeChoice.accept(this);
 }

 public void visitAddOp(AddOp ao) {
  ao.nodeChoice.accept(this);
 }

 public void visitMultOp(MultOp mo) {
  mo.nodeChoice.accept(this);
 }

 public void visitFormList(FormList fl) {
  fl.nodeToken.accept(this);
  fl.fidMore.accept(this);
 }

 public void visitOtherRelE(OtherRelE relE) {
  relE.cmpOp.accept(this);
  relE.exp.accept(this);
 }

 public void visitParamDecList(ParamDecList list) {
  list.param.accept(this);
  list.paramMore.accept(this);
 }

 public void visitStmMore(StmMore more) {
  more.nodeListOptional.accept(this);
 }
}