示例#1
0
 public object Visit(AssignedVarDeclaringNode n, object o)
 {
     if (_currentScopeLevel == 1)
     {
         _currentClassST.EnterSymbol(n.Identifier.Value, n);
     }
     else if (_currentScopeLevel == 2)
     {
         _currentMethodST.EnterSymbol(n.Identifier.Value, n);
     }
     return(null);
 }
示例#2
0
        private VarDeclaringNode ParseVariableDeclaring()
        {
            VarDeclaringNode   itsAST;
            SourceCodePosition itsPos = _currentToken.SourcePosition;

            Accept(Token.TokenType.Var);
            TypeNode       itsType = Type();
            IdentifierNode itsName = new IdentifierNode(_currentToken, itsType);

            Accept(Token.TokenType.Identifier);
            itsAST = new VarDeclaringNode(itsName, itsType, itsPos);
            if (_currentToken.Type == Token.TokenType.AssignmentOperator)
            {
                itsAST = new AssignedVarDeclaringNode(itsName, itsType, Assigning(), itsPos);
            }
            Accept(Token.TokenType.Semicolon);
            return(itsAST);
        }
示例#3
0
 public object Visit(AssignedVarDeclaringNode n, object o)
 {
     if (_currentScopeLevel == 1)
     {
         Append($"{AddIndent()}public ");
         n.Type.Accept(this, null);
         Append($" {n.Identifier.Value} = ");
         n.Expression.Accept(this, null);
         AppendLine(";");
     }
     else
     {
         Append($"{AddIndent()}");
         n.Type.Accept(this, null);
         Append($" {n.Identifier.Value} = ");
         n.Expression.Accept(this, null);
         AppendLine(";");
     }
     return(null);
 }