Class Scanner

java.lang.Object
org.codehaus.janino.Scanner

public class Scanner extends Object
Splits up a character stream into tokens and returns them as String objects.
  • Field Details

    • SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE

      public static final String SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE
      Setting this system property to 'true' enables source-level debugging. Typically, this means that compilation is executed with "-g:all" instead of "-g:none".
      See Also:
    • SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR

      public static final String SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR
      If the source code is not read from a file, debuggers have a hard time locating the source file for source-level debugging. As a workaround, a copy of the source code is written to a temporary file, which must be included in the debugger's source path. If this system property is set, the temporary source file is created in that directory, otherwise in the default temporary-file directory.
      See Also:
    • SYSTEM_PROPERTY_SOURCE_DEBUGGING_KEEP

      public static final String SYSTEM_PROPERTY_SOURCE_DEBUGGING_KEEP
      If set to "true", then the temporary source code files are not deleted on exit. That may be useful to interpret stack traces offline.
      See Also:
    • sb

      private final StringBuilder sb
      Holds the characters of the currently scanned token.
    • fileName

      @Nullable private final String fileName
    • in

      private final Reader in
    • ignoreWhiteSpace

      private boolean ignoreWhiteSpace
    • nextChar

      private int nextChar
    • nextButOneChar

      private int nextButOneChar
    • crLfPending

      private boolean crLfPending
    • nextCharLineNumber

      private int nextCharLineNumber
    • nextCharColumnNumber

      private int nextCharColumnNumber
    • tokenLineNumber

      private int tokenLineNumber
      Line number of the previously produced token (typically starting at one).
    • tokenColumnNumber

      private int tokenColumnNumber
      Column number of the first character of the previously produced token (1 if token is immediately preceded by a line break).
    • JAVA_KEYWORDS

      private static final Set<String> JAVA_KEYWORDS
    • JAVA_OPERATORS

      private static final Set<String> JAVA_OPERATORS
  • Constructor Details

    • Scanner

      @Deprecated public Scanner(String fileName) throws IOException
      Deprecated.
      This method is deprecated because it leaves the input file open
      Throws:
      IOException
    • Scanner

      @Deprecated public Scanner(String fileName, String encoding) throws IOException
      Deprecated.
      This method is deprecated because it leaves the input file open
      Throws:
      IOException
    • Scanner

      @Deprecated public Scanner(File file) throws IOException
      Deprecated.
      This method is deprecated because it leaves the input file open
      Throws:
      IOException
    • Scanner

      @Deprecated public Scanner(File file, @Nullable String encoding) throws IOException
      Deprecated.
      This method is deprecated because it leaves the input file open
      Throws:
      IOException
    • Scanner

      public Scanner(@Nullable String fileName, InputStream is) throws IOException
      Sets up a scanner that reads tokens from the given InputStream in the platform default encoding.

      The fileName is solely used for reporting in thrown exceptions.

      Throws:
      IOException
    • Scanner

      public Scanner(@Nullable String fileName, InputStream is, @Nullable String encoding) throws IOException
      Sets up a scanner that reads tokens from the given InputStream with the given encoding (null means platform default encoding).

      The fileName is used for reporting errors during compilation and for source level debugging, and should name an existing file. If null is passed, and the system property org.codehaus.janino.source_debugging.enable is set to "true", then a temporary file in org.codehaus.janino.source_debugging.dir or the system's default temp dir is created in order to make the source code available to a debugger.

      Throws:
      IOException
    • Scanner

      public Scanner(@Nullable String fileName, Reader in) throws IOException
      Sets up a scanner that reads tokens from the given Reader.

      The fileName is used for reporting errors during compilation and for source level debugging, and should name an existing file. If null is passed, and the system property org.codehaus.janino.source_debugging.enable is set to "true", then a temporary file in org.codehaus.janino.source_debugging.dir or the system's default temp dir is created in order to make the source code available to a debugger.

      Throws:
      IOException
    • Scanner

      public Scanner(@Nullable String fileName, Reader in, int initialLineNumber, int initialColumnNumber) throws IOException
      Creates a Scanner that counts lines and columns from non-default initial values.
      Throws:
      IOException
  • Method Details