19#ifndef __CVC4__PARSER__PARSER_STATE_H
20#define __CVC4__PARSER__PARSER_STATE_H
65 return out <<
"CHECK_NONE";
67 return out <<
"CHECK_DECLARED";
69 return out <<
"CHECK_UNDECLARED";
71 return out <<
"DeclarationCheck!UNKNOWN";
93 return out <<
"SYM_VARIABLE";
95 return out <<
"SYM_SORT";
97 return out <<
"SymbolType!UNKNOWN";
134 size_t d_assertionLevel;
144 std::set<std::string> d_reservedSymbols;
147 size_t d_anonymousFunctionCount;
153 bool d_checksEnabled;
165 bool d_canIncludeFile;
170 bool d_logicIsForced;
175 std::string d_forcedLogic;
178 std::set<Kind> d_logicOperators;
181 std::set<std::string> d_attributesWarnedAbout;
190 std::set<Type> d_unresolved;
197 std::list<Command*> d_commandQueue;
226 return d_exprManager;
279 void forceLogic(
const std::string& logic) { assert(!d_logicIsForced); d_logicIsForced =
true; d_forcedLogic = logic; }
309 const std::vector<Type>& params);
340 void reserveSymbolAtAssertionLevel(const
std::
string& name);
387 mkVars(const
std::vector<
std::
string> names, const
Type& type,
407 Expr mkAnonymousFunction(const
std::
string& prefix, const
Type& type,
411 void defineVar(const
std::
string& name, const
Expr& val,
412 bool levelZero = false);
415 void defineFunction(const
std::
string& name, const
Expr& val,
416 bool levelZero = false);
419 void defineType(const
std::
string& name, const
Type& type);
422 void defineType(const
std::
string& name,
423 const
std::vector<
Type>& params, const
Type& type);
426 void defineParameterizedType(const
std::
string& name,
427 const
std::vector<
Type>& params,
457 const
std::vector<
Type>& params);
462 bool isUnresolvedType(const
std::
string& name);
486 bool isBoolean(const
std::
string& name);
489 bool isFunctionLike(const
std::
string& name);
492 bool isDefinedFunction(const
std::
string& name);
495 bool isDefinedFunction(
Expr func);
498 bool isPredicate(const
std::
string& name);
507 inline
void warning(const
std::
string& msg) {
540 parseError(
"Unimplemented feature: " + msg);
552 d_assertionLevel = scopeLevel();
558 if(scopeLevel() < d_assertionLevel) {
559 d_assertionLevel = scopeLevel();
560 d_reservedSymbols.clear();
591 d_symtab = &d_symtabAllocated;
593 d_symtab = parser->d_symtab;
Class encapsulating the datatype type.
The representation of an inductive datatype.
A pure-virtual stream interface for expressions.
Class encapsulating CVC4 expressions and methods for constructing new expressions.
Class encapsulating a user-defined sort constructor.
Class encapsulating a user-defined sort.
A convenience class for handling scoped declarations.
void pushScope()
Push a scope level.
size_t getLevel() const
Get the current level of this symbol table.
void popScope()
Pop a scope level.
Class encapsulating CVC4 expression types.
A builder for input language parsers.
An expression stream interface for a parser.
ExprStream(Parser *parser)
~ExprStream()
Virtual destructor; this implementation does nothing.
Expr nextExpr()
Get the next expression in the stream (advancing the stream pointer as a side effect....
This class encapsulates all of the state of a parser, including the name of the file,...
bool isDeclared(const std::string &name, SymbolType type=SYM_VARIABLE)
Checks if a symbol has been declared.
bool canIncludeFile() const
void checkDeclaration(const std::string &name, DeclarationCheck check, SymbolType type=SYM_VARIABLE, std::string notes="")
Checks if the declaration policy we want to enforce holds for the given symbol.
void parseError(const std::string &msg)
Raise a parse error with the given message.
ExprManager * getExprManager() const
Get the associated ExprManager.
void disableStrictMode()
Disable strict parsing.
void useDeclarationsFrom(Parser *parser)
Set the current symbol table used by this parser.
size_t scopeLevel() const
Gets the current declaration level.
void enableChecks()
Enable semantic checks during parsing.
Input * getInput() const
Get the associated input.
Expr getVariable(const std::string &name)
Returns a variable, given a name.
void attributeNotSupported(const std::string &attr)
Issue a warning to the user, but only once per attribute.
void forceLogic(const std::string &logic)
bool done() const
Check if we are done – either the end of input has been reached, or some error has been encountered.
void enableStrictMode()
Enable strict parsing, according to the language standards.
void useDeclarationsFrom(SymbolTable *symtab)
const std::string & getForcedLogic() const
void unexpectedEOF(const std::string &msg)
Unexpectedly encountered an EOF.
Type getSort(const std::string &sort_name)
Returns a sort, given a name.
size_t getArity(const std::string &sort_name)
Returns arity of a (parameterized) sort, given a name and args.
Parser(ExprManager *exprManager, Input *input, bool strictMode=false, bool parseOnly=false)
Create a parser state.
void pushScope(bool bindingLevel=false)
void disableChecks()
Disable semantic checks during parsing.
Type getSort(const std::string &sort_name, const std::vector< Type > ¶ms)
Returns a (parameterized) sort, given a name and args.
void disallowIncludeFile()
Expr getFunction(const std::string &name)
Returns a function, given a name.
Expr nextExpression()
Parse and return the next expression.
SymbolTable * getSymbolTable() const
void setInput(Input *input)
Deletes and replaces the current parser input.
bool logicIsForced() const
void unimplementedFeature(const std::string &msg)
If we are parsing only, don't raise an exception; if we are not, raise a parse error with the given m...
void setDone(bool done=true)
Sets the done flag.
virtual bool logicIsSet()
Expose the functionality from SMT/SMT2 parsers, while making implementation optional by returning fal...
Macros that should be defined everywhere during the building of the libraries and driver binary,...
A stream interface for expressions.
DeclarationCheck
Types of check for the symols.
@ CHECK_NONE
Don't check anything.
@ CHECK_UNDECLARED
Enforce that the symbol has not been declared.
@ CHECK_DECLARED
Enforce that the symbol has been declared.
std::ostream & operator<<(std::ostream &out, DeclarationCheck check)
Returns a string representation of the given object (for debugging).
SymbolType
Types of symbols.
Exception class for parse errors.
Convenience class for scoping variable and type declarations.