public interface Source
A "Source" represents a range of CTokens (post-preprocessor tokens) from the
token stream that forms the input to the parser. Typical use: a Source object
is associated to each node in an AST to report useful error messages to the
user when a syntax error occurs.
-
Method Summary
Modifier and TypeMethodDescriptiongetContent(boolean abbreviated) Returns the first token in the range of tokens represented by this Source.Returns the last token in the range of tokens represented by this Source.getLocation(boolean abbreviated) Returns location information only (not actual source text).intReturns the number of tokens represented by this Source.getSummary(boolean abbreviated, boolean multiline) Returns summary of location and text.voidprint(PrintStream out) tokens()Returns an iterator over the tokens represented by this Source.toString()Returns a human-readable string representation of this range of source data.
-
Method Details
-
getFirstToken
CivlcToken getFirstToken()Returns the first token in the range of tokens represented by this Source.- Returns:
- the first token
-
getLastToken
CivlcToken getLastToken()Returns the last token in the range of tokens represented by this Source.- Returns:
- the last token
-
tokens
Iterator<CivlcToken> tokens()Returns an iterator over the tokens represented by this Source.- Returns:
- an iterator over the tokens
-
getNumTokens
int getNumTokens()Returns the number of tokens represented by this Source.- Returns:
- the number of tokens
-
toString
String toString()Returns a human-readable string representation of this range of source data. -
print
-
getLocation
Returns location information only (not actual source text). For example "foo.c:127.4-128.1".- Parameters:
abbreviated- true iff want to have the shorter file name, e.g, "f1:127.4-128.1" instead of "longOrignialFile.c:127.4-128.1"
-
getSummary
Returns summary of location and text.- Parameters:
abbreviated- true iff want to have the shorter file name in the location, e.g, "f1:127.4-128.1" instead of "longOrignialFile.c:127.4-128.1"isException- true iff want to print the detailed information for a thrown exception.- Returns:
- summary of location and text
-
getContent
-