Class SMTLibTokenizer
This is not a full SMTLIB parser, but only provides basic support for SMTLIB commands.
Use this class as an Iterable, or the Iterator with iterator() to
turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, a ImmutableList of all tokens can be created with toImmutableList().
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic StringVariable names (symbols) can be wrapped with "|".static booleanisAssertToken(String token) Check if the token is an(assert ...).static booleanisDeclarationToken(String token) Check if the token is a function or variable declaration.static booleanisDefinitionToken(String token) Check if the token is a function definition.static booleanisExitToken(String token) Check if the token is(exit).static booleanisForbiddenToken(String token) Check if this is a forbidden token.static booleanisPopToken(String token) Check if the token is an(pop ...).static booleanisPushToken(String token) Check if the token is an(push ...).static booleanisResetAssertionsToken(String token) Check if the token is an(reset-assertions ...).static booleanisResetToken(String token) Check if the token is an(reset).static booleanisSetInfoToken(String token) Check if the token is(set-info ..).static booleanisSetLogicToken(String token) Check if the token is(set-logic ..).iterator()static SMTLibTokenizerCreates a newSMTLibTokenizerfrom the inputString.Split up a sequence of lisp expressions into a list of nen-empty tokens.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
of
Creates a newSMTLibTokenizerfrom the inputString. The resultingSMTLibTokenizeris anIterablefor the SMTLIB tokens. A newIteratoron the input can be created withiterator(). AImmutableListof all tokens can be created viatoImmutableList(). Tokenized input is returned sanitized from unnecessary characters, and checked for basic (but not full) syntactic validity (e.g. that every opened bracket is also closed in a valid way).- Parameters:
inputToTokenize- SMTLIB inputStringthat may be empty, but not null.
-
dequoteSMTLib
Variable names (symbols) can be wrapped with "|". This function removes those chars. -
toImmutableList
Split up a sequence of lisp expressions into a list of nen-empty tokens. This method simply uses theSMTLibTokenizer.TokenizerIteratorand creates a list out of all tokens. Repeated calls to this method are inefficient, as a newListis created every time it is called.This is used by
FormulaManager.parse(String)as part of the preprocessing before the input is passed on to the solver. SMT-LIB2 scripts are sequences of commands that are just r-expression. We split them up and then return the list.As an example
tokenize("(define-const a Int)(assert (= a 0)")will return the sequence["(define-const a Int)", "(assert (= a 0))"] -
iterator
-
isSetLogicToken
Check if the token is(set-logic ..).Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isSetInfoToken
Check if the token is(set-info ..).Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isDeclarationToken
Check if the token is a function or variable declaration.Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isDefinitionToken
Check if the token is a function definition.Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isAssertToken
Check if the token is an(assert ...).Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isPushToken
Check if the token is an(push ...).Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isPopToken
Check if the token is an(pop ...).Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isResetAssertionsToken
Check if the token is an(reset-assertions ...).Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isResetToken
Check if the token is an(reset).Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isExitToken
Check if the token is(exit).Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList(). -
isForbiddenToken
Check if this is a forbidden token.The list of forbidden tokens contains:
- push
- pop
- reset-assertions
- reset
Forbidden tokens manipulate the stack and are not supported while parsing SMT-lIB2 string. When a forbidden token is found parsing should be aborted by throwing an
IllegalArgumentExceptionexception.Use
SMTLibTokenizeras anIterable, or theIteratorwithiterator()to turn an SMT-LIB2 script into a string of input tokens efficiently. Alternatively, aImmutableListof all tokens can be created withtoImmutableList().
-