public Procedure(string name, VariableSequence valArgs, Variable resultArg, StatementSequence statements)
 {
     AddChild(valArgs);
     AddChild(resultArg);
     AddChild(statements);
     _name = name;
 }
 void Proc(ProcedureSequence procs)
 {
     StatementSequence statements;
     string name;
     VariableSequence valArgs = new VariableSequence();
     Variable resultArg = null;
     Expect(5);
     Token ptok = t;
     Expect(1);
     name = t.val;
     Expect(6);
     if (la.kind == 7 || la.kind == 8) {
     if (la.kind == 7) {
         Get();
         Expect(1);
         Variable v = new Variable(t.val);
         v.IsValueArg = true;
         valArgs.AddVariable(v);
         SymbolTable.DefineArgument(t.val);
         if (la.kind == 12) {
             Args(valArgs, out resultArg);
         }
     } else {
         Get();
         Expect(1);
         resultArg = new Variable(t.val);
         resultArg.IsResultArg = true;
         SymbolTable.DefineResultArgument(t.val);
     }
     }
     Expect(9);
     SequencePoint seq1 = new SequencePoint(ptok.line,ptok.col, t.line,t.col+t.val.Length);
     Expect(10);
     StmtSeq(out statements);
     Expect(4);
     SequencePoint seq2 = new SequencePoint(t.line, t.col, t.line, t.col+t.val.Length);
     Expect(11);
     if (procs.ContainsProcedure(name)) {
     errors.SemErr(ptok.line, ptok.col, "Procedure '" + name + "' is already declared");
     } else {
     Procedure proc = new Procedure(name, valArgs, resultArg, statements);
     proc.AddSequencePoint(seq1);
     proc.AddSequencePoint(seq2);
     procs.AddProcedure(proc);
     }
     SymbolTable.Clear();
 }
 public virtual void Visit(VariableSequence node)
 {
 }
        void Args(VariableSequence valArgs, out Variable resultArg)
        {
            resultArg = null;
            if (IsStartOfResultArg()) {
            Expect(12);
            Expect(8);
            Expect(1);
            resultArg = new Variable(t.val);
            resultArg.IsResultArg = true;
            if (SymbolTable.IsDeclaredInCurrentScope(t.val)) {
                errors.SemErr(t.line, t.col, string.Format("Argument '{0}' is already declared in this scope",t.val));
            } else {
                SymbolTable.DefineResultArgument(t.val);
            }

            } else if (la.kind == 12) {
            Get();
            Expect(1);
            Variable v = new Variable(t.val);
            v.IsValueArg = true;
            valArgs.AddVariable(v);
            if (SymbolTable.IsDeclaredInCurrentScope(t.val)) {
                errors.SemErr(t.line, t.col, string.Format("Argument '{0}' is already declared in this scope",t.val));
            } else {
                SymbolTable.DefineArgument(t.val);
            }

            if (la.kind == 12) {
                Args(valArgs, out resultArg);
            }
            } else SynErr(51);
        }