OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
stringparser.hpp
Go to the documentation of this file.
1 #ifndef COMPILER_STRINGPARSER_H_INCLUDED
2 #define COMPILER_STRINGPARSER_H_INCLUDED
3 
4 #include <vector>
5 
7 
8 #include "parser.hpp"
9 #include "tokenloc.hpp"
10 
11 namespace Compiler
12 {
13  class Literals;
14 
15  class StringParser : public Parser
16  {
17  enum State
18  {
20  };
21 
24  std::vector<Interpreter::Type_Code> mCode;
25  bool mSmashCase;
27  bool mDiscard;
28 
29  public:
30 
31  StringParser (ErrorHandler& errorHandler, const Context& context, Literals& literals);
32 
33  virtual bool parseName (const std::string& name, const TokenLoc& loc,
34  Scanner& scanner);
37 
38  virtual bool parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner);
41 
42  virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner);
45 
46  void append (std::vector<Interpreter::Type_Code>& code);
48 
49  void smashCase();
51 
52  void reset();
54 
57  const TokenLoc& getTokenLoc() const;
58 
61  void discard();
62  };
63 }
64 
65 #endif
virtual bool parseKeyword(int keyword, const TokenLoc &loc, Scanner &scanner)
Definition: stringparser.cpp:43
void smashCase()
Transform all scanned strings to lower case.
Definition: stringparser.cpp:88
const TokenLoc & getTokenLoc() const
Definition: stringparser.cpp:93
Definition: stringparser.hpp:15
Definition: stringparser.hpp:19
State
Definition: stringparser.hpp:17
virtual bool parseName(const std::string &name, const TokenLoc &loc, Scanner &scanner)
Definition: stringparser.cpp:21
Definition: context.hpp:10
Location of a token in a source file.
Definition: tokenloc.hpp:10
Error handling.
Definition: errorhandler.hpp:14
void discard()
Definition: stringparser.cpp:98
bool mDiscard
Definition: stringparser.hpp:27
Definition: stringparser.hpp:19
bool mSmashCase
Definition: stringparser.hpp:25
void append(std::vector< Interpreter::Type_Code > &code)
Append code for parsed string.
Definition: stringparser.cpp:73
int code
Definition: crashcatcher.cpp:70
Literal values.
Definition: literals.hpp:13
virtual bool parseSpecial(int code, const TokenLoc &loc, Scanner &scanner)
Definition: stringparser.cpp:62
Parser base class.
Definition: parser.hpp:17
StringParser(ErrorHandler &errorHandler, const Context &context, Literals &literals)
Definition: stringparser.cpp:15
std::vector< Interpreter::Type_Code > mCode
Definition: stringparser.hpp:24
TokenLoc mTokenLoc
Definition: stringparser.hpp:26
State mState
Definition: stringparser.hpp:23
Scanner.
Definition: scanner.hpp:21
void reset()
Reset parser to clean state (this includes the smashCase function).
Definition: stringparser.cpp:78
const char * name
Definition: crashcatcher.cpp:59
Literals & mLiterals
Definition: stringparser.hpp:22