OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lineparser.hpp
Go to the documentation of this file.
1 #ifndef COMPILER_LINEPARSER_H_INCLUDED
2 #define COMPILER_LINEPARSER_H_INCLUDED
3 
4 #include <vector>
5 #include <string>
6 
9 
10 #include "parser.hpp"
11 #include "exprparser.hpp"
12 
13 namespace Compiler
14 {
15  class Locals;
16  class Literals;
17 
19 
20  class LineParser : public Parser
21  {
22  enum State
23  {
28  EndState, PotentialEndState /* may have a stray string argument */,
30  };
31 
34  std::vector<Interpreter::Type_Code>& mCode;
36  std::string mName;
37  std::string mMemberName;
39  int mButtons;
40  std::string mExplicit;
41  char mType;
44 
45  void parseExpression (Scanner& scanner, const TokenLoc& loc);
46 
47  public:
48 
49  LineParser (ErrorHandler& errorHandler, const Context& context, Locals& locals,
50  Literals& literals, std::vector<Interpreter::Type_Code>& code,
51  bool allowExpression = false);
54 
55  virtual bool parseInt (int value, const TokenLoc& loc, Scanner& scanner);
58 
59  virtual bool parseFloat (float value, const TokenLoc& loc, Scanner& scanner);
62 
63  virtual bool parseName (const std::string& name, const TokenLoc& loc,
64  Scanner& scanner);
67 
68  virtual bool parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner);
71 
72  virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner);
75 
76  void reset();
78  };
79 
81  {
82  private:
83  std::string mArguments;
84 
85  protected:
86  virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision);
87  virtual void visitedCharacter(char c) {}
88 
89  public:
90  virtual void process(const std::string& message)
91  {
92  mArguments.clear();
94  }
95  std::string getArguments() const { return mArguments; }
96  };
97 }
98 
99 #endif
void message(CodeContainer &code, Literals &literals, const std::string &message, int buttons)
Definition: generator.cpp:537
Definition: lineparser.hpp:28
ExprParser mExprParser
Definition: lineparser.hpp:42
void parseExpression(Scanner &scanner, const TokenLoc &loc)
Definition: lineparser.cpp:19
virtual bool parseInt(int value, const TokenLoc &loc, Scanner &scanner)
Definition: lineparser.cpp:62
Literals & mLiterals
Definition: lineparser.hpp:33
char mType
Definition: lineparser.hpp:41
Definition: lineparser.hpp:28
void reset()
Reset parser to clean state.
Definition: lineparser.cpp:553
Definition: context.hpp:10
Definition: lineparser.hpp:25
bool mAllowExpression
Definition: lineparser.hpp:43
virtual bool parseSpecial(int code, const TokenLoc &loc, Scanner &scanner)
Definition: lineparser.cpp:490
Location of a token in a source file.
Definition: tokenloc.hpp:10
Definition: exprparser.hpp:16
Definition: lineparser.hpp:29
virtual bool parseFloat(float value, const TokenLoc &loc, Scanner &scanner)
Definition: lineparser.cpp:74
bool mReferenceMember
Definition: lineparser.hpp:38
Placeholder
Definition: messageformatparser.hpp:11
virtual void process(const std::string &message)
Definition: messageformatparser.cpp:7
Definition: lineparser.hpp:80
virtual void process(const std::string &message)
Definition: lineparser.hpp:90
Definition: lineparser.hpp:25
Locals & mLocals
Definition: lineparser.hpp:32
std::string mMemberName
Definition: lineparser.hpp:37
State mState
Definition: lineparser.hpp:35
int mButtons
Definition: lineparser.hpp:39
Error handling.
Definition: errorhandler.hpp:14
virtual bool parseName(const std::string &name, const TokenLoc &loc, Scanner &scanner)
Definition: lineparser.cpp:86
virtual void visitedPlaceholder(Placeholder placeholder, char padding, int width, int precision)
Definition: lineparser.cpp:560
Definition: lineparser.hpp:25
virtual bool parseKeyword(int keyword, const TokenLoc &loc, Scanner &scanner)
Definition: lineparser.cpp:201
std::string getArguments() const
Definition: lineparser.hpp:95
Definition: messageformatparser.hpp:8
std::string mArguments
Definition: lineparser.hpp:83
std::string mExplicit
Definition: lineparser.hpp:40
Definition: lineparser.hpp:26
State
Definition: lineparser.hpp:22
std::vector< Interpreter::Type_Code > & mCode
Definition: lineparser.hpp:34
Definition: lineparser.hpp:27
int code
Definition: crashcatcher.cpp:70
Literal values.
Definition: literals.hpp:13
virtual void visitedCharacter(char c)
Definition: lineparser.hpp:87
Definition: lineparser.hpp:27
std::string mName
Definition: lineparser.hpp:36
Parser base class.
Definition: parser.hpp:17
Definition: lineparser.hpp:29
LineParser(ErrorHandler &errorHandler, const Context &context, Locals &locals, Literals &literals, std::vector< Interpreter::Type_Code > &code, bool allowExpression=false)
Definition: lineparser.cpp:55
Definition: lineparser.hpp:24
Definition: lineparser.hpp:27
Definition: lineparser.hpp:26
Local variable declarations.
Definition: locals.hpp:12
Scanner.
Definition: scanner.hpp:21
const char * name
Definition: crashcatcher.cpp:59
Line parser, to be used in console scripts and as part of ScriptParser.
Definition: lineparser.hpp:20