コード例 #1
0
        private TypeDescriptor PrimaryExp(AbstractNode node)
        {
            AbstractNode child = node.Child;    // QualifiedName
                                                // NotJustName not implemented
            QualifiedName name = child as QualifiedName;

            if (name != null)
            {
                Attributes attr = Table.lookup(name.GetStringName());
                return(attr.TypeDescriptor);
            }
            // Special Name
            SpecialName specialName = child as SpecialName;

            if (specialName != null)
            {
                return(new ErrorDescriptor("SpecialName not implemented"));
            }
            // Complex Primary
            Expression exp = child as Expression;

            if (exp != null)
            {
                exp.Accept(this);
                return(exp.TypeDescriptor);
            }
            //Complex Primary No Parentheses
            Literal literal = child as Literal;

            if (literal != null)
            {
                return(literal.TypeDescriptor);
            }
            Number num = child as Number;

            if (num != null)
            {
                return(num.TypeDescriptor);
            }
            FieldAccess fieldAcc = child as FieldAccess;

            if (fieldAcc != null)
            {
                return(new ErrorDescriptor("FieldAccess not implemented"));
            }
            MethodCall methodCall = child as MethodCall;

            if (methodCall != null)
            {
                methodCall.Accept(this);
                return(methodCall.TypeDescriptor);
            }

            return(new ErrorDescriptor("Expected QualifiedName, Expression, " +
                                       "Literal or Number as Primary Expression"));
        }
コード例 #2
0
        // removed (added to grammar-node functionality)
        #endregion TopDecl Helpers


        #region TopDecl Travelers
        private void VisitNode(MethodCall node)
        {
            node.Accept(SemanticsVisitor);
        }