public StringState(IScanner scanner) { _buffer = StringBuilderPool.Pull(); _scanner = scanner; _start = scanner.Position; _errors = null; }
/// <summary> /// Converts the matrix to a string. /// </summary> public static String This <T>(T[,] value) { var sb = StringBuilderPool.Pull(); var rows = value.GetLength(0); var cols = value.GetLength(1); sb.Append('['); for (var i = 0; i < rows; i++) { if (i > 0) { sb.Append(';'); } for (var j = 0; j < cols; j++) { if (j > 0) { sb.Append(','); } sb.Append(This(value[i, j])); } } sb.Append(']'); return(sb.Stringify()); }
public String Serialize(Object value) { var sb = StringBuilderPool.Pull(); SerializeTo(value, sb, 0); return(sb.Stringify()); }
private static IToken ScanName(IScanner scanner) { var position = scanner.Position; var sb = StringBuilderPool.Pull(); var current = scanner.Current; var canContinue = true; do { sb.Append(Char.ConvertFromUtf32(current)); if (!scanner.MoveNext()) { canContinue = false; break; } current = scanner.Current; }while (current.IsName()); if (canContinue) { scanner.MoveBack(); } var name = sb.Stringify(); var type = Keywords.IsKeyword(name) ? TokenType.Keyword : TokenType.Identifier; return(new IdentToken(type, name, position, scanner.Position)); }
/// <summary> /// Converts the matrix to a string. /// </summary> public static String This(Double[,] value) { var sb = StringBuilderPool.Pull(); var rows = value.GetLength(0); var cols = value.GetLength(1); sb.Append('['); for (var i = 0; i < rows; i++) { if (i > 0) { sb.Append(';'); } for (var j = 0; j < cols; j++) { if (j > 0) { sb.Append(','); } sb.Append(value[i, j].ToString(CultureInfo.InvariantCulture)); } } sb.Append(']'); return(sb.Stringify()); }
/// <summary> /// Converts the given matrix to a JSON string. /// </summary> /// <param name="matrix">The matrix to represent.</param> /// <returns>The JSON representation.</returns> public static String AsJson(Double[,] matrix) { var sb = StringBuilderPool.Pull(); var rows = matrix.GetRows(); var cols = matrix.GetColumns(); sb.Append('['); for (var i = 0; i < rows; i++) { if (i > 0) { sb.Append(", "); } sb.Append('['); for (var j = 0; j < cols; j++) { if (j > 0) { sb.Append(", "); } sb.Append(This(matrix[i, j])); } sb.Append(']'); } sb.Append(']'); return(sb.Stringify()); }
public StringState(IScanner scanner, Boolean literal) { _buffer = StringBuilderPool.Pull(); _scanner = scanner; _start = scanner.Position; _errors = null; _literal = literal; }
public StringState(IScanner scanner, ITokenizer tokenizer) { _buffer = StringBuilderPool.Pull(); _scanner = scanner; _start = scanner.Position; _errors = null; _parts = new List <List <IToken> >(); _tokenizer = tokenizer; }
private static IToken ScanLine(IScanner scanner, TextPosition start) { var sb = StringBuilderPool.Pull(); while (scanner.MoveNext() && scanner.Current != CharacterTable.LineFeed) { sb.Append(Char.ConvertFromUtf32(scanner.Current)); } return(new CommentToken(TokenType.Comment, sb.Stringify(), start, scanner.Position)); }
private IToken Preprocessor(IScanner scanner) { var start = scanner.Position; var sb = StringBuilderPool.Pull(); while (scanner.MoveNext()) { var current = scanner.Current; if (current == CharacterTable.LineFeed) { break; } sb.Append(Char.ConvertFromUtf32(current)); } var end = scanner.Position; var payload = sb.Stringify(); return(new PreprocessorToken(payload, start, end)); }
private static IToken ScanBlock(IScanner scanner, TextPosition start) { var sb = StringBuilderPool.Pull(); while (scanner.MoveNext()) { if (scanner.Current == CharacterTable.Asterisk) { if (!scanner.MoveNext() || scanner.Current == CharacterTable.Slash) { break; } else { sb.Append(Char.ConvertFromUtf32(CharacterTable.Asterisk)); } } sb.Append(Char.ConvertFromUtf32(scanner.Current)); } return(new CommentToken(TokenType.Comment, sb.Stringify(), start, scanner.Position)); }