Module dev.civl.abc

Interface Source


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 Type
    Method
    Description
    getContent(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).
    int
    Returns the number of tokens represented by this Source.
    getSummary(boolean abbreviated, boolean multiline)
    Returns summary of location and text.
    void
     
    Returns an iterator over the tokens represented by this Source.
    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.
      Overrides:
      toString in class Object
      Returns:
      user-friendly readable representation
    • print

      void print(PrintStream out)
    • getLocation

      String getLocation(boolean abbreviated)
      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

      String getSummary(boolean abbreviated, boolean multiline)
      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

      String getContent(boolean abbreviated)