public override bool Parse(ParseContext context, IAstNode parent)
        {
            if (base.Parse(context, parent))
            {
                IScope scope = RParser.ParseScope(context, this, allowsSimpleScope: true,
                                                  terminatingKeyword: _terminatingKeyword);
                if (scope != null)
                {
                    this.Scope = scope;
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        public override bool Parse(ParseContext context, IAstNode parent)
        {
            if (ParseKeyword(context, parent))
            {
                IScope scope = RParser.ParseScope(context, this, _allowsSimpleScope, terminatingKeyword: null);
                if (scope != null)
                {
                    this.Scope = scope;
                }

                this.Parent = parent;
                return(true);
            }

            return(false);
        }
예제 #3
0
        public override bool Parse(ParseContext context, IAstNode parent)
        {
            TokenStream <RToken> tokens = context.Tokens;

            Debug.Assert(tokens.CurrentToken.TokenType == RTokenType.Keyword);
            this.Keyword = RParser.ParseKeyword(context, this);
            this.Text    = context.TextProvider.GetText(this.Keyword);

            if (tokens.CurrentToken.TokenType == RTokenType.OpenBrace)
            {
                this.OpenBrace = RParser.ParseToken(context, this);

                this.Arguments = new ArgumentList(RTokenType.CloseBrace);
                this.Arguments.Parse(context, this);

                if (tokens.CurrentToken.TokenType == RTokenType.CloseBrace)
                {
                    this.CloseBrace = RParser.ParseToken(context, this);
                    this.Scope      = RParser.ParseScope(context, this, allowsSimpleScope: true, terminatingKeyword: null);
                    if (this.Scope != null)
                    {
                        return(base.Parse(context, parent));
                    }
                    else
                    {
                        context.AddError(new ParseError(ParseErrorType.FunctionBodyExpected, ErrorLocation.Token, tokens.PreviousToken));
                    }
                }
                else
                {
                    context.AddError(new ParseError(ParseErrorType.CloseBraceExpected, ErrorLocation.Token, tokens.CurrentToken));
                }
            }
            else
            {
                context.AddError(new ParseError(ParseErrorType.OpenBraceExpected, ErrorLocation.Token, tokens.CurrentToken));
            }

            return(false);
        }