Skip to main content

cddl/
lexer.rs

1//! Lexer types preserved for AST compatibility
2
3#[cfg(target_arch = "wasm32")]
4use serde::Serialize;
5
6/// Lexer position
7#[cfg_attr(target_arch = "wasm32", derive(Serialize))]
8#[derive(Debug, Copy, Clone)]
9pub struct Position {
10  /// Line number
11  pub line: usize,
12  /// Column number
13  pub column: usize,
14  /// Token begin and end index range
15  pub range: (usize, usize),
16  /// Lexer index
17  pub index: usize,
18}
19
20impl Default for Position {
21  fn default() -> Self {
22    Position {
23      line: 1,
24      column: 1,
25      range: (0, 0),
26      index: 0,
27    }
28  }
29}