- 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
Modifier and TypeFieldDescriptionstatic final List<SourceChar>
The empty unmodifiable list ofSourceChar
objects.static final SourceChar
TheSourceChar
object representing the end of the source file. -
Method Summary
-
Field Details
-
EMPTY_LIST
The empty unmodifiable list ofSourceChar
objects. -
STATIC_EOF
TheSourceChar
object representing the end of the source file.This object behaves as follows:
- The
isEof()
method returnstrue
- The
toChar()
andgetSpan()
methods throw anIllegalStateException
- The
getChildren()
method returnsEMPTY_LIST
Do not compare a
SourceChar
object 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
-
isEof
boolean isEof()Returns whether this object represents EOF.- Returns:
true
if this represents EOF.
-
toChar
char toChar()Returns achar
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.
-