z3 / src / parsers / util / simple_parser.h

Copyright (c) 2006 Microsoft Corporation

Module Name:



    Simple sexpr parser


    Leonardo de Moura (leonardo) 2008-03-31.

Revision History:



class scanner;

   \brief Simple sexpr parser.
   This class is used to parse small expressions used for configuring Z3.
class simple_parser {
    struct parser_error {};
    struct builtin_op {
        family_id m_family_id;
        decl_kind m_kind;
        builtin_op() : m_family_id(null_family_id), m_kind(0) {}
        builtin_op(family_id fid, decl_kind k) : m_family_id(fid), m_kind(k) {}
    typedef map<symbol, builtin_op, symbol_hash_proc, symbol_eq_proc> op_map;
    typedef map<symbol, var *, symbol_hash_proc, symbol_eq_proc>   var_map;
    ast_manager &    m_manager;
    op_map           m_builtin;
    var_map          m_vars;
    expr_ref_vector  m_exprs;
    expr * parse_expr(scanner & s);
    simple_parser(ast_manager & m);
    virtual ~simple_parser();
    void add_builtin_op(symbol const & s, family_id fid, decl_kind kind);
    void add_builtin_op(char const * str, family_id fid, decl_kind kind);
    void add_var(symbol const & s, var * v);
    void add_var(char const * str, var * v);
    void reset();
    void reset_vars();
    bool parse(std::istream & in, expr_ref & result);
    bool parse_string(char const * str, expr_ref & result);
    bool parse_file(char const * file, expr_ref & result);
    virtual expr * parse_int(rational const & r) { throw parser_error(); }
    virtual expr * parse_float(rational const & r) { throw parser_error(); }

#endif /* _SIMPLE_PARSER_H_ */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.