Class FileParser

java.lang.Object
io.github.syst3ms.skriptparser.file.FileParser

public class FileParser extends Object
A class for parsing a plaintext file into a list of FileElements representing every line.
  • Field Details

    • LINE_PATTERN

      public static final Pattern LINE_PATTERN
  • Constructor Details

    • FileParser

      public FileParser()
  • Method Details

    • parseFileLines

      public static List<FileElement> parseFileLines(String fileName, List<String> lines, int expectedIndentation, int lastLine, SkriptLogger logger)
      Parses a List of strings into a list of FileElements. This creates FileElement and FileSection objects from the lines, effectively structuring the lines into a tree. This removes comments from each line, and discards any blank lines afterwards.
      Parameters:
      fileName - the name of the file the lines belong to
      lines - the list of lines to parse
      expectedIndentation - the indentation level the first line is expected to be at
      lastLine - a parameter that keeps track of the line count throughout recursive calls of this method when parsing sections
      logger - the logger
      Returns:
      a list of FileElements