diff options
Diffstat (limited to 'src/parser/lexer.h')
-rw-r--r-- | src/parser/lexer.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/parser/lexer.h b/src/parser/lexer.h index 8f9bd103a..6c0a588c0 100644 --- a/src/parser/lexer.h +++ b/src/parser/lexer.h @@ -24,6 +24,7 @@ #include <variant> #include "support/name.h" +#include "support/result.h" #ifndef parser_lexer_h #define parser_lexer_h @@ -397,6 +398,14 @@ public: return getIndex(); } + [[nodiscard]] Err err(size_t pos, std::string reason) { + std::stringstream msg; + msg << position(pos) << ": error: " << reason; + return Err{msg.str()}; + } + + [[nodiscard]] Err err(std::string reason) { return err(getPos(), reason); } + private: void skipSpace(); void lexToken(); |