ScriptScanner.h revision 533eae20118036f425f27bf0536ef0ccbb090b65
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                                      \
19  mcld::ScriptScanner::lex(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
28namespace mcld {
29
30/** \class ScriptScanner
31 *
32 */
33class ScriptScanner : public yyFlexLexer
34{
35public:
36  ScriptScanner(std::istream* yyin = NULL, std::ostream* yyout = NULL);
37
38  virtual ~ScriptScanner();
39
40  virtual ScriptParser::token_type lex(ScriptParser::semantic_type* yylval,
41                                       ScriptParser::location_type* yylloc,
42                                       const ScriptFile& pScriptFile);
43
44  void setLexState(ScriptFile::Kind pKind);
45
46  void popLexState();
47
48private:
49  void enterComments(ScriptParser::location_type& pLocation);
50
51private:
52  ScriptFile::Kind m_Kind;
53  std::stack<ScriptFile::Kind> m_StateStack;
54};
55
56} // namespace of mcld
57
58#endif
59
60