1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 20:29:57 +00:00
openmw/components/compiler/stringparser.hpp

58 lines
1.6 KiB
C++
Raw Normal View History

2010-07-01 14:40:03 +00:00
#ifndef COMPILER_STRINGPARSER_H_INCLUDED
#define COMPILER_STRINGPARSER_H_INCLUDED
#include <vector>
#include <components/interpreter/types.hpp>
#include "parser.hpp"
#include "tokenloc.hpp"
2010-07-01 14:40:03 +00:00
namespace Compiler
{
class Literals;
2014-02-14 11:23:00 +00:00
2010-07-01 14:40:03 +00:00
class StringParser : public Parser
{
2022-09-22 18:26:05 +00:00
Literals& mLiterals;
std::vector<Interpreter::Type_Code> mCode;
bool mSmashCase;
TokenLoc mTokenLoc;
bool mDiscard;
2014-02-14 11:23:00 +00:00
2022-09-22 18:26:05 +00:00
public:
StringParser(ErrorHandler& errorHandler, const Context& context, Literals& literals);
2014-02-14 11:23:00 +00:00
2022-09-22 18:26:05 +00:00
bool parseName(const std::string& name, const TokenLoc& loc, Scanner& scanner) override;
///< Handle a name token.
/// \return fetch another token?
2010-07-01 14:40:03 +00:00
2022-09-22 18:26:05 +00:00
bool parseKeyword(int keyword, const TokenLoc& loc, Scanner& scanner) override;
///< Handle a keyword token.
/// \return fetch another token?
2010-07-01 14:40:03 +00:00
2022-09-22 18:26:05 +00:00
bool parseInt(int value, const TokenLoc& loc, Scanner& scanner) override;
///< Handle an int token.
/// \return fetch another token?
2022-09-22 18:26:05 +00:00
void append(std::vector<Interpreter::Type_Code>& code);
///< Append code for parsed string.
2022-09-22 18:26:05 +00:00
void smashCase();
///< Transform all scanned strings to lower case
2014-02-14 11:23:00 +00:00
2022-09-22 18:26:05 +00:00
void reset() override;
///< Reset parser to clean state (this includes the smashCase function).
2014-02-14 11:23:00 +00:00
2022-09-22 18:26:05 +00:00
/// Returns TokenLoc object for string. If no string has been parsed, the TokenLoc
/// object will be default initialised.
const TokenLoc& getTokenLoc() const;
2022-09-22 18:26:05 +00:00
/// If parsing a string, do not add it to the literal table and do not create code
/// for it.
void discard();
2010-07-01 14:40:03 +00:00
};
}
#endif