Class LexSimpleAnalyzerUtils


  • class LexSimpleAnalyzerUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String guessClass​(java.lang.String line)  
      private static java.lang.String guessIncluded​(java.lang.String line)  
      private static java.util.Set<java.io.File> guessIncludes​(java.io.File file)
      Processes a file for %include directives.
      private static java.lang.String guessPackage​(java.lang.String line)  
      (package private) static SpecInfo guessSpecInfo​(java.io.File lexFile)
      Guesses package and class name, and %include files, based on this grammar definition.
      (package private) static SpecInfo guessSpecInfo​(java.io.Reader lexFileReader, java.io.File lexFile)
      Guesses package and class name, and %include files, based on this grammar definition.
      (package private) static java.util.Set<java.io.File> mapFiles​(java.util.Set<java.lang.String> set, java.io.File parent)
      Resolves path names relative to parent.
      private static java.util.Set<java.io.File> nestedIncludes​(java.util.Set<java.io.File> seen, java.io.File file)
      Recursively processes a file for %include directives.
      (package private) static java.util.Set<java.lang.String> parseIncludes​(java.io.Reader fileReader)
      Parses input for %include directives.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INCLUDE_DIRECTIVE_MATCHER

        private static final java.util.regex.Pattern INCLUDE_DIRECTIVE_MATCHER
      • INCLUDE_DIRECTIVE_ARG_OFFSET

        private static final int INCLUDE_DIRECTIVE_ARG_OFFSET
        See Also:
        Constant Field Values
    • Constructor Detail

      • LexSimpleAnalyzerUtils

        private LexSimpleAnalyzerUtils()
    • Method Detail

      • guessSpecInfo

        static SpecInfo guessSpecInfo​(java.io.File lexFile)
                               throws java.io.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:
        java.io.FileNotFoundException - if the lex file does not exist
        java.io.IOException - when an IO exception occurred while reading a file.
      • guessSpecInfo

        static SpecInfo guessSpecInfo​(java.io.Reader lexFileReader,
                                      java.io.File lexFile)
                               throws java.io.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:
        java.io.IOException - when an IO exception occurred while processing the reader. Ignores IO errors for %incude files.
      • guessIncludes

        private static java.util.Set<java.io.File> guessIncludes​(java.io.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 java.util.Set<java.io.File> nestedIncludes​(java.util.Set<java.io.File> seen,
                                                                  java.io.File file)
        Recursively processes a file for %include directives.
        Parameters:
        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.
        seen - the set of files seen so far, to avoid following cycles.
        Returns:
        the set of files (recursively) mentioned in %includes.
      • mapFiles

        static java.util.Set<java.io.File> mapFiles​(java.util.Set<java.lang.String> set,
                                                    java.io.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 java.util.Set<java.lang.String> parseIncludes​(java.io.Reader fileReader)
                                                      throws java.io.IOException
        Parses input for %include directives.
        Parameters:
        fileReader - the input
        Returns:
        the set of path names mentioned after %include directives in the input.
        Throws:
        java.io.IOException
      • guessClass

        @Nullable
        private static java.lang.String guessClass​(java.lang.String line)
      • guessPackage

        @Nullable
        private static java.lang.String guessPackage​(java.lang.String line)
      • guessIncluded

        @Nullable
        private static java.lang.String guessIncluded​(java.lang.String line)