private bool IsIdentifierStart()
 {
     if (CurrentCharacter == '_')
     {
         // VB Spec §2.2:
         //  If an identifier begins with an underscore, it must contain at least one other valid identifier character to disambiguate it from a line continuation.
         return(ParserHelpers.IsIdentifierPart(Peek()));
     }
     if (CurrentCharacter == '[')
     {
         return(ParserHelpers.IsIdentifierPart(Peek()));
     }
     return(ParserHelpers.IsIdentifierStart(CurrentCharacter));
 }
 private PartialParseResult HandleInsertion(Span target, char previousChar, TextChange change)
 {
     // What are we inserting after?
     if (previousChar == '.')
     {
         return(HandleInsertionAfterDot(target, change));
     }
     else if (ParserHelpers.IsIdentifierPart(previousChar) || previousChar == ')' || previousChar == ']')
     {
         return(HandleInsertionAfterIdPart(target, change));
     }
     else
     {
         return(PartialParseResult.Rejected);
     }
 }
 private PartialParseResult HandleDeletion(Span target, char previousChar, TextChange change)
 {
     // What's left after deleting?
     if (previousChar == '.')
     {
         return(TryAcceptChange(target, change, PartialParseResult.Accepted | PartialParseResult.Provisional));
     }
     else if (ParserHelpers.IsIdentifierPart(previousChar))
     {
         return(TryAcceptChange(target, change));
     }
     else
     {
         return(PartialParseResult.Rejected);
     }
 }
Esempio n. 4
0
 private PartialParseResultInternal HandleInsertion(SyntaxNode target, char previousChar, SourceChange change)
 {
     // What are we inserting after?
     if (previousChar == '.')
     {
         return(HandleInsertionAfterDot(target, change));
     }
     else if (ParserHelpers.IsIdentifierPart(previousChar) || previousChar == ')' || previousChar == ']')
     {
         return(HandleInsertionAfterIdPart(target, change));
     }
     else if (previousChar == '(')
     {
         return(HandleInsertionAfterOpenParenthesis(target, change));
     }
     else
     {
         return(PartialParseResultInternal.Rejected);
     }
 }
Esempio n. 5
0
        private StateResult Identifier()
        {
            bool isEscaped = false;

            if (CurrentCharacter == '[')
            {
                TakeCurrent();
                isEscaped = true;
            }
            TakeUntil(c => !ParserHelpers.IsIdentifierPart(c));

            // If we're escaped, take the ']'
            if (isEscaped)
            {
                if (CurrentCharacter == ']')
                {
                    TakeCurrent();
                }
            }

            // Check for Keywords and build the symbol
            VBKeyword?keyword = VBKeywordDetector.GetKeyword(Buffer.ToString());

            if (keyword == VBKeyword.Rem)
            {
                return(CommentBody());
            }

            VBSymbol sym = new VBSymbol(
                CurrentStart,
                Buffer.ToString(),
                keyword == null ? VBSymbolType.Identifier : VBSymbolType.Keyword
                )
            {
                Keyword = keyword
            };

            StartSymbol();

            return(Stay(sym));
        }
Esempio n. 6
0
    private PartialParseResultInternal HandleDeletion(SyntaxNode target, char previousChar, SourceChange change)
    {
        // What's left after deleting?
        if (previousChar == '.')
        {
            return(TryAcceptChange(target, change, PartialParseResultInternal.Accepted | PartialParseResultInternal.Provisional));
        }
        else if (ParserHelpers.IsIdentifierPart(previousChar))
        {
            return(TryAcceptChange(target, change));
        }
        else if (previousChar == '(')
        {
            var changeRelativePosition = change.Span.AbsoluteIndex - target.Position;
            if (target.GetContent()[changeRelativePosition] == ')')
            {
                return(PartialParseResultInternal.Accepted | PartialParseResultInternal.Provisional);
            }
        }

        return(PartialParseResultInternal.Rejected);
    }