tree_house_bindings/
lib.rs1mod grammar;
2mod node;
3mod parser;
4pub mod query;
5mod query_cursor;
6mod tree;
7mod tree_cursor;
8
9#[cfg(feature = "ropey")]
10mod ropey;
11#[cfg(feature = "ropey")]
12pub use ropey::RopeInput;
13
14use std::ops;
15
16pub use grammar::{Grammar, IncompatibleGrammarError};
17pub use node::Node;
18pub use parser::{Parser, ParserInputRaw};
19pub use query::{Capture, Pattern, Query, QueryStr};
20pub use query_cursor::{InactiveQueryCursor, MatchedNode, MatchedNodeIdx, QueryCursor, QueryMatch};
21pub use tree::{InputEdit, Tree};
22pub use tree_cursor::TreeCursor;
23
24#[repr(C)]
25#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
26pub struct Point {
27 pub row: u32,
28 pub col: u32,
29}
30
31impl 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)]
41pub struct Range {
42 pub start_point: Point,
43 pub end_point: Point,
44 pub start_byte: u32,
45 pub end_byte: u32,
46}
47
48pub trait Input {
49 type Cursor: regex_cursor::Cursor;
50 fn cursor_at(&mut self, offset: u32) -> &mut Self::Cursor;
51 fn eq(&mut self, range1: ops::Range<u32>, range2: ops::Range<u32>) -> bool;
52}
53
54pub trait IntoInput {
55 type Input: Input;
56 fn into_input(self) -> Self::Input;
57}
58
59impl<T: Input> IntoInput for T {
60 type Input = T;
61
62 fn into_input(self) -> T {
63 self
64 }
65}