Beispiel #1
0
        private AST Pointer()
        {
            if (currentToken.Type == TokenType.TILDE)
            {
                Eat(TokenType.TILDE);
                StringToken nodeToken = new StringToken(TokenType.ID, "Node", currentToken.Line, currentToken.Column, file);
                return(new IdAST(nodeToken));
            }
            else if (currentToken.Type == TokenType.AT)
            {
                Eat(TokenType.AT);
                StringToken inputToken = new StringToken(TokenType.ID, "InputMarker", currentToken.Line, currentToken.Column, file);
                return(new IdAST(inputToken));
            }
            else if (currentToken.Type == TokenType.DOLL)
            {
                Eat(TokenType.DOLL);
                StringToken outputToken = new StringToken(TokenType.ID, "OutputSink", currentToken.Line, currentToken.Column, file);
                return(new IdAST(outputToken));
            }
            StringToken idToken    = Eat(TokenType.ID) as StringToken;
            AST         pointerAST = new IdAST(idToken);

            while (currentToken.Type == TokenType.DOT)
            {
                Eat(TokenType.DOT);
                idToken    = Eat(TokenType.ID) as StringToken;
                pointerAST = new PointerAST(pointerAST, new IdAST(idToken));
            }
            return(pointerAST);
        }
Beispiel #2
0
        private object Visit(PointerAST pointerAST)
        {
            ScopeSymbolTable scope = Visit(pointerAST.ScopeName) as ScopeSymbolTable;

            if (scope != null)
            {
                ScopeSymbolTable tempScope = currentScope;
                currentScope = scope;
                object member = Visit(pointerAST.Member);
                currentScope = tempScope;
                return(member);
            }
            else
            {
                throw logger.Error(new SemanticException(pointerAST.ScopeName.FindToken(), "Scope expected"));
            }
        }