Package org.smtlib
Interface IParser
- All Known Implementing Classes:
Parser
public interface IParser
This is the interface to a parser for SMT-LIB. The interface is independent
of the concrete syntax being used; a specific implementation of this interface
will implement a specific concrete syntax for the SMT-LIB abstract syntax.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAn exception to be thrown if parsing is to be intentionally aborted (and restarted, ignoring any tokens since the last successful call to the parser.static interfaceFunctional interface for a lambda that parses one element from a Parser.static interfaceThe interface for the parser/printer factorystatic classAn exception thrown if parsing is to be aborted.static classAn exception to be thrown if there is an unrecoverable problem scanning the syntax -
Method Summary
Modifier and TypeMethodDescriptionvoidSkips remainder of current linedefault voidChecks that a user-defined symbol does not begin with the reserved characters@or.; throws a ParserException if the check fails.booleanReturns true if the command most recently returned by parseCommand() had a syntax error that parsing recovered from; such a command is not sent to a solverbooleanReturns true if one of the errors commandHasError() reports was an invalid characterbooleanisEOD()Returns true if the parser is at the end of dataReturns the most recent error, or nullParse an attribute (keyword with optional value), returning null with error messages if an error occurs.Parses a value for an attribute, returning null with error messages if an error occursParse an SMT-LIB binary literal; return null and log an error response if there is no numeralParses a binding "(id expression)", returning null with error messages if an error occursParses a parenthesized sequence of let-bindings, returning null with error messages if an error occursParses an SMT-LIB command, if the parser is looking at text representing a valid SMT-LIB command; returns null and logs errors if the text is not a valid command.Parses a constructor declaration "(symbol selector*)"Parses a datatype declarationParse an SMT-LIB decimal literal; return null and log an error response if there is no numeralParses a declaration "(id sort)", returning null with error messages if an error occursParses a parenthesized sequence of IDeclaration items, returning null with error messages if an error occursParses a term or formula; return null and log an error response if there is no term or formulaParses a function declaration "(symbol (sorted_var*) sort)" used in define-funs-recparseHex()Parse an SMT-LIB hex literal; return null and log an error response if there is no numeralParses an identifier (either a symbol or a parameterized identifier) from the token stream, returning null (with logged error messages) if there is not one.Parse an SMT-LIB keyword; return null and log an error response if there is no valid keyworddefault List<ISort.IDatatype> Parses a parenthesized list of datatype declarations from the given parser.Parses a parenthesized list of terms from the given parser.Parse an SMT-LIB literal of any kind; return null and log an error response if there is no literalParse an SMT-LIB logic; return null and log an error response if there is no valid logic definitionParse an SMT-LIB numeral; return null and log an error response if there is no numeralParses a qualified identifier (either a symbol, a parameterized identifier, or an as identifier) from the token stream, returning null (with logged error messages) if there is not one.Parses an SMT-LIB command script.Parses a selector declaration "(symbol sort)"parseSort(List<ISort.IParameter> parameters) Parses a sort, returning null with error messages if a valid sort is not in the next parser tokens.Parse an SMT-LIB string literal; return null and log an error response if there is no valid string literalParse an SMT-LIB symbol; return null and log an error response if there is no symbolParse an SMT-LIB theory; return null and log an error response if there is no valid theory definitionsmt()Returns the configuration with which the parser was instantiated.
-
Method Details
-
smt
SMT.Configuration smt()Returns the configuration with which the parser was instantiated. -
isEOD
Returns true if the parser is at the end of data- Throws:
IOExceptionIParser.ParserException
-
lastError
IResponse.IError lastError()Returns the most recent error, or null -
commandHasError
boolean commandHasError()Returns true if the command most recently returned by parseCommand() had a syntax error that parsing recovered from; such a command is not sent to a solver -
commandHasLexicalError
boolean commandHasLexicalError()Returns true if one of the errors commandHasError() reports was an invalid character -
abortLine
void abortLine()Skips remainder of current line -
parseAttribute
Parse an attribute (keyword with optional value), returning null with error messages if an error occurs.- Throws:
IParser.ParserException
-
parseAttributeValue
Parses a value for an attribute, returning null with error messages if an error occurs- Throws:
IParser.ParserException
-
parseCommand
Parses an SMT-LIB command, if the parser is looking at text representing a valid SMT-LIB command; returns null and logs errors if the text is not a valid command.- Returns:
- the command or null
- Throws:
IOException- if an IO problem happened during parsingIParser.ParserException
-
parseScript
Parses an SMT-LIB command script. The result is either a string literal or a parenthesized list of commands (which are parenthesized themselves); the string literal denotes the name of a file from which the commands are read when the command is executed; if the script is included directly, it is parsed, but typechecking is performed in context upon execution. If any errors occur, messages are logged and null is returned, with the parser advancing through a matching right parenthesis.- Returns:
- the parsed script
- Throws:
IOException- if an IO error occurs in reading inputIParser.ParserException- if an unrecoverable error occurs in parsing tokens
-
parseExpr
Parses a term or formula; return null and log an error response if there is no term or formula- Throws:
IParser.ParserException
-
parseSymbol
Parse an SMT-LIB symbol; return null and log an error response if there is no symbol- Throws:
IParser.ParserException
-
parseLiteral
Parse an SMT-LIB literal of any kind; return null and log an error response if there is no literal- Throws:
IParser.ParserException
-
parseNumeral
Parse an SMT-LIB numeral; return null and log an error response if there is no numeral- Throws:
IParser.ParserException
-
parseDecimal
Parse an SMT-LIB decimal literal; return null and log an error response if there is no numeral- Throws:
IParser.ParserException
-
parseBinary
Parse an SMT-LIB binary literal; return null and log an error response if there is no numeral- Throws:
IParser.ParserException
-
parseHex
Parse an SMT-LIB hex literal; return null and log an error response if there is no numeral- Throws:
IParser.ParserException
-
parseStringLiteral
Parse an SMT-LIB string literal; return null and log an error response if there is no valid string literal- Throws:
IParser.ParserException
-
parseKeyword
Parse an SMT-LIB keyword; return null and log an error response if there is no valid keyword- Throws:
IParser.ParserException
-
parseQualifiedIdentifier
Parses a qualified identifier (either a symbol, a parameterized identifier, or an as identifier) from the token stream, returning null (with logged error messages) if there is not one.- Throws:
IParser.ParserException
-
parseIdentifier
Parses an identifier (either a symbol or a parameterized identifier) from the token stream, returning null (with logged error messages) if there is not one.- Throws:
IParser.ParserException
-
parseSort
Parses a sort, returning null with error messages if a valid sort is not in the next parser tokens.- Throws:
IParser.ParserException
-
parseLogic
Parse an SMT-LIB logic; return null and log an error response if there is no valid logic definition- Throws:
IParser.ParserException
-
parseTheory
Parse an SMT-LIB theory; return null and log an error response if there is no valid theory definition- Throws:
IParser.ParserException
-
parseBinding
Parses a binding "(id expression)", returning null with error messages if an error occurs- Throws:
IOExceptionIParser.ParserException
-
parseDatatype
Parses a datatype declaration- Throws:
IOExceptionIParser.ParserException
-
parseSelector
Parses a selector declaration "(symbol sort)"- Throws:
IParser.ParserException
-
parseConstructor
Parses a constructor declaration "(symbol selector*)"- Throws:
IParser.ParserException
-
parseFunctionDeclaration
Parses a function declaration "(symbol (sorted_var*) sort)" used in define-funs-rec- Throws:
IParser.ParserException
-
parseDeclaration
Parses a declaration "(id sort)", returning null with error messages if an error occurs- Throws:
IOExceptionIParser.ParserException
-
parseBindings
Parses a parenthesized sequence of let-bindings, returning null with error messages if an error occurs- Throws:
IOExceptionIParser.ParserException
-
parseDeclarations
Parses a parenthesized sequence of IDeclaration items, returning null with error messages if an error occurs- Throws:
IOExceptionIParser.ParserException
-
parseListTerms
Parses a parenthesized list of terms from the given parser.- Throws:
IParser.ParserException
-
parseListDatatypes
Parses a parenthesized list of datatype declarations from the given parser.- Throws:
IParser.ParserException
-
checkUserId
Checks that a user-defined symbol does not begin with the reserved characters@or.; throws a ParserException if the check fails.- Throws:
IParser.ParserException
-