Class DatalogTokenizer

java.lang.Object
edu.harvard.seas.pl.abcdatalog.parser.DatalogTokenizer

public class DatalogTokenizer extends Object
A tokenizer for Datalog.

The character '%' begins a single line comment. Newlines are treated like normal whitespace, to the effect that a clause can extend over multiple lines. Alphanumeric characters and underscores are grouped together, but other punctuation is tokenized character by character.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a stream of Datalog tokens from a Reader.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Attempts to consume the supplied string from the beginning of the token stream.
    boolean
    Returns whether there is another token in this stream.
    Returns (and consumes) the next token in this stream.
    Returns the next token in this stream without consuming it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DatalogTokenizer

      public DatalogTokenizer(Reader r)
      Construct a stream of Datalog tokens from a Reader.
      Parameters:
      r - the Reader
  • Method Details

    • consume

      public void consume(String s) throws DatalogParseException
      Attempts to consume the supplied string from the beginning of the token stream. An exception is thrown if the string does not match the token stream. The string must describe complete (i.e. not partial) tokens.
      Parameters:
      s - the string representation of the tokens to be consumed
      Throws:
      DatalogParseException
    • peek

      public String peek() throws DatalogParseException
      Returns the next token in this stream without consuming it. Throws an exception if at EOF.
      Returns:
      the string representation of token
      Throws:
      DatalogParseException
    • next

      public String next() throws DatalogParseException
      Returns (and consumes) the next token in this stream. Throws an exception if at EOF.
      Returns:
      the string representation of token
      Throws:
      DatalogParseException
    • hasNext

      public boolean hasNext() throws DatalogParseException
      Returns whether there is another token in this stream.
      Returns:
      whether there is another token
      Throws:
      DatalogParseException