java.lang.Object
io.github.ocelot.glslprocessor.lib.anarres.cpp.Source
Direct Known Subclasses:
LexerSource

@Internal public abstract class Source extends Object
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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    error(int line, int column, String msg)
     
    int
    Returns the current column number within this Source.
    int
    Returns the current line number within this Source.
    @Nullable String
    Returns the human-readable name of the current Source.
    skipline(boolean white)
    Skips tokens until the end of line.
    abstract 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
  • Constructor Details

    • Source

      public Source()
  • Method Details

    • getName

      @Nullable public @Nullable String getName()
      Returns the human-readable name of the current Source.
    • getLine

      public int getLine()
      Returns the current line number within this Source.
    • getColumn

      public int getColumn()
      Returns the current column number within this Source.
    • token

      public abstract Token token() throws LexerException
      Returns the next Token parsed from this input stream.
      Throws:
      LexerException
      See Also:
    • skipline

      public Token skipline(boolean white) throws 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:
      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