示例#1
0
        protected bool ParseKeyword(ParseContext context, IAstNode parent)
        {
            this.Keyword = RParser.ParseKeyword(context, this);
            this.Text    = context.TextProvider.GetText(this.Keyword);

            return(true);
        }
示例#2
0
        public override bool Parse(ParseContext context, IAstNode parent)
        {
            Debug.Assert(context.Tokens.CurrentToken.TokenType == RTokenType.Keyword);

            this.Keyword = RParser.ParseKeyword(context, this);
            this.Text    = context.TextProvider.GetText(this.Keyword);

            bool result = base.Parse(context, parent);

            if (context.Tokens.CurrentToken.TokenType == RTokenType.Semicolon)
            {
                this.Semicolon = RParser.ParseToken(context, this);
            }

            return(result);
        }
示例#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);
        }