Package com.jogamp.gluegen.jcpp
Class Source
- java.lang.Object
-
- com.jogamp.gluegen.jcpp.Source
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<Token>
- Direct Known Subclasses:
LexerSource
public abstract class Source extends Object implements Iterable<Token>, Closeable
An input to the Preprocessor. Inputs may come from Files, Strings or other sources. The preprocessor maintains a stack of Sources. Operations such as file inclusion or token pasting will push a new source onto the Preprocessor stack. Sources pop from the stack when they are exhausted; this may be transparent or explicit. BUG: Error messages are not handled properly.
-
-
Constructor Summary
Constructors Constructor Description Source()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
protected void
error(int line, int column, String msg)
int
getColumn()
Returns the current column number within this Source.int
getLine()
Returns the current line number within this Source.String
getName()
Returns the human-readable name of the current Source.Source
getParent()
Returns the parent source of this source.String
getPath()
Returns the File currently being lexed.Iterator<Token>
iterator()
Returns a token iterator for this Source.void
setListener(PreprocessorListener pl)
Sets the listener for this Source.Token
skipline(boolean white)
Skips tokens until the end of line.abstract Token
token()
Returns the next Token parsed from this input stream.protected void
warning(int line, int column, String msg)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getParent
public final Source getParent()
Returns the parent source of this source. Sources form a singly linked list.
-
setListener
public void setListener(PreprocessorListener pl)
Sets the listener for this Source. Normally this is set by the Preprocessor when a Source is used, but if you are using a Source as a standalone object, you may wish to call this.
-
getPath
@CheckForNull public String getPath()
Returns the File currently being lexed. If this Source is not aFileLexerSource
, then it will ask the parent Source, and so forth recursively. If no Source on the stack is a FileLexerSource, returns null.
-
getName
@CheckForNull public String getName()
Returns the human-readable name of the current Source.
-
getLine
@Nonnegative public int getLine()
Returns the current line number within this Source.
-
getColumn
public int getColumn()
Returns the current column number within this Source.
-
token
@Nonnull public abstract Token token() throws IOException, LexerException
Returns the next Token parsed from this input stream.- Throws:
IOException
LexerException
- See Also:
Token
-
skipline
@Nonnull public Token skipline(boolean white) throws IOException, LexerException
Skips tokens until the end of line.- Parameters:
white
- true if only whitespace is permitted on the remainder of the line.- Returns:
- the NL token.
- Throws:
IOException
LexerException
-
error
protected void error(int line, int column, String msg) throws LexerException
- Throws:
LexerException
-
warning
protected void warning(int line, int column, String msg) throws LexerException
- Throws:
LexerException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-