private void Append(char[] content) { for (int i = 0; i < content.Length; i++) { AppendCore(content[i]); // \r on it's own: Start a new line, otherwise wait for \n // Other Newline: Start a new line if ((content[i] == '\r' && (i + 1 == content.Length || content[i + 1] != '\n')) || (content[i] != '\r' && ParserHelpers.IsNewLine(content[i]))) { PushNewLine(); } } }
private StateResult Data() { if (ParserHelpers.IsNewLine(CurrentCharacter)) { // CSharp Spec §2.3.1 var checkTwoCharNewline = CurrentCharacter == '\r'; TakeCurrent(); if (checkTwoCharNewline && CurrentCharacter == '\n') { TakeCurrent(); } return(Stay(EndSymbol(CSharpSymbolType.NewLine))); } else if (ParserHelpers.IsWhitespace(CurrentCharacter)) { // CSharp Spec §2.3.3 TakeUntil(c => !ParserHelpers.IsWhitespace(c)); return(Stay(EndSymbol(CSharpSymbolType.WhiteSpace))); } else if (IsIdentifierStart(CurrentCharacter)) { return(Identifier()); } else if (char.IsDigit(CurrentCharacter)) { return(NumericLiteral()); } switch (CurrentCharacter) { case '@': return(AtSymbol()); case '\'': TakeCurrent(); return(Transition(CSharpTokenizerState.QuotedCharacterLiteral)); case '"': TakeCurrent(); return(Transition(CSharpTokenizerState.QuotedStringLiteral)); case '.': if (char.IsDigit(Peek())) { return(RealLiteral()); } return(Stay(Single(CSharpSymbolType.Dot))); case '/': TakeCurrent(); if (CurrentCharacter == '/') { TakeCurrent(); return(SingleLineComment()); } else if (CurrentCharacter == '*') { TakeCurrent(); return(Transition(CSharpTokenizerState.BlockComment)); } else if (CurrentCharacter == '=') { TakeCurrent(); return(Stay(EndSymbol(CSharpSymbolType.DivideAssign))); } else { return(Stay(EndSymbol(CSharpSymbolType.Slash))); } default: return(Stay(EndSymbol(Operator()))); } }
// CSharp Spec §2.3.2 private StateResult SingleLineComment() { TakeUntil(c => ParserHelpers.IsNewLine(c)); return(Stay(EndSymbol(CSharpSymbolType.Comment))); }
// CSharp Spec §2.3.2 private StateResult SingleLineComment() { TakeUntil(c => ParserHelpers.IsNewLine(c)); return(Stay(EndToken(SyntaxKind.CSharpComment))); }