mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2024-12-28 00:15:06 +00:00
28131fd62b
These warnings were always enabled, but we didn't see them due to https://gitlab.com/OpenMW/openmw/-/issues/7882. I do not fully understand the cause of 7822 as I can't repro it in a minimal CMake project. Some of these fixes are thought through. Some are sensible best guesses. Some are kind of a stab in the dark as I don't know whether there was a possible bug the warning was telling me about that I've done nothing to help by introducing a static_cast. Nearly all of these warnings were about some kind of narrowing conversion, so I'm not sure why they weren't firing with GCC and Clang, which have -Wall -Wextra -pedantic set, which should imply -Wnarrowing, and they can't have been affected by 7882. There were also some warnings being triggered from Boost code. The vast majority of library headers that do questionable things weren't firing warnings off, but for some reason, /external:I wasn't putting these Boost headers into external mode. We need these warnings dealt with one way or another so we can switch the default Windows CI from MSBuild (which doesn't do ccache) to Ninja (which does). I have the necessary magic for that on a branch, but the branch won't build because of these warnings.
77 lines
1.8 KiB
C++
77 lines
1.8 KiB
C++
#ifndef OPENMW_COMPONENTS_FX_LEXER_H
|
|
#define OPENMW_COMPONENTS_FX_LEXER_H
|
|
|
|
#include <cstddef>
|
|
#include <optional>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
#include "lexer_types.hpp"
|
|
|
|
namespace fx
|
|
{
|
|
namespace Lexer
|
|
{
|
|
struct LexerException : std::runtime_error
|
|
{
|
|
LexerException(const std::string& message)
|
|
: std::runtime_error(message)
|
|
{
|
|
}
|
|
LexerException(const char* message)
|
|
: std::runtime_error(message)
|
|
{
|
|
}
|
|
};
|
|
|
|
class Lexer
|
|
{
|
|
public:
|
|
struct Block
|
|
{
|
|
std::size_t line;
|
|
std::string_view content;
|
|
};
|
|
|
|
Lexer(std::string_view buffer);
|
|
Lexer() = delete;
|
|
|
|
Token next();
|
|
Token peek();
|
|
|
|
// Jump ahead to next uncommented closing bracket at level zero. Assumes the head is at an opening bracket.
|
|
// Returns the contents of the block excluding the brackets and places cursor at closing bracket.
|
|
std::optional<std::string_view> jump();
|
|
|
|
Block getLastJumpBlock() const;
|
|
|
|
[[noreturn]] void error(const std::string& msg);
|
|
|
|
private:
|
|
void drop();
|
|
void advance();
|
|
char head();
|
|
bool peekChar(char c);
|
|
|
|
Token scanToken();
|
|
Token scanLiteral();
|
|
Token scanStringLiteral();
|
|
Token scanNumber();
|
|
|
|
const char* mHead;
|
|
const char* mTail;
|
|
std::size_t mAbsolutePos;
|
|
std::size_t mColumn;
|
|
std::size_t mLine;
|
|
std::string_view mBuffer;
|
|
Token mLastToken;
|
|
std::optional<Token> mLookahead;
|
|
|
|
Block mLastJumpBlock;
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif
|