InputParser

This class is the main interface for retrieving commands and expressions from an input.


class 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 e.g. setFileInput, setStreamInput, setStringInput or setIncrementalStringInput and appendIncrementalStringInput. Then, the methods nextCommand and nextExpression 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.

Public Functions

InputParser ( Solver * solver , SymbolManager * sm )

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 ( Solver * solver )

Construct an input parser with an initially empty symbol manager.

Parameters :

solver – The solver (e.g. for constructing terms and sorts)

Solver * getSolver ( )
Returns :

The underlying solver of this input parser

SymbolManager * getSymbolManager ( )
Returns :

The underlying symbol manager of this input parser

void setFileInput ( modes :: InputLanguage lang , const std :: string & filename )

Set the input for the given file.

Parameters :
  • lang – the input language (e.g. modes::InputLanguage::SMT_LIB_2_6)

  • filename – the input filename

void setStreamInput ( modes :: InputLanguage lang , std :: istream & input , const std :: string & name )

Set the input for the given stream.

Parameters :
  • lang – the input language

  • input – the input stream

  • name – the name of the stream, for use in error messages

void setStringInput ( modes :: InputLanguage , const std :: string & input , const std :: string & name )

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

void setIncrementalStringInput ( modes :: InputLanguage lang , const std :: string & name )

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

void appendIncrementalStringInput ( const std :: string & input )

Append string to the input being parsed by this parser. Should be called after calling setIncrementalStringInput.

Parameters :

input – The input string

Command 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.

Term nextTerm ( )

Parse and return the next term. Requires setting the logic prior to this point.

bool done ( ) const

Is this parser done reading input?