1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Core module for the Rusty LR parser.
//!
//! This crate is private and not intended to be used directly.
//! Please use the [`rusty_lr`](https://crates.io/crates/rusty_lr) crate instead.

pub(crate) mod hashmap;
pub(crate) mod rule;
pub(crate) mod token;

#[cfg(feature = "tree")]
pub(crate) mod tree;
#[cfg(feature = "tree")]
pub use tree::Tree;
#[cfg(feature = "tree")]
pub use tree::TreeList;
#[cfg(feature = "tree")]
pub use tree::TreeNonTerminal;

/// module for build DFA tables from CFG
#[cfg(feature = "builder")]
pub mod builder;

/// module for LR(1), LALR(1) parser
pub mod lr;

/// module for GLR parser
pub mod glr;

pub use hashmap::HashMap;
pub use hashmap::HashSet;

pub use rule::ProductionRule;

pub use rule::LookaheadRule;
pub use rule::LookaheadRuleRefSet;
pub use rule::ShiftedRule;
pub use rule::ShiftedRuleRef;

pub use rule::ReduceType;
pub use token::Token;

#[cfg(feature = "error")]
pub(crate) mod backtrace;
#[cfg(feature = "error")]
pub use backtrace::Backtrace;

/// Default error type for reduce action
#[derive(Debug, Default)]
pub struct DefaultReduceActionError;
impl std::fmt::Display for DefaultReduceActionError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "Default reduce action error")
    }
}
impl std::error::Error for DefaultReduceActionError {
    fn cause(&self) -> Option<&dyn std::error::Error> {
        None
    }
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        None
    }
    fn description(&self) -> &str {
        "Default reduce action error"
    }
}