mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
JSSpecCompiler+LibXML: Store location for tokens
This commit is contained in:
parent
d219c91ca9
commit
dee4978d67
7 changed files with 78 additions and 50 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue