Inheritance: AstNode
Esempio n. 1
0
        public static TokenNode ParseToken(ParseContext context, IAstNode parent) {
            TokenStream<RToken> tokens = context.Tokens;
            TokenNode node = new TokenNode();

            node.Parse(context, parent);
            return node;
        }
Esempio n. 2
0
        public static TokenNode ParseKeyword(ParseContext context, IAstNode parent) {
            TokenStream<RToken> tokens = context.Tokens;

            Debug.Assert(tokens.CurrentToken.TokenType == RTokenType.Keyword);

            TokenNode keyword = new TokenNode();
            keyword.Parse(context, parent);

            return keyword;
        }
Esempio n. 3
0
        public static TokenNode ParseOpenBraceSequence(ParseContext context, IAstNode parent) {
            TokenStream<RToken> tokens = context.Tokens;

            if (tokens.CurrentToken.TokenType == RTokenType.OpenBrace) {
                TokenNode openBrace = new TokenNode();
                openBrace.Parse(context, parent);

                return openBrace;
            } else {
                context.AddError(new MissingItemParseError(ParseErrorType.OpenBraceExpected, tokens.PreviousToken));
            }

            return null;
        }
Esempio n. 4
0
        /// <summary>
        /// Reflects change inside string or comment by shrinking or expanding token node.
        /// </summary>
        /// <returns></returns>
        private IAstNode OnTokenNodeChange(TokenNode node, int start, int oldLength, int newLength) {
            Debug.Assert(node != null);
            node.Token.Expand(0, newLength - oldLength);

            return node;
        }