Interface SourceChar

All Known Implementing Classes:
Eof

public interface SourceChar
A character of the source file or EOF.

The SourceChar object represents a character that composes the token or EOF. It may also have one or more child characters in some cases. For example, it is the case that it represents:

  • the character which is substituted for any digraph or trigraph sequence
  • the character that follows a backslash (\) at the end of the line
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final List<SourceChar>
    The empty unmodifiable list of SourceChar objects.
    static final SourceChar
    Deprecated.
    Not for public use in the future.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the child characters.
    Returns the filename.
    Returns location of this object in the source file.
    boolean
    Returns whether this object represents EOF.
    char
    Returns a char value corresponding to this object.
  • Field Details

  • Method Details

    • getFilename

      String getFilename()
      Returns the filename.
      Returns:
      The filename. Or null if no filename is specified.
    • isEof

      boolean isEof()
      Returns whether this object represents EOF.
      Returns:
      true if this represents EOF.
    • toChar

      char toChar()
      Returns a char value corresponding to this object.

      This method throws an IllegalStateException if this object represents EOF.

      Returns:
      The char value.
      Throws:
      IllegalStateException - If this object represents EOF.
    • getSpan

      SourceSpan getSpan()
      Returns location of this object in the source file.

      If this object has its child characters, its location depends on their location. So, its location may represent a range of the characters.

      This method throws an IllegalStateException if this object represents EOF.

      Returns:
      The location.
      Throws:
      IllegalStateException - If this object represents EOF and has no child characters.
    • getChildren

      List<SourceChar> getChildren()
      Returns the child characters.
      Returns:
      The unmodifiable list containing the child characters, or EMPTY_LIST if this object has no child characters.