private bool IsLineBreak(CharacterCodes ch) { return(ch == CharacterCodes.lineFeed || ch == CharacterCodes.carriageReturn || ch == CharacterCodes.lineSeparator || ch == CharacterCodes.paragraphSeparator); }
private bool IsWhiteSpaceSingleLine(CharacterCodes ch) { return(ch == CharacterCodes.space || ch == CharacterCodes.tab || ch == CharacterCodes.verticalTab || ch == CharacterCodes.formFeed || ch == CharacterCodes.nonBreakingSpace || ch == CharacterCodes.nextLine || ch == CharacterCodes.ogham || ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace || ch == CharacterCodes.narrowNoBreakSpace || ch == CharacterCodes.mathematicalSpace || ch == CharacterCodes.ideographicSpace || ch == CharacterCodes.byteOrderMark); }
/// <nodoc/> public static string FromCharCode(this CharacterCodes code) { // TODO: Optimize return(((char)code).ToString()); }
private bool IsIdentifierStart(CharacterCodes ch) { return(ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z || ch == CharacterCodes.at || ch == CharacterCodes._); }
private bool IsDigit(CharacterCodes ch) { return(ch >= CharacterCodes._0 && ch <= CharacterCodes._9); }
public SyntaxKind Scan() { startPos = pos; hasExtendedUnicodeEscape = false; precedingLineBreak = false; tokenIsUnterminated = false; currentTokenValue = null; while (true) { tokenPos = pos; if (pos >= end) { return(SyntaxKind.EndOfFileToken); } chCurrent = text.CharCodeAt(pos); switch (chCurrent) { case CharacterCodes.space: if (skipTrivia) { pos++; continue; } else { while (pos < end && IsWhiteSpaceSingleLine(text.CharCodeAt(pos))) { pos++; } return(token = SyntaxKind.WhitespaceTrivia); } case CharacterCodes._1: case CharacterCodes._2: case CharacterCodes._3: case CharacterCodes._4: case CharacterCodes._5: case CharacterCodes._6: case CharacterCodes._7: case CharacterCodes._8: case CharacterCodes._9: tokenValue = ScanNumber(); return(token = SyntaxKind.NumericLiteral); case CharacterCodes.dot: pos++; return(token = SyntaxKind.DotToken); case CharacterCodes.openBracket: pos++; return(token = SyntaxKind.OpenBracketToken); case CharacterCodes.closeBracket: pos++; return(token = SyntaxKind.CloseBracketToken); case CharacterCodes.openParen: pos++; return(token = SyntaxKind.OpenParenToken); case CharacterCodes.closeParen: pos++; return(token = SyntaxKind.CloseParenToken); case CharacterCodes.comma: pos++; return(token = SyntaxKind.CommaToken); case CharacterCodes.backtick: pos++; return(token = SyntaxKind.CLRStringArgCountSpecifier); default: if (IsIdentifierStart(chCurrent)) { pos++; while (pos < end && IsIdentifierPart((chCurrent = text.CharCodeAt(pos)))) { pos++; } tokenValue = text.Substring(tokenPos, pos - tokenPos); if (chCurrent == CharacterCodes.backslash) { tokenValue += ScanIdentifierParts(); } currentTokenValue = tokenValue; return(token = GetIdentifierToken()); } else if (IsWhiteSpaceSingleLine(chCurrent)) { pos++; continue; } else if (IsLineBreak(chCurrent)) { precedingLineBreak = true; pos++; continue; } Debugger.Break(); pos++; return(token = SyntaxKind.Unknown); } } }