public override object Visit(PrefixReference that, object value)
        {
            var result = (System.Text.StringBuilder) value;

            that.Prefix.Visit(this, (object) result);
            result.Append('!');
            result.Append(that.Symbol);

            return null;
        }
Exemple #2
0
 public override object Visit(PrefixReference that, object value)
 {
     that.Prefix.Visit(this);
     _writer.Write('.');
     _writer.Write(that.Symbol);
     return null;
 }
        public override object Visit(PrefixReference that, object value = null)
        {
            Folder<Symbol> folder = (Folder<Symbol>) that.Prefix.Visit(this, value);
            Object<Symbol> result = folder.Resolve(that.Symbol);
            if (result == null)
                throw new Toolbox.Error(Toolbox.ErrorKind.Fatal, that.Cursor, 0, "Unknown symbol: " + that.Symbol);

            that.Definition = result.Data.Definition;

            return (object) folder;
        }
        public override object Visit(PrefixReference that, object value = null)
        {
            PrintPrologue(that);
            PrintReference(that);
            PrintNodeId("Prefix", that.Prefix);
            PrintEpilogue(that);

            that.Prefix.Visit(this);

            return null;
        }
Exemple #5
0
        /** Parses an expression. */
        private Expression ParseExpression()
        {
            Expression result;

            /** Parse the expression prefix. */
            switch (_matcher.This.Kind)
            {
            #if DONE
                case TokenKind.Keyword_Base:
                    result = (Expression) ParseParentReference();
                    break;
            #endif
                case TokenKind.Dot:
                    result = (Expression) ParseMemberReference();
                    break;

                case TokenKind.Exclamation:
                    result = (Expression) ParseGlobalReference();
                    break;

            #if DONE
                case TokenKind.Keyword_False:
                case TokenKind.Keyword_True:
                    result = (Expression) ParseBooleanLiteral();
                    break;
            #endif

                case TokenKind.Name:
                    result = (Expression) ParseSymbolReference();
                    break;

                case TokenKind.Literal_Cardinal:
                    result = (Expression) ParseCardinalLiteral();
                    break;
            #if DONE
                case TokenKind.Literal_Character:
                    result = (Expression) ParseCharacterLiteral();
                    break;
            #endif
                case TokenKind.Literal_Text:
                    result = (Expression) ParseTextLiteral();
                    break;
            #if DONE
                case TokenKind.Keyword_New:
                    result = (Expression) ParseNewExpression();
                    break;

                case TokenKind.Keyword_None:
                    result = (Expression) ParseNoneExpression();
                    break;

                case TokenKind.Keyword_This:
                {
                    _matcher.Match(TokenKind.Keyword_This);
                    result = (Expression) ParseMemberReference();
                    break;
                }

                case TokenKind.BracketBegin:
                    result = (Expression) ParseBracketExpression();
                    break;
            #endif
                default:
                    /** \todo The \c ToString() invokation does not call our \c ToString() - why? */
                    throw new ParserError(_matcher.This.Cursor, "Expression expected, found " + _matcher.This.Kind.ToString());
            }

            bool done = false;
            while (!done)
            {
                switch (_matcher.This.Kind)
                {
                    case TokenKind.Dot:
                    {
                        Token start = _matcher.Match(TokenKind.Dot);
                        Token label = _matcher.Match(TokenKind.Name);
                        result = new PrefixReference(start.Cursor, result, label.Text);
                        break;
                    }

            #if DONE
                    case TokenKind.BracketBegin:
                    {
                        Token start = _matcher.Match(TokenKind.BracketBegin);
                        Expression other = ParseExpression();
                        _matcher.Match(TokenKind.BracketClose);
                        result = new ArrayExpression(start.Cursor, result, other);
                        break;
                    }
            #endif

                    case TokenKind.ParenthesisBegin:
                    {
                        Token start = _matcher.This;
                        Expression[] arguments = ParseArguments();
                        result = new CallExpression(start.Cursor, result, arguments);
                        break;
                    }

                    default:
                        done = true;
                        break;
                }
            }

            return result;
        }