1 //===- ScriptScanner.h ----------------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #ifndef MCLD_SCRIPT_SCRIPTSCANNER_H_ 10 #define MCLD_SCRIPT_SCRIPTSCANNER_H_ 11 12 #ifndef __FLEX_LEXER_H 13 #include <FlexLexer.h> 14 #endif 15 16 #ifndef YY_DECL 17 #define YY_DECL \ 18 mcld::ScriptParser::token_type mcld::ScriptScanner::lex( \ 19 mcld::ScriptParser::semantic_type* yylval, \ 20 mcld::ScriptParser::location_type* yylloc, \ 21 const mcld::ScriptFile& pScriptFile) 22 #endif 23 24 #include "mcld/Script/ScriptFile.h" 25 #include "ScriptParser.h" 26 #include <stack> 27 28 namespace mcld { 29 30 /** \class ScriptScanner 31 * 32 */ 33 class ScriptScanner : public yyFlexLexer { 34 public: 35 explicit ScriptScanner(std::istream* yyin = NULL, std::ostream* yyout = NULL); 36 37 virtual ~ScriptScanner(); 38 39 virtual ScriptParser::token_type lex(ScriptParser::semantic_type* yylval, 40 ScriptParser::location_type* yylloc, 41 const ScriptFile& pScriptFile); 42 43 void setLexState(ScriptFile::Kind pKind); 44 45 void popLexState(); 46 47 private: 48 void enterComments(ScriptParser::location_type& pLocation); 49 50 private: 51 ScriptFile::Kind m_Kind; 52 std::stack<ScriptFile::Kind> m_StateStack; 53 }; 54 55 } // namespace mcld 56 57 #endif // MCLD_SCRIPT_SCRIPTSCANNER_H_ 58