dReal4
scanner.h
1 #pragma once
2 
3 // Flex expects the signature of yylex to be defined in the macro YY_DECL, and
4 // the C++ parser expects it to be declared. We can factor both as follows.
5 
6 #ifndef YY_DECL
7 
8 #define YY_DECL \
9  dreal::Smt2Parser::token_type dreal::Smt2Scanner::lex( \
10  dreal::Smt2Parser::semantic_type* yylval, \
11  dreal::Smt2Parser::location_type* yylloc)
12 #endif
13 
14 #ifndef __FLEX_LEXER_H
15 #define yyFlexLexer Smt2FlexLexer
16 #include <FlexLexer.h>
17 #undef yyFlexLexer
18 #endif
19 
20 // The following include should come first before parser.yy.hh.
21 // Do not alpha-sort them.
22 #include "dreal/smt2/sort.h"
23 #include "dreal/smt2/term.h"
25 #include "dreal/util/box.h"
26 #include "dreal/util/string_to_interval.h"
27 
28 #include "dreal/smt2/parser.yy.hh"
29 
30 namespace dreal {
31 
32 /** Smt2Scanner is a derived class to add some extra function to the scanner
33  * class. Flex itself creates a class named yyFlexLexer, which is renamed using
34  * macros to ExampleFlexLexer. However we change the context of the generated
35  * yylex() function to be contained within the Smt2Scanner class. This is
36  * required because the yylex() defined in ExampleFlexLexer has no parameters.
37  */
38 class Smt2Scanner : public Smt2FlexLexer {
39  public:
40  /** Create a new scanner object. The streams arg_yyin and arg_yyout default
41  * to cin and cout, but that assignment is only made when initializing in
42  * yylex(). */
43  explicit Smt2Scanner(std::istream* arg_yyin = nullptr,
44  std::ostream* arg_yyout = nullptr);
45 
46  Smt2Scanner(const Smt2Scanner&) = delete;
47 
48  Smt2Scanner(Smt2Scanner&&) = delete;
49 
50  Smt2Scanner& operator=(const Smt2Scanner&) = delete;
51 
52  Smt2Scanner& operator=(Smt2Scanner&&) = delete;
53 
54  /** Required for virtual functions */
55  ~Smt2Scanner() override;
56 
57  /** This is the main lexing function. It is generated by flex according to
58  * the macro declaration YY_DECL above. The generated bison parser then
59  * calls this virtual function to fetch new tokens. */
60  virtual Smt2Parser::token_type lex(Smt2Parser::semantic_type* yylval,
61  Smt2Parser::location_type* yylloc);
62 
63  /** Enable debug output (via arg_yyout) if compiled into the scanner. */
64  void set_debug(bool b);
65 };
66 
67 } // namespace dreal
Smt2Scanner(std::istream *arg_yyin=nullptr, std::ostream *arg_yyout=nullptr)
Create a new scanner object.
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
void set_debug(bool b)
Enable debug output (via arg_yyout) if compiled into the scanner.
~Smt2Scanner() override
Required for virtual functions.
virtual Smt2Parser::token_type lex(Smt2Parser::semantic_type *yylval, Smt2Parser::location_type *yylloc)
This is the main lexing function.
Smt2Scanner is a derived class to add some extra function to the scanner class.
Definition: scanner.h:38
This is the header file that we consolidate Drake&#39;s symbolic classes and expose them inside of dreal ...