Debian Codegraph @

Xtree-house/bindings/src/lib.rs

raw symbols SCIP
1 mod grammar;
2 mod node;
3 mod parser;
4 pub mod query;
5 mod query_cursor;
6 mod tree;
7 mod tree_cursor;
8
9 #[cfg(feature = "ropey")]
10 mod ropey;
11 #[cfg(feature = "ropey")]
12 pub use ropey::RopeInput;
13
14 use std::ops;
15
16 pub use grammar::{Grammar, IncompatibleGrammarError};
17 pub use node::Node;
18 pub use parser::{ParseOptions, ParseState, Parser, ParserInputRaw};
19 pub use query::{Capture, Pattern, Query, QueryStr};
20 pub use query_cursor::{InactiveQueryCursor, MatchedNode, MatchedNodeIdx, QueryCursor, QueryMatch};
21 pub use tree::{InputEdit, Tree};
22 pub use tree_cursor::TreeCursor;
23
24 #[repr(C)]
25 #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
26 pub struct Point {
27 pub row: u32,
28 pub col: u32,
29 }
30
31 impl Point {
32 pub const ZERO: Self = Self { row: 0, col: 0 };
33 pub const MAX: Self = Self {
34 row: u32::MAX,
35 col: u32::MAX,
36 };
37 }
38
39 #[repr(C)]
40 #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
41 pub struct Range {
42 pub start_point: Point,
43 pub end_point: Point,
44 pub start_byte: u32,
45 pub end_byte: u32,
46 }
47
48 impl Range {
49 pub fn new(start_point: Point, end_point: Point, start_byte: u32, end_byte: u32) -> Range {
50 debug_assert!(start_point <= end_point);
51 debug_assert!(start_byte <= end_byte);
52 Range {
53 start_point,
54 end_point,
55 start_byte,
56 end_byte,
57 }
58 }
59 }
60
61 pub trait Input {
62 type Cursor: regex_cursor::Cursor;
63 fn cursor_at(&mut self, offset: u32) -> &mut Self::Cursor;
64 fn eq(&mut self, range1: ops::Range<u32>, range2: ops::Range<u32>) -> bool;
65 }
66
67 pub trait IntoInput {
68 type Input: Input;
69 fn into_input(self) -> Self::Input;
70 }
71
72 impl<T: Input> IntoInput for T {
73 type Input = T;
74
75 fn into_input(self) -> T {
76 self
77 }
78 }