Class DatalogTokenizer
java.lang.Object
edu.harvard.seas.pl.abcdatalog.parser.DatalogTokenizer
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.
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
ConstructorDescriptionConstruct a stream of Datalog tokens from a Reader. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Attempts to consume the supplied string from the beginning of the token stream.boolean
hasNext()
Returns whether there is another token in this stream.next()
Returns (and consumes) the next token in this stream.peek()
Returns the next token in this stream without consuming it.
-
Constructor Details
-
DatalogTokenizer
Construct a stream of Datalog tokens from a Reader.- Parameters:
r
- the Reader
-
-
Method Details
-
consume
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
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
Returns (and consumes) the next token in this stream. Throws an exception if at EOF.- Returns:
- the string representation of token
- Throws:
DatalogParseException
-
hasNext
Returns whether there is another token in this stream.- Returns:
- whether there is another token
- Throws:
DatalogParseException
-