Top Description Fields Constructors Methods
com.jogamp.gluegen.jcpp

public abstract Class Source

extends Object
implements Iterable<Token>, Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable, java.lang.Iterable
Known Direct Subclasses
com.jogamp.gluegen.jcpp.TokenSnifferSource, com.jogamp.gluegen.jcpp.FixedTokenSource, com.jogamp.gluegen.jcpp.LexerSource, com.jogamp.gluegen.jcpp.MacroTokenSource
Imports
java.io.Closeable, .IOException, java.util.Iterator, javax.annotation.CheckForNull, .Nonnegative, .Nonnull

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.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private PreprocessorListener
private Source
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
protected void
error(final int line, final int column, final String msg)

public int
getColumn()

Returns the current column number within this Source.

public int
getLine()

Returns the current line number within this Source.

public String
getName()

Returns the human-readable name of the current Source.

public final Source
getParent()

Returns the parent source of this source.

public String
getPath()

Returns the File currently being lexed.

pack-priv void
init(final Preprocessor pp)

pack-priv boolean
pack-priv boolean
isAutopop()

Returns true if this Source should be transparently popped from the input stack.

pack-priv boolean
isExpanding(final Macro m)

Returns true if this Source is expanding the given macro.

pack-priv boolean
isNumbered()

Returns true if this source has line numbers.

public Iterator<Token>
iterator()

Implements java.lang.Iterable.iterator.

Returns a token iterator for this Source.
pack-priv void
setActive(final boolean b)

public void
setListener(final PreprocessorListener pl)

Sets the listener for this Source.

pack-priv void
setParent(final Source parent, final boolean autopop)

Sets the parent source of this source.

public Token

Returns:

the NL token.
skipline
(final boolean
true if only whitespace is permitted on the remainder of the line.
white
)

Skips tokens until the end of line.

public abstract Token
token()

Returns the next Token parsed from this input stream.

protected void
warning(final int line, final int column, final String msg)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeback to summary
private boolean active
autopopback to summary
private boolean autopop
listenerback to summary
private PreprocessorListener listener
parentback to summary
private Source parent
werrorback to summary
private boolean werror

Constructor Detail

Sourceback to summary
public Source()

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Exceptions
IOException:
if an I/O error occurs
errorback to summary
protected void error(final int line, final int column, final String msg) throws LexerException
getColumnback to summary
public int getColumn()

Returns the current column number within this Source.

getLineback to summary
public int getLine()

Returns the current line number within this Source.

Annotations
@Nonnegative
getNameback to summary
public String getName()

Returns the human-readable name of the current Source.

Annotations
@CheckForNull
getParentback to summary
public final Source getParent()

Returns the parent source of this source. Sources form a singly linked list.

getPathback to summary
public String getPath()

Returns the File currently being lexed. If this Source is not a FileLexerSource, then it will ask the parent Source, and so forth recursively. If no Source on the stack is a FileLexerSource, returns null.

Annotations
@CheckForNull
initback to summary
pack-priv void init(final Preprocessor pp)
isActiveback to summary
pack-priv boolean isActive()
isAutopopback to summary
pack-priv boolean isAutopop()

Returns true if this Source should be transparently popped from the input stack. Examples of such sources are macro expansions.

isExpandingback to summary
pack-priv boolean isExpanding(final Macro m)

Returns true if this Source is expanding the given macro. This is used to prevent macro recursion.

isNumberedback to summary
pack-priv boolean isNumbered()

Returns true if this source has line numbers.

iteratorback to summary
public Iterator<Token> iterator()

Implements java.lang.Iterable.iterator.

Returns a token iterator for this Source.

Returns:Iterator<Token>

Doc from java.lang.Iterable.iterator.

an Iterator.

Annotations
@Override
setActiveback to summary
pack-priv void setActive(final boolean b)
setListenerback to summary
public void setListener(final 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.

setParentback to summary
pack-priv void setParent(final Source parent, final boolean autopop)

Sets the parent source of this source. Sources form a singly linked list.

skiplineback to summary
public Token skipline(final boolean white) throws IOException, LexerException

Skips tokens until the end of line.

Parameters
white:boolean

true if only whitespace is permitted on the remainder of the line.

Returns:Token

the NL token.

Annotations
@Nonnull
tokenback to summary
public abstract Token token() throws IOException, LexerException

Returns the next Token parsed from this input stream.

Annotations
@Nonnull
See Also
Token
warningback to summary
protected void warning(final int line, final int column, final String msg) throws LexerException