From 6a21dba68255af9ef93e1924f324ef519d16ddd8 Mon Sep 17 00:00:00 2001 From: Adrien Duermael Date: Mon, 24 Feb 2025 16:25:57 -0800 Subject: [PATCH] Lexer: add offset getter (#1688) Added a getter for the Lexer's private `offset` to track its cursor position in the buffer. This helps me index tokens by buffer address in a project where I'm rendering Luau code with [Dear ImGui](https://github.com/ocornut/imgui). Would love this merged so I can use official Luau releases again! Co-authored-by: Adrian Duermael --- Ast/include/Luau/Lexer.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Ast/include/Luau/Lexer.h b/Ast/include/Luau/Lexer.h index 20814860..3570a35c 100644 --- a/Ast/include/Luau/Lexer.h +++ b/Ast/include/Luau/Lexer.h @@ -187,6 +187,11 @@ public: static bool fixupQuotedString(std::string& data); static void fixupMultilineString(std::string& data); + unsigned int getOffset() const + { + return offset; + } + private: char peekch() const; char peekch(unsigned int lookahead) const;