torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XdlScanner.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the XdlScanner class.
18 
19 #ifndef TORC_PHYSICAL_XDL_XDLSCANNER_HPP
20 #define TORC_PHYSICAL_XDL_XDLSCANNER_HPP
21 
22 // Flex expects the signature of yylex to be defined in the macro YY_DECL, and
23 // the C++ parser expects it to be declared. We can factor both as follows.
24 
25 #ifndef YY_DECL
26 
27 #define YY_DECL \
28  torc::XdlParser::token_type \
29  torc::XdlScanner::lex( \
30  torc::XdlParser::semantic_type* yylval, \
31  torc::XdlParser::location_type* yylloc \
32  )
33 #endif
34 
35 #ifndef __FLEX_LEXER_H
36 #define yyFlexLexer XdlFlexLexer
38 #undef yyFlexLexer
39 #endif
40 
42 
43 namespace torc {
44 
45  class XdlScanner : public XdlFlexLexer {
46  public:
47  // constructors
48  /// \brief Public constructor.
49  /// \details Scans the input stream for tokens, and sends any output to the output stream.
50  /// \param arg_yyin The input stream.
51  /// \param arg_yyout The output stream.
52  XdlScanner(std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0);
53  /// \brief Virtual destructor.
54  virtual ~XdlScanner();
55  // functions
56  /// \brief Main scanning function.
58  XdlParser::location_type* yylloc);
59  /// \brief Enables or disables debugging output.
60  void set_debug(bool b);
61 
62  protected:
63  // friends
64  /// \brief The XDL parser has full access to our internals.
65  friend class XdlParser;
66  // members
67  /// \brief Flag to track whether we are inside a double quote.
69  /// \brief Variable to count the number of separator colons seen.
70  int colon;
71  /// \brief Variable to count the number of double-quotes seen.
72  int quote;
73  /// \biref Last double-quoted string that we saw.
75  };
76 
77 } // namespace torc
78 
79 #endif // TORC_PHYSICAL_XDL_XDLSCANNER_HPP
A Bison parser.
Definition: XdlParser.hpp:149
std::string last_string
Last double-quoted string that we saw.
Definition: XdlScanner.hpp:74
int quote
Variable to count the number of double-quotes seen.
Definition: XdlScanner.hpp:72
Header for the XdlParser class.
virtual ~XdlScanner()
Virtual destructor.
std::string string
YYSTYPE semantic_type
Symbol semantic values.
Definition: XdlParser.hpp:156
virtual XdlParser::token_type lex(XdlParser::semantic_type *yylval, XdlParser::location_type *yylloc)
Main scanning function.
void set_debug(bool b)
Enables or disables debugging output.
XdlScanner(std::istream *arg_yyin=0, std::ostream *arg_yyout=0)
Public constructor.
int colon
Variable to count the number of separator colons seen.
Definition: XdlScanner.hpp:70
bool in_double_quote
Flag to track whether we are inside a double quote.
Definition: XdlScanner.hpp:68