Esempio n. 1
0
 private void Visit(ProcedureDeclarationStmt declarationStmt)
 {
     if (!Symbols.ExistsInCurrentScope(declarationStmt.Identifier))
     {
         int currentScope   = Symbols.CurrentScope;
         int procedureScope = Symbols.EnterScope();
         //ReturnTypeStack.Push(TypeInfo.BasicVoid);
         var parameterSymbols = new List <ParameterSymbol>();
         foreach (var parameter in declarationStmt.Parameters)
         {
             var parameterSymbol = new ParameterSymbol(parameter, procedureScope);
             Symbols.AddSymbol(parameterSymbol);
             parameterSymbols.Add(parameterSymbol);
         }
         var procSymbol = new ProcedureSymbol(declarationStmt, parameterSymbols, currentScope);
         Symbols.AddSymbol(procSymbol);
         FunctionStack.Push(procSymbol);
         declarationStmt.DeclarationSymbol = procSymbol;
         Visit(declarationStmt.ProcedureBlock, false);
         Symbols.LeaveScope();
         //ReturnTypeStack.Pop();
         FunctionStack.Pop();
     }
     else
     {
         AddError(string.Format("'{0}' is already declared in current scope", declarationStmt.Identifier), declarationStmt);
     }
 }
Esempio n. 2
0
        private ProcedureDeclarationStmt ParseProcedureDeclaration()
        {
            Match(TokenType.KwProcedure);
            ProcedureDeclarationStmt statement = new ProcedureDeclarationStmt(AcceptedToken);

            statement.Identifier = ParseIdentifier();
            Match(TokenType.LParen);
            statement.Parameters = ParseParameters();
            Match(TokenType.RParen);
            Match(TokenType.LineTerm);
            statement.ProcedureBlock = ParseBlock();
            return(statement);
        }
Esempio n. 3
0
 public ProcedureSymbol(ProcedureDeclarationStmt declaration, List <ParameterSymbol> parameters, int scope) :
     base(declaration, parameters, scope)
 {
 }