Package io.github.cvc5
Class InputParser
java.lang.Object
io.github.cvc5.InputParser
This class is the main interface for retrieving commands and expressions
from an input using a parser.
After construction, it is expected that an input is first set via
setFileInput(InputLanguage, String)
,
setStringInput(InputLanguage, String, String)
,
or setIncrementalStringInput(InputLanguage, String)
and
appendIncrementalStringInput(String)
. Then, the methods
nextCommand()
and nextTerm()
can be
invoked to parse the input.
The input parser interacts with a symbol manager, which determines which
symbols are defined in the current context, based on the background logic
and user-defined symbols. If no symbol manager is provided, then the
input parser will construct (an initially empty) one.
If provided, the symbol manager must have a logic that is compatible
with the provided solver. That is, if both the solver and symbol
manager have their logics set (SymbolManager.isLogicSet()
and
Solver.isLogicSet()
, then their logics must be the same.
Upon setting an input source, if either the solver (resp. symbol
manager) has its logic set, then the symbol manager (resp. solver) is set to
use that logic, if its logic is not already set.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInputParser
(Solver solver) Construct an input parser with an initially empty symbol manager.InputParser
(Solver solver, SymbolManager sm) Construct an input parser -
Method Summary
Modifier and TypeMethodDescriptionvoid
Append string to the input being parsed by this parser.void
Free the native resource associated with this pointer.protected void
deletePointer
(long pointer) Delete the native resource associated with the specified pointer.boolean
done()
Determine if this parser done reading input.long
Return the raw native pointer.Get the underlying solver of this input parser.Get the underlying symbol manager of this input parser.Parse and return the next command.nextTerm()
Parse and return the next term.void
setFileInput
(InputLanguage lang, String fileName) Set the input for the given file.void
setIncrementalStringInput
(InputLanguage lang, String name) Set that we will be feeding strings to this parser via appendIncrementalStringInput below.void
setStringInput
(InputLanguage lang, String input, String name) Set the input to the given concrete input string.toString()
Return a string representation of the pointer.protected String
toString
(long pointer) Return a string representation of the specified native pointer.
-
Field Details
-
pointer
protected long pointerThe raw native pointer value.
-
-
Constructor Details
-
InputParser
Construct an input parser- Parameters:
solver
- The solver (e.g. for constructing terms and sorts)sm
- The symbol manager, which contains a symbol table that maps symbols to terms and sorts. Must have a logic that is compatible with the solver.
-
InputParser
Construct an input parser with an initially empty symbol manager.- Parameters:
solver
- The solver (e.g. for constructing terms and sorts).
-
-
Method Details
-
deletePointer
protected void deletePointer(long pointer) Delete the native resource associated with the specified pointer.Subclasses must implement this method to provide resource-specific cleanup logic.
- Parameters:
pointer
- the native pointer to delete
-
toString
Return a string representation of the specified native pointer.Subclasses must implement this method to convert the native pointer into a meaningful string.
- Parameters:
pointer
- the native pointer- Returns:
- a string representation of the pointer
-
getSolver
Get the underlying solver of this input parser.- Returns:
- The underlying solver of this input parser
-
getSymbolManager
Get the underlying symbol manager of this input parser.- Returns:
- The underlying symbol manager of this input parser.
-
setFileInput
Set the input for the given file.- Parameters:
lang
- the input language (e.g. InputLanguage.SMT_LIB_2_6).fileName
- the input file name.
-
setStringInput
Set the input to the given concrete input string.- Parameters:
lang
- The input language.input
- The input string.name
- The name of the stream, for use in error messages.
-
setIncrementalStringInput
Set that we will be feeding strings to this parser via appendIncrementalStringInput below.- Parameters:
lang
- The input language.name
- The name of the stream, for use in error messages.
-
appendIncrementalStringInput
Append string to the input being parsed by this parser. Should be called after calling setIncrementalStringInput.- Parameters:
input
- The input string.
-
nextCommand
Parse and return the next command. Will initialize the logic to "ALL" or the forced logic if no logic is set prior to this point and a command is read that requires initializing the logic.- Returns:
- The parsed command. This is the null command if no command was read.
-
nextTerm
Parse and return the next term. Requires setting the logic prior to this point.- Returns:
- The parsed term.
-
done
public boolean done()Determine if this parser done reading input.- Returns:
- True if this parser done reading input.
-
getPointer
public long getPointer()Return the raw native pointer.- Returns:
- the pointer value
-
deletePointer
public void deletePointer()Free the native resource associated with this pointer.This method should be called to explicitly clean up the underlying native resource. It removes this instance from the
Context
, then invokes the subclass-defineddeletePointer(long)
method to perform the actual cleanup. -
toString
Return a string representation of the pointer.
-