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::DrParser::token_type dreal::DrScanner::lex( \
10  dreal::DrParser::semantic_type* yylval, \
11  dreal::DrParser::location_type* yylloc)
12 #endif
13 
14 #ifndef __FLEX_LEXER_H
15 #define yyFlexLexer DrFlexLexer
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.
23 
24 #include "dreal/dr/parser.yy.hh"
25 
26 namespace dreal {
27 
28 /** DrScanner is a derived class to add some extra function to the scanner
29  * class. Flex itself creates a class named yyFlexLexer, which is renamed using
30  * macros to ExampleFlexLexer. However we change the context of the generated
31  * yylex() function to be contained within the DrScanner class. This is
32  * required because the yylex() defined in ExampleFlexLexer has no parameters.
33  */
34 class DrScanner : public DrFlexLexer {
35  public:
36  /** Create a new scanner object. The streams arg_yyin and arg_yyout default
37  * to cin and cout, but that assignment is only made when initializing in
38  * yylex(). */
39  explicit DrScanner(std::istream* arg_yyin = nullptr,
40  std::ostream* arg_yyout = nullptr);
41 
42  DrScanner(const DrScanner&) = delete;
43 
44  DrScanner(DrScanner&&) = delete;
45 
46  DrScanner& operator=(const DrScanner&) = delete;
47 
48  DrScanner& operator=(DrScanner&&) = delete;
49 
50  /** Required for virtual functions */
51  ~DrScanner() override;
52 
53  /** This is the main lexing function. It is generated by flex according to
54  * the macro declaration YY_DECL above. The generated bison parser then
55  * calls this virtual function to fetch new tokens. */
56  virtual DrParser::token_type lex(DrParser::semantic_type* yylval,
57  DrParser::location_type* yylloc);
58 
59  /** Enable debug output (via arg_yyout) if compiled into the scanner. */
60  void set_debug(bool b);
61 };
62 
63 } // namespace dreal
virtual DrParser::token_type lex(DrParser::semantic_type *yylval, DrParser::location_type *yylloc)
This is the main lexing function.
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
~DrScanner() override
Required for virtual functions.
void set_debug(bool b)
Enable debug output (via arg_yyout) if compiled into the scanner.
DrScanner(std::istream *arg_yyin=nullptr, std::ostream *arg_yyout=nullptr)
Create a new scanner object.
This is the header file that we consolidate Drake&#39;s symbolic classes and expose them inside of dreal ...
DrScanner is a derived class to add some extra function to the scanner class.
Definition: scanner.h:34