vile / lexer / source_state.v
19 lines · 16 sloc · 458 bytes · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw
1module lexer
2
3// SourceState records committed scanner progress, independently of a diagnostic
4// position that may point backwards. Reading it allocates no storage.
5pub struct SourceState {
6pub:
7 fold_case bool = true
8 consumed int
9}
10
11@[inline]
12pub fn (s &Scanner) source_state() SourceState {
13 return SourceState{ fold_case: !s.no_fold, consumed: s.pos }
14}
15
16@[inline]
17pub fn (s &AltScanner) source_state() SourceState {
18 return s.scanner.source_state()
19}
20