Семантика языков программирования. Семантический анализ и элементы генерации объектного кода или интерпретации, страница 4

                buf+=cl.toString();

            }

            return buf;

      };

       public boolean Resolved(String Name){

        for(String s:this.resolvedTypes){

            if(s.compareTo(Name)==0)

                return true;

        }

        return false;

      };

      class Class{

       public String name;

       public ArrayList<Field> fields;

       public ArrayList<Constructor> constructors;

       public ArrayList<Method> methods;

       public Class(String Name){

           name=Name;

           fields=new ArrayList<Field>();

           constructors=new ArrayList<Constructor>();

           methods=new ArrayList<Method>();

       }

       public String toString(){

           String buf="Class "+name+"{\n";

              for(Field f: fields){

                buf+="\t"+f.toString();

              }

              for(Constructor f: constructors){

                buf+="\t"+f.toString();

              }

              for(Method f: methods){

                buf+="\t"+f.toString();

              }

           buf+="};\n" ;

           return buf;

       }

       public boolean AddField(boolean Visible, String Type, String Name){

          for(Field f:this.fields){

               if(f.name.compareTo(Name)==0)

                   return false;

          }

          for(Method m:this.methods){

               if(m.name.compareTo(Name)==0)

                   return false;

          }

        fields.add(new Field(Visible,Type,Name));

        return true;

       }

       public boolean AddConstructor(boolean Visible, String Name){

          if(this.name.compareTo(Name)!=0)

              return false;

          this.constructors.add(new Constructor(Visible,this.name));

          return true;

       }

       public boolean AddConstructorParam(Param p){

          if(this.constructors.isEmpty())

              return false;

          Constructor conc=constructors.get(this.constructors.size()-1);

          for(Param par: conc.params){

                if(par.CompareToName(p))

                    return false;

          }

          this.constructors.get(this.constructors.size()-1).params.add(p);

          return true;

       }

       public boolean EndConstructor(){

            if(this.constructors.size()<2)

                return true;

            Constructor c=this.constructors.get(this.constructors.size()-1);

            for(int i=0; i<this.constructors.size()-1; i++)

                if(this.constructors.get(i).CompareTo(c)==true){

                        this.constructors.remove(this.constructors.size()-1);

                        return false;

                }

            return true;

       };

       public boolean AddMethod(boolean Visible, String Type, String Name){

          for(Field f:this.fields){

               if(f.name.compareTo(Name)==0)

                   return false;

          }

          for(Method m:this.methods){

               if(m.name.compareTo(Name)==0)

                   return false;

          }

          this.methods.add(new Method(Visible,Type,Name));

          return true;

       }

       public boolean AddMethodParam(Param p){

          if(this.methods.isEmpty())

              return false;

          Method conc=methods.get(this.methods.size()-1);

          for(Param par: conc.params){

                if(par.CompareToName(p))

                    return false;

          }

          this.methods.get(this.methods.size()-1).params.add(p);

          return true;

       }

    }

      public boolean AddClass(String Name){

        if(Resolved(Name))

            return false;

        this.resolvedTypes.add(Name);

        this.classes.add(new Class(Name));

        return true;