Skip to content

Commit

Permalink
idk
Browse files Browse the repository at this point in the history
something uncommitted most likley trash
  • Loading branch information
DenuxPlays committed Oct 31, 2023
1 parent 4dfb455 commit 5e1090e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/main/java/dev/denux/dtp/internal/reader/TomlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,23 @@ private String readMultilineArray(@Nonnull String str, int currentIndex) {
String line = filterComments(lines.get(i.get())); //check if filterComments actually works here or not
String finalLine = "";
if (breakLoop) break;
for (char c : line.toCharArray()) {
for (int j = 0; j < line.length(); j++) {
char c = line.charAt(j);
char nextChar = j + 1 == line.length() ? ' ' : line.charAt(j + 1);
char previousChar = j == 0 ? ' ' : line.charAt(j - 1);
if (Constant.STRING_INDICATORS.contains(c)) {
//TODO continue here
if (escapeSequence.isEmpty()) {
escapeSequence = String.valueOf(c);
}
if (escapeSequence.equals(String.valueOf(c)) && previousChar != '\\') {
escapeSequence = "";
}
//check if this actually works
String multilineIndicator = String.format("%c%c%c", c, c, c);
if (Constant.MULTILINE_STRING_INDICATORS.contains(multilineIndicator)) {
escapeSequence = multilineIndicator;
}
//TODO more multiline handling
}
if (c == '[' && escapeSequence.isEmpty())
arrayDepth++;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/dev/denux/dtp/util/Constant.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.denux.dtp.util;

import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;

Expand All @@ -10,5 +9,7 @@ private Constant() {}
public static final Pattern RFC3339_REGEX = Pattern.compile("^(\\d{4})-(\\d{2})-(\\d{2})([Tt ](\\d{2}):(\\d{2}):?(\\d{2})?(\\.\\d+)?)?([Zz]|([+-])(\\d{2}):(\\d{2}))?");
public static final Pattern RFC3339_TIME_REGEX = Pattern.compile("^(\\d{2}):(\\d{2}):?(\\d{2})?(\\.\\d*)?");

public static final List<Character> STRING_INDICATORS = Arrays.asList('"', '\'');
public static final List<Character> STRING_INDICATORS = List.of('"', '\'');

public static final List<String> MULTILINE_STRING_INDICATORS = List.of("\"\"\"", "'''");
}

0 comments on commit 5e1090e

Please sign in to comment.