ScriptScanner.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
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#ifdef ENABLE_UNITTEST 12#include <gtest.h> 13#endif 14 15#ifndef __FLEX_LEXER_H 16#include "FlexLexer.h" 17#endif 18 19#ifndef YY_DECL 20#define YY_DECL \ 21 mcld::ScriptParser::token_type \ 22 mcld::ScriptScanner::lex(mcld::ScriptParser::semantic_type* yylval, \ 23 mcld::ScriptParser::location_type* yylloc, \ 24 const mcld::ScriptFile& pScriptFile) 25#endif 26 27#include <mcld/Script/ScriptFile.h> 28#include "ScriptParser.h" 29#include <stack> 30 31namespace mcld { 32 33/** \class ScriptScanner 34 * 35 */ 36class ScriptScanner : public yyFlexLexer 37{ 38public: 39 ScriptScanner(std::istream* yyin = NULL, std::ostream* yyout = NULL); 40 41 virtual ~ScriptScanner(); 42 43 virtual ScriptParser::token_type lex(ScriptParser::semantic_type* yylval, 44 ScriptParser::location_type* yylloc, 45 const ScriptFile& pScriptFile); 46 47 void setLexState(ScriptFile::Kind pKind); 48 49 void popLexState(); 50 51private: 52 void enterComments(ScriptParser::location_type& pLocation); 53 54private: 55 ScriptFile::Kind m_Kind; 56 std::stack<ScriptFile::Kind> m_StateStack; 57}; 58 59} // namespace of mcld 60 61#endif 62 63