Class LexSimpleAnalyzerUtils

java.lang.Object
jflex.maven.plugin.jflex.LexSimpleAnalyzerUtils

class LexSimpleAnalyzerUtils extends Object
  • Field Details

    • DEFAULT_NAME

      static final String DEFAULT_NAME
      See Also:
    • INCLUDE_DIRECTIVE_MATCHER

      private static final Pattern INCLUDE_DIRECTIVE_MATCHER
    • INCLUDE_DIRECTIVE_ARG_OFFSET

      private static final int INCLUDE_DIRECTIVE_ARG_OFFSET
      See Also:
  • Constructor Details

    • LexSimpleAnalyzerUtils

      private LexSimpleAnalyzerUtils()
  • Method Details

    • guessSpecInfo

      static SpecInfo guessSpecInfo(File lexFile) throws IOException
      Guesses package and class name, and %include files, based on this grammar definition.
      Parameters:
      lexFile - the lex spec to process
      Returns:
      collected info about this lex spec.
      Throws:
      FileNotFoundException - if the lex file does not exist
      IOException - when an IO exception occurred while reading a file.
    • guessSpecInfo

      static SpecInfo guessSpecInfo(Reader lexFileReader, File lexFile) throws IOException
      Guesses package and class name, and %include files, based on this grammar definition.
      Parameters:
      lexFileReader - reader for lex spec to process
      lexFile - the lex spec to process, used for relative path name resolution of %incudes.
      Returns:
      collected info about this lex spec.
      Throws:
      IOException - when an IO exception occurred while processing the reader. Ignores IO errors for %incude files.
    • guessIncludes

      private static Set<File> guessIncludes(File file)
      Processes a file for %include directives.
      Parameters:
      file - the lex file to process.
      Returns:
      the set of files (recursively) mentioned in %includes.
    • nestedIncludes

      private static Set<File> nestedIncludes(Set<File> seen, File file)
      Recursively processes a file for %include directives.
      Parameters:
      seen - the set of files seen so far, to avoid following cycles.
      file - the file to process; itself assumed to be an %include or lex file. Path names in the file are relative to the file location.
      Returns:
      the set of files (recursively) mentioned in %includes.
    • mapFiles

      static Set<File> mapFiles(Set<String> set, File parent)
      Resolves path names relative to parent.
      Parameters:
      set - a set of relative path names
      parent - the parent file of these path names
      Returns:
      the set of files relative to parent
    • parseIncludes

      static Set<String> parseIncludes(Reader fileReader) throws IOException
      Parses input for %include directives.
      Parameters:
      fileReader - the input
      Returns:
      the set of path names mentioned after %include directives in the input.
      Throws:
      IOException
    • guessClass

      @Nullable private static String guessClass(String line)
    • guessPackage

      @Nullable private static String guessPackage(String line)
    • guessIncluded

      @Nullable private static String guessIncluded(String line)