- 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
FieldsModifier and TypeFieldDescriptionstatic final List<SourceChar> The empty unmodifiable list ofSourceCharobjects.static final SourceCharDeprecated.Not for public use in the future. -
Method Summary
-
Field Details
-
EMPTY_LIST
The empty unmodifiable list ofSourceCharobjects. -
STATIC_EOF
Deprecated.Not for public use in the future. This field is expected to be removed.TheSourceCharobject representing the end of the source file.This object behaves as follows:
- The
isEof()method returnstrue - The
getFilename()method returnsnull - The
toChar()andgetSpan()methods throw anIllegalStateException - The
getChildren()method returnsEMPTY_LIST
Do not compare a
SourceCharobject with this object to determine whether it is EOF or not. Use theisEof()method instead.Note that this is an immutable object.
- The
-
-
Method Details
-
getFilename
String getFilename()Returns the filename.- Returns:
- The filename. Or
nullif no filename is specified.
-
isEof
boolean isEof()Returns whether this object represents EOF.- Returns:
trueif this represents EOF.
-
toChar
char toChar()Returns acharvalue corresponding to this object.This method throws an
IllegalStateExceptionif this object represents EOF.- Returns:
- The
charvalue. - 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
IllegalStateExceptionif 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_LISTif this object has no child characters.
-