Skip to content

Commit b604a48

Browse files
committed
Add debug description to lexeme printing the lexeme’s content
1 parent acd9391 commit b604a48

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/SwiftParser/Lexer.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct Lexer {
2222
/// A lexeme is the fundamental output unit of lexical analysis. Each lexeme
2323
/// represents a fully identified, meaningful part of the input text that
2424
/// will can be consumed by a ``Parser``.
25-
public struct Lexeme {
25+
public struct Lexeme: CustomDebugStringConvertible {
2626
public struct Flags: OptionSet {
2727
public var rawValue: UInt8
2828

@@ -101,6 +101,10 @@ public struct Lexer {
101101
SyntaxText(baseAddress: start.advanced(by: leadingTriviaByteLength+textByteLength),
102102
count: trailingTriviaByteLength)
103103
}
104+
105+
public var debugDescription: String {
106+
return String(syntaxText: SyntaxText(baseAddress: start, count: byteLength))
107+
}
104108
}
105109
}
106110

0 commit comments

Comments
 (0)