protected CodeBlockInfo ParseBlockStart(bool isTopLevel, bool captureTransition) { // Capture the transition token, if any, into a span Span transitionSpan = null; if (HaveContent && captureTransition) { transitionSpan = TransitionSpan.Create(Context, hidden: false, acceptedCharacters: AcceptedCharacters.None); Context.ResetBuffers(); } SourceLocation start = CurrentLocation; string identifier = Context.AcceptIdentifier(); Span initialSpan = null; if (isTopLevel) { initialSpan = CodeSpan.Create(Context); Context.ResetBuffers(); } CodeBlockInfo block = new CodeBlockInfo(identifier, start, isTopLevel, transitionSpan, initialSpan); return(block); }
protected AcceptedCharacters AcceptDottedExpression(bool isWithinCode, bool expectIdentifierFirst, params char[] allowedBrackets) { if (!expectIdentifierFirst || ParserHelpers.IsIdentifierStart(CurrentCharacter)) { do { // Parse Parentheses or Brackets if we see them do { if (!allowedBrackets.Any(c => CurrentCharacter == c)) { break; } // Dev10 884975 - Incorrect Error Messaging SourceLocation bracketStart = CurrentLocation; char bracket = CurrentCharacter; if (!BalanceBrackets(allowTransition: true, spanFactory: CreateImplicitExpressionSpanFactory(isWithinCode))) { // Balancing terminated because of EOF char terminator = _bracketPairs[bracket]; Context.AcceptCurrent(); TryRecover(RecoveryModes.Any); OnError(bracketStart, RazorResources.ParseError_Expected_CloseBracket_Before_EOF, bracket, terminator); return(AcceptedCharacters.Any); } } while (!EndOfFile); // If the next character is a dot, followed by an identifier start, keep on parsing using (Context.StartTemporaryBuffer()) { if (CurrentCharacter != '.') { break; } Context.AcceptCurrent(); if (!ParserHelpers.IsIdentifierStart(CurrentCharacter)) { if (isWithinCode) { Context.AcceptTemporaryBuffer(); } break; } Context.AcceptTemporaryBuffer(); // Put the dot in the primary buffer } // Parse an identifier Context.AcceptIdentifier(); } while (!EndOfFile); } return(AcceptedCharacters.NonWhiteSpace); }
protected void AcceptTypeName(bool allowGenerics) { do { if (CurrentCharacter == '.') { Context.AcceptCurrent(); } Context.AcceptIdentifier(); if (allowGenerics) { AcceptGenericArgument(); } } while (CurrentCharacter == '.'); }