private StateResult OctLiteral() { AssertCurrent('&'); TakeCurrent(); Debug.Assert(Char.ToLowerInvariant(CurrentCharacter) == 'o'); TakeCurrent(); TakeUntil(c => !VBHelpers.IsOctalDigit(c)); TakeIntTypeSuffix(); return(Stay(EndSymbol(VBSymbolType.IntegerLiteral))); }
private StateResult QuotedLiteral() { TakeUntil(c => VBHelpers.IsDoubleQuote(c) || ParserHelpers.IsNewLine(c)); if (VBHelpers.IsDoubleQuote(CurrentCharacter)) { TakeCurrent(); if (VBHelpers.IsDoubleQuote(CurrentCharacter)) { // Escape sequence, remain in the string TakeCurrent(); return(Stay()); } } VBSymbolType type = VBSymbolType.StringLiteral; if (Char.ToLowerInvariant(CurrentCharacter) == 'c') { TakeCurrent(); type = VBSymbolType.CharacterLiteral; } return(Transition(EndSymbol(type), Data)); }
private StateResult Data() { // We are accepting more characters and whitespace/newlines then the VB Spec defines, to simplify things // Since the code must still be compiled by a VB compiler, this will not cause adverse effects. if (ParserHelpers.IsNewLine(CurrentCharacter)) { // VB Spec §2.1.1 bool checkTwoCharNewline = CurrentCharacter == '\r'; TakeCurrent(); if (checkTwoCharNewline && CurrentCharacter == '\n') { TakeCurrent(); } return(Stay(EndSymbol(VBSymbolType.NewLine))); } else if (ParserHelpers.IsWhitespace(CurrentCharacter)) { // CSharp Spec §2.1.3 TakeUntil(c => !ParserHelpers.IsWhitespace(c)); return(Stay(EndSymbol(VBSymbolType.WhiteSpace))); } else if (VBHelpers.IsSingleQuote(CurrentCharacter)) { TakeCurrent(); return(CommentBody()); } else if (IsIdentifierStart()) { return(Identifier()); } else if (Char.IsDigit(CurrentCharacter)) { return(DecimalLiteral()); } else if (CurrentCharacter == '&') { char next = Char.ToLower(Peek(), CultureInfo.InvariantCulture); if (next == 'h') { return(HexLiteral()); } else if (next == 'o') { return(OctLiteral()); } } else if (CurrentCharacter == '.' && Char.IsDigit(Peek())) { return(FloatingPointLiteralEnd()); } else if (VBHelpers.IsDoubleQuote(CurrentCharacter)) { TakeCurrent(); return(Transition(QuotedLiteral)); } else if (AtDateLiteral()) { return(DateLiteral()); } else if (CurrentCharacter == '@') { TakeCurrent(); if (CurrentCharacter == '*') { return(Transition(EndSymbol(VBSymbolType.RazorCommentTransition), AfterRazorCommentTransition)); } else if (CurrentCharacter == '@') { // Could be escaped comment transition return(Transition(EndSymbol(VBSymbolType.Transition), () => { TakeCurrent(); return Transition(EndSymbol(VBSymbolType.Transition), Data); })); } else { return(Stay(EndSymbol(VBSymbolType.Transition))); } } return(Stay(EndSymbol(Operator()))); }