1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:37:35 +00:00

JSSpecCompiler+LibXML: Store location for tokens

This commit is contained in:
Dan Klishch 2024-01-16 20:47:08 -05:00 committed by Andrew Kaster
parent d219c91ca9
commit dee4978d67
7 changed files with 78 additions and 50 deletions

View file

@ -39,10 +39,21 @@ struct Listener {
virtual void error(ParseError const&) { }
};
// FIXME: This is also used in JSSpecCompiler, so should probably live in AK or even merged with
// AK::GenericLexer.
class LineTrackingLexer : public GenericLexer {
public:
using GenericLexer::GenericLexer;
LineTrackingLexer(StringView input, XML::Offset start_offset)
: GenericLexer(input)
, m_cached_offset {
.line = start_offset.line,
.column = start_offset.column,
}
{
}
Offset cached_offset() const { return m_cached_offset; }
void restore_cached_offset(Offset cached_offset) { m_cached_offset = cached_offset; }
Offset offset_for(size_t) const;