00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/physical/xdl/XdlScanner.hpp $ 00003 // $Id: XdlScanner.hpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Header for the XdlScanner class. 00018 00019 #ifndef TORC_PHYSICAL_XDL_XDLSCANNER_HPP 00020 #define TORC_PHYSICAL_XDL_XDLSCANNER_HPP 00021 00022 // Flex expects the signature of yylex to be defined in the macro YY_DECL, and 00023 // the C++ parser expects it to be declared. We can factor both as follows. 00024 00025 #ifndef YY_DECL 00026 00027 #define YY_DECL \ 00028 torc::XdlParser::token_type \ 00029 torc::XdlScanner::lex( \ 00030 torc::XdlParser::semantic_type* yylval, \ 00031 torc::XdlParser::location_type* yylloc \ 00032 ) 00033 #endif 00034 00035 #ifndef __FLEX_LEXER_H 00036 #define yyFlexLexer XdlFlexLexer 00037 #include "torc/physical/xdl/FlexLexer.h" 00038 #undef yyFlexLexer 00039 #endif 00040 00041 #include "torc/physical/xdl/XdlParser.hpp" 00042 00043 namespace torc { 00044 00045 class XdlScanner : public XdlFlexLexer { 00046 public: 00047 // constructors 00048 /// \brief Public constructor. 00049 /// \details Scans the input stream for tokens, and sends any output to the output stream. 00050 /// \param arg_yyin The input stream. 00051 /// \param arg_yyout The output stream. 00052 XdlScanner(std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0); 00053 /// \brief Virtual destructor. 00054 virtual ~XdlScanner(); 00055 // functions 00056 /// \brief Main scanning function. 00057 virtual XdlParser::token_type lex(XdlParser::semantic_type* yylval, 00058 XdlParser::location_type* yylloc); 00059 /// \brief Enables or disables debugging output. 00060 void set_debug(bool b); 00061 00062 protected: 00063 // friends 00064 /// \brief The XDL parser has full access to our internals. 00065 friend class XdlParser; 00066 // members 00067 /// \brief Flag to track whether we are inside a double quote. 00068 bool in_double_quote; 00069 /// \brief Flag to count the number of separator colons seen. 00070 int colon; 00071 /// \biref Last double-quoted string that we saw. 00072 std::string last_string; 00073 }; 00074 00075 } // namespace torc 00076 00077 #endif // TORC_PHYSICAL_XDL_XDLSCANNER_HPP