use crate::atn::ATN;
use crate::parser::ParserNodeType;
use crate::token_factory::TokenAware;
use crate::vocabulary::Vocabulary;
pub const VERSION_MAJOR: &'static str = env!("CARGO_PKG_VERSION_MAJOR");
pub const VERSION_MINOR: &'static str = env!("CARGO_PKG_VERSION_MINOR");
pub fn check_version(major: &str, minor: &str) {
assert!(major == VERSION_MAJOR && minor == VERSION_MINOR,
"parser is not compatible with current runtime version, please generate parser with the latest version of ANTLR")
}
pub trait Recognizer<'input>: TokenAware<'input> {
type Node: ParserNodeType<'input, TF = Self::TF>;
fn sempred(
&mut self,
_localctx: Option<&<Self::Node as ParserNodeType<'input>>::Type>,
_rule_index: isize,
_action_index: isize,
) -> bool
where
Self: Sized,
{
true
}
fn action(
&mut self,
_localctx: Option<&<Self::Node as ParserNodeType<'input>>::Type>,
_rule_index: isize,
_action_index: isize,
) where
Self: Sized,
{
}
fn get_rule_names(&self) -> &[&str] { &[] }
fn get_vocabulary(&self) -> &dyn Vocabulary { unimplemented!() }
fn get_grammar_file_name(&self) -> &str { "" }
fn get_atn(&self) -> &ATN { unimplemented!() }
}
pub trait Actions<'a, P: Recognizer<'a>> {
fn sempred(
_localctx: Option<&<P::Node as ParserNodeType<'a>>::Type>,
_rule_index: isize,
_action_index: isize,
_recog: &mut P,
) -> bool {
true
}
fn action(
_localctx: Option<&<P::Node as ParserNodeType<'a>>::Type>,
_rule_index: isize,
_action_index: isize,
_recog: &mut P,
) {
}
fn get_rule_names(&self) -> &[&str] { &[] }
fn get_vocabulary(&self) -> &dyn Vocabulary { unimplemented!() }
fn get_grammar_file_name(&self) -> &str { "" }
fn get_atn(&self) -> &ATN { unimplemented!() }
}