001 package com.croftsoft.apps.compiler.mini.node;
002
003 import java.util.*;
004
005 /*********************************************************************
006 * Parse tree node for the Mini programming language.
007 *
008 * @see
009 * MiniNode
010 *
011 * @author
012 * <A HREF="http://www.alumni.caltech.edu/~croft/">David W. Croft</A>
013 * @version
014 * 1999-04-22
015 *********************************************************************/
016
017 public class StatementSequenceMiniNode extends AbstractMiniNode
018 //////////////////////////////////////////////////////////////////////
019 //////////////////////////////////////////////////////////////////////
020 {
021
022 protected List statementMiniNodeList;
023
024 //////////////////////////////////////////////////////////////////////
025 //////////////////////////////////////////////////////////////////////
026
027 public StatementSequenceMiniNode (
028 StatementSequenceMiniNode statementSequenceMiniNode,
029 StatementMiniNode statementMiniNode )
030 //////////////////////////////////////////////////////////////////////
031 {
032 if ( statementSequenceMiniNode != null )
033 {
034 statementMiniNodeList
035 = statementSequenceMiniNode.statementMiniNodeList;
036 }
037 else
038 {
039 statementMiniNodeList = new LinkedList ( );
040 }
041
042 statementMiniNodeList.add ( statementMiniNode );
043 }
044
045 public StatementSequenceMiniNode (
046 StatementMiniNode statementMiniNode )
047 //////////////////////////////////////////////////////////////////////
048 {
049 this ( null, statementMiniNode );
050 }
051
052 //////////////////////////////////////////////////////////////////////
053 //////////////////////////////////////////////////////////////////////
054
055 public List getStatementMiniNodeList ( )
056 //////////////////////////////////////////////////////////////////////
057 {
058 return statementMiniNodeList;
059 }
060
061 //////////////////////////////////////////////////////////////////////
062 // MiniNode interface methods
063 //////////////////////////////////////////////////////////////////////
064
065 public void generate ( MiniNodeCodeVisitor miniNodeCodeVisitor )
066 //////////////////////////////////////////////////////////////////////
067 {
068 miniNodeCodeVisitor.generateStatementSequence ( this );
069 }
070
071 //////////////////////////////////////////////////////////////////////
072 //////////////////////////////////////////////////////////////////////
073
074 public void checkSemantics ( Stack parentMiniNodeStack )
075 throws SemanticErrorException
076 //////////////////////////////////////////////////////////////////////
077 {
078 parentMiniNodeStack.push ( this );
079
080 Iterator i = statementMiniNodeList.iterator ( );
081
082 while ( i.hasNext ( ) )
083 {
084 ( ( StatementMiniNode ) i.next ( ) ).checkSemantics (
085 parentMiniNodeStack );
086 }
087
088 parentMiniNodeStack.pop ( );
089 }
090
091 //////////////////////////////////////////////////////////////////////
092 //////////////////////////////////////////////////////////////////////
093 }