#![crate_type = "lib"]
#![warn(rust_2018_idioms)]
#![warn(missing_docs)] #![warn(missing_debug_implementations)]
#![warn(trivial_numeric_casts)]
#[macro_use]
extern crate lazy_static;
#[doc(hidden)]
pub use lazy_static::lazy_static;
#[doc(hidden)]
pub use parking_lot::RwLock;
#[doc(hidden)]
pub use better_any::{tid, Tid, TidAble, TidExt};
#[doc(inline)]
pub use error_strategy::{BailErrorStrategy, DefaultErrorStrategy, ErrorStrategy};
pub use input_stream::InputStream;
#[doc(inline)]
pub use lexer::{BaseLexer, Lexer};
#[doc(inline)]
pub use parser::{BaseParser, ListenerId, Parser};
#[doc(inline)]
pub use token_source::TokenSource;
#[doc(hidden)]
pub use prediction_context::PredictionContextCache;
#[doc(inline)]
pub use prediction_mode::PredictionMode;
#[doc(hidden)]
pub mod atn_config;
#[doc(hidden)]
pub mod atn_simulator;
pub mod int_stream;
mod lexer_action;
mod ll1_analyzer;
#[doc(hidden)]
pub mod recognizer;
pub mod token_factory;
#[doc(hidden)]
pub mod atn_deserialization_options;
#[doc(hidden)]
pub mod atn_state;
pub mod char_stream;
#[doc(hidden)]
pub mod dfa_state;
#[doc(hidden)]
pub mod interval_set;
pub mod parser_rule_context;
mod prediction_context;
#[doc(hidden)]
pub mod semantic_context;
mod token_source;
pub mod token_stream;
#[doc(hidden)]
pub mod dfa;
#[doc(hidden)]
pub mod transition;
pub mod tree;
#[doc(hidden)]
pub mod atn;
#[doc(hidden)]
pub mod atn_config_set;
#[doc(hidden)]
pub mod atn_deserializer;
pub mod common_token_stream;
mod dfa_serializer;
pub mod error_listener;
pub mod error_strategy;
pub mod errors;
pub mod input_stream;
pub mod lexer;
#[doc(hidden)]
pub mod lexer_action_executor;
pub mod lexer_atn_simulator;
pub mod parser;
pub mod parser_atn_simulator;
mod prediction_mode;
pub mod token;
pub mod trees;
mod utils;
mod atn_type;
pub mod rule_context;
pub mod vocabulary;
use std::rc::Rc;
pub trait CoerceFrom<T> {
fn coerce_rc(from: Rc<T>) -> Rc<Self>;
fn coerce_box(from: Box<T>) -> Box<Self>;
fn coerce_ref(from: &T) -> &Self;
fn coerce_mut(from: &mut T) -> &mut Self;
}
#[doc(hidden)]
#[macro_export]
macro_rules! coerce_from {
($lt:lifetime : $p:path) => {
const _: () = {
use std::rc::Rc;
impl<$lt, T> $crate::CoerceFrom<T> for dyn $p + $lt
where
T: $p + $lt,
{
fn coerce_rc(from: Rc<T>) -> Rc<Self> {
from as _
}
fn coerce_box(from: Box<T>) -> Box<Self> {
from as _
}
fn coerce_ref(from: &T) -> &Self {
from as _
}
fn coerce_mut(from: &mut T) -> &mut Self {
from as _
}
}
};
};
}
pub trait CoerceTo<T: ?Sized> {
fn coerce_rc_to(self: Rc<Self>) -> Rc<T>;
fn coerce_box_to(self: Box<Self>) -> Box<T>;
fn coerce_ref_to(self: &Self) -> &T;
fn coerce_mut_to(self: &mut Self) -> &mut T;
}
impl<T: ?Sized, X> CoerceTo<T> for X
where
T: CoerceFrom<X>,
{
fn coerce_rc_to(self: Rc<Self>) -> Rc<T> {
T::coerce_rc(self)
}
fn coerce_box_to(self: Box<Self>) -> Box<T> {
T::coerce_box(self)
}
fn coerce_ref_to(self: &Self) -> &T {
T::coerce_ref(self)
}
fn coerce_mut_to(self: &mut Self) -> &mut T {
T::coerce_mut(self)
}
}