%%
%%
%%
%%
%%
#[expect(non_camel_case_types)]
#[derive(Default)]
pub struct yyStackEntry<'i> {
stateno: YYACTIONTYPE,
major: YYCODETYPE,
minor: YYMINORTYPE<'i>,
}
use crate::parser::stack::Stack;
#[expect(non_camel_case_types)]
pub struct yyParser<'input> {
#[cfg(feature = "YYTRACKMAXSTACKDEPTH")]
yyhwm: usize,
yyerrcnt: i32,
%%
yystack: Stack<yyStackEntry<'input>>,
}
#[cfg(not(feature = "NDEBUG"))]
use log::{debug, log_enabled, Level::Debug};
static TARGET: &str = "Parse";
#[cfg(any(feature = "YYCOVERAGE", not(feature = "NDEBUG")))]
%%
#[cfg(not(feature = "NDEBUG"))]
#[rustfmt::skip]
#[expect(non_upper_case_globals)]
static yyRuleName: [&str; YYNRULE] = [
%%
];
impl yyParser<'_> {
fn yy_grow_stack_if_needed(&mut self) -> bool {
false
}
fn yy_grow_stack_for_push(&mut self) -> bool {
self.yystack.grow();
false
}
}
impl yyParser<'_> {
pub fn new(
%%
) -> yyParser {
let mut p = yyParser {
#[cfg(feature = "YYTRACKMAXSTACKDEPTH")]
yyhwm: 0,
yystack: Stack::with_capacity(YYSTACKDEPTH),
yyerrcnt: -1,
%%
};
p.yystack.push(yyStackEntry::default());
p
}
}
impl yyParser<'_> {
fn yy_pop_parser_stack(&mut self) {
let _yytos = self.yystack.pop();
#[cfg(not(feature = "NDEBUG"))]
{
debug!(
target: TARGET,
"Popping {}", yyTokenName[_yytos.major as usize]
);
}
}
}
impl yyParser<'_> {
#[expect(non_snake_case)]
pub fn ParseFinalize(&mut self) {
while self.yystack.yyidx > 0 {
self.yy_pop_parser_stack();
}
}
}
#[cfg(feature = "YYTRACKMAXSTACKDEPTH")]
impl yyParser<'_> {
#[expect(non_snake_case)]
pub fn ParseStackPeak(&self) -> usize {
self.yyhwm
}
fn yyhwm_incr(&mut self) {
if self.yystack.yyidx > self.yyhwm {
self.yyhwm += 1;
assert_eq!(self.yyhwm, self.yystack.yyidx);
}
}
}
#[cfg(not(feature = "YYTRACKMAXSTACKDEPTH"))]
impl yyParser<'_> {
#[inline]
fn yyhwm_incr(&mut self) {}
}
#[cfg(feature = "YYCOVERAGE")]
static yycoverage: [[bool; YYNTOKEN]; YYNSTATE] = [];
#[cfg(feature = "YYCOVERAGE")]
fn ParseCoverage() -> i32 {
let mut nMissed = 0;
return nMissed;
}
#[expect(non_snake_case)]
fn yy_find_shift_action(
mut iLookAhead: YYCODETYPE,
stateno: YYACTIONTYPE,
) -> YYACTIONTYPE {
if stateno > YY_MAX_SHIFT {
return stateno;
}
assert!(stateno <= YY_SHIFT_COUNT);
#[cfg(feature = "YYCOVERAGE")]
{
}
loop {
let mut i = yy_shift_ofst[stateno as usize] as usize;
assert!(i <= YY_ACTTAB_COUNT!());
assert!(i + usize::from(YYNTOKEN) <= yy_lookahead.len());
assert_ne!(iLookAhead, YYNOCODE);
assert!((iLookAhead as YYACTIONTYPE) < YYNTOKEN);
i += iLookAhead as usize;
if yy_lookahead[i] != iLookAhead {
if YYFALLBACK {
let iFallback = yyFallback[iLookAhead as usize];
if iFallback != 0 {
#[cfg(not(feature = "NDEBUG"))]
{
debug!(
target: TARGET,
"FALLBACK {} => {}",
yyTokenName[iLookAhead as usize],
yyTokenName[iFallback as usize]
);
}
assert_eq!(yyFallback[iFallback as usize], 0);
iLookAhead = iFallback;
continue;
}
}
if YYWILDCARD > 0 {
let j = i - iLookAhead as usize + YYWILDCARD as usize;
if yy_lookahead[j] == YYWILDCARD && iLookAhead > 0 {
#[cfg(not(feature = "NDEBUG"))]
{
debug!(
target: TARGET,
"WILDCARD {} => {}",
yyTokenName[iLookAhead as usize],
yyTokenName[YYWILDCARD as usize]
);
}
return yy_action[j];
}
}
return yy_default[stateno as usize];
} else {
return yy_action[i];
}
}
}
#[expect(non_snake_case)]
fn yy_find_reduce_action(
stateno: YYACTIONTYPE,
iLookAhead: YYCODETYPE,
) -> YYACTIONTYPE {
if YYERRORSYMBOL > 0 {
if stateno > YY_REDUCE_COUNT {
return yy_default[stateno as usize];
}
} else {
assert!(stateno <= YY_REDUCE_COUNT);
}
let mut i: i32 = yy_reduce_ofst[stateno as usize].into();
assert_ne!(iLookAhead, YYNOCODE);
i += i32::from(iLookAhead);
if YYERRORSYMBOL > 0 {
if !(0..YY_ACTTAB_COUNT!()).contains(&i) || yy_lookahead[i as usize] != iLookAhead {
return yy_default[stateno as usize];
}
} else {
assert!((0..YY_ACTTAB_COUNT!()).contains(&i));
assert_eq!(yy_lookahead[i as usize], iLookAhead);
}
yy_action[i as usize]
}
#[expect(non_snake_case)]
#[cfg(feature = "NDEBUG")]
fn yyTraceShift(_yystack: &Stack<yyStackEntry>, _: YYACTIONTYPE, _: &str) {
}
#[expect(non_snake_case)]
#[cfg(not(feature = "NDEBUG"))]
fn yyTraceShift(yystack: &Stack<yyStackEntry>, yyNewState: YYACTIONTYPE, zTag: &str) {
let yytos = &yystack[0];
if yyNewState < YYNSTATE {
debug!(
target: TARGET,
"{} '{}', go to state {}", zTag, yyTokenName[yytos.major as usize], yyNewState
);
} else {
debug!(
target: TARGET,
"{} '{}', pending reduce {:?}",
zTag,
yyTokenName[yytos.major as usize],
yyNewState.checked_sub(YY_MIN_REDUCE)
);
}
}
impl<'input> yyParser<'input> {
#[expect(non_snake_case)]
fn yy_shift(
&mut self,
mut yyNewState: YYACTIONTYPE,
yyMajor: YYCODETYPE,
yyMinor: ParseTOKENTYPE<'input>,
) {
self.yystack.yyidx_shift(1);
self.yyhwm_incr();
if self.yy_grow_stack_if_needed() {
return;
}
if yyNewState > YY_MAX_SHIFT {
yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
}
let yytos = yyStackEntry {
stateno: yyNewState,
major: yyMajor,
minor: YYMINORTYPE::yy0(yyMinor),
};
self.yystack.push(yytos);
yyTraceShift(&self.yystack, yyNewState, "Shift");
}
}
#[expect(non_upper_case_globals)]
static yyRuleInfoLhs: [YYCODETYPE; YYNRULE] = [
%%
];
#[expect(non_upper_case_globals)]
static yyRuleInfoNRhs: [i8; YYNRULE] = [
%%
];
impl yyParser<'_> {
fn yy_reduce(
&mut self,
yyruleno: YYACTIONTYPE,
yy_look_ahead: YYCODETYPE,
yy_lookahead_token: &ParseTOKENTYPE,
) -> Result<YYACTIONTYPE, ParseError> {
let _ = yy_look_ahead;
let _ = yy_lookahead_token;
let yylhsminor: YYMINORTYPE<'_>;
match yyruleno {
%%
}
let yygoto: YYCODETYPE = yyRuleInfoLhs[yyruleno as usize];
let yysize: i8 = yyRuleInfoNRhs[yyruleno as usize];
let yyact: YYACTIONTYPE = yy_find_reduce_action(self.yystack[yysize].stateno, yygoto);
assert!(!(yyact > YY_MAX_SHIFT && yyact <= YY_MAX_SHIFTREDUCE));
assert_ne!(yyact, YY_ERROR_ACTION);
self.yystack.yyidx_shift(yysize + 1);
{
let yymsp = &mut self.yystack[0];
yymsp.stateno = yyact;
yymsp.major = yygoto;
}
yyTraceShift(&self.yystack, yyact, "... then shift");
Ok(yyact)
}
}
impl yyParser<'_> {
#[cfg(not(feature = "YYNOERRORRECOVERY"))]
fn yy_parse_failed(&mut self) {
#[cfg(not(feature = "NDEBUG"))]
{
error!(target: TARGET, "Fail!");
}
while self.yystack.yyidx > 0 {
self.yy_pop_parser_stack();
}
%%
}
#[cfg(feature = "YYNOERRORRECOVERY")]
fn yy_parse_failed(&mut self) {}
}
impl yyParser<'_> {
fn yy_syntax_error(
&mut self,
yymajor: YYCODETYPE,
yyminor: &ParseTOKENTYPE,
) {
%%
}
}
impl yyParser<'_> {
fn yy_accept(&mut self) {
#[cfg(not(feature = "NDEBUG"))]
{
debug!(target: TARGET, "Accept!");
}
if cfg!(not(feature = "YYNOERRORRECOVERY")) {
self.yyerrcnt = -1;
}
assert_eq!(self.yystack.yyidx, 0);
%%
}
}
impl<'input> yyParser<'input> {
#[expect(non_snake_case)]
pub fn Parse(
&mut self,
yymajor: TokenType,
yyminor: ParseTOKENTYPE<'input>,
) -> Result<(), ParseError> {
let mut yymajor = yymajor as YYCODETYPE;
let mut yyendofinput: bool = false;
let mut yyerrorhit: bool = false;
if YYERRORSYMBOL == 0 && cfg!(not(feature = "YYNOERRORRECOVERY")) {
yyendofinput = yymajor == 0;
}
let mut yyact: YYACTIONTYPE = self.yystack[0].stateno;
#[cfg(not(feature = "NDEBUG"))]
{
if yyact < YY_MIN_REDUCE {
debug!(
target: TARGET,
"Input '{}' in state {}", yyTokenName[yymajor as usize], yyact
);
} else {
debug!(
target: TARGET,
"Input '{}' with pending reduce {}",
yyTokenName[yymajor as usize],
yyact - YY_MIN_REDUCE
);
}
}
loop {
assert_eq!(yyact, self.yystack[0].stateno);
yyact = yy_find_shift_action(yymajor, yyact);
if yyact >= YY_MIN_REDUCE {
let yyruleno = yyact - YY_MIN_REDUCE;
#[cfg(not(feature = "NDEBUG"))]
{
assert!((yyruleno as usize) < yyRuleName.len());
let yysize = yyRuleInfoNRhs[yyruleno as usize];
let action = if yyruleno < YYNRULE_WITH_ACTION {
""
} else {
" without external action"
};
if yysize != 0 {
debug!(
target: TARGET,
"Reduce {} [{}]{}, pop back to state {}.",
yyruleno,
yyRuleName[yyruleno as usize],
action,
self.yystack[yysize].stateno
);
} else {
debug!(
target: TARGET,
"Reduce {} [{}]{}.", yyruleno, yyRuleName[yyruleno as usize], action
);
}
}
if yyRuleInfoNRhs[yyruleno as usize] == 0 {
self.yyhwm_incr();
if self.yy_grow_stack_for_push() {
break;
}
}
yyact = self.yy_reduce(yyruleno, yymajor, &yyminor)?;
} else if yyact <= YY_MAX_SHIFTREDUCE {
self.yy_shift(yyact, yymajor, yyminor);
if cfg!(not(feature = "YYNOERRORRECOVERY")) {
self.yyerrcnt -= 1;
}
break;
} else if yyact == YY_ACCEPT_ACTION {
self.yystack.yyidx_shift(-1);
self.yy_accept();
return Ok(());
} else {
assert_eq!(yyact, YY_ERROR_ACTION);
#[cfg(not(feature = "NDEBUG"))]
{
debug!(target: TARGET, "Syntax Error!");
}
if YYERRORSYMBOL > 0 {
if self.yyerrcnt < 0 {
self.yy_syntax_error(yymajor, &yyminor);
}
let yymx = self.yystack[0].major;
if yymx == YYERRORSYMBOL || yyerrorhit {
#[cfg(not(feature = "NDEBUG"))]
{
debug!(
target: TARGET,
"Discard input token {}", yyTokenName[yymajor as usize]
);
}
yymajor = YYNOCODE;
} else {
while self.yystack.yyidx > 0 {
yyact = yy_find_reduce_action(self.yystack[0].stateno, YYERRORSYMBOL);
if yyact <= YY_MAX_SHIFTREDUCE {
break;
}
self.yy_pop_parser_stack();
}
if self.yystack.yyidx <= 0 || yymajor == 0 {
self.yy_parse_failed();
if cfg!(not(feature = "YYNOERRORRECOVERY")) {
self.yyerrcnt = -1;
}
yymajor = YYNOCODE;
} else if yymx != YYERRORSYMBOL {
self.yy_shift(yyact, YYERRORSYMBOL, yyminor);
}
}
self.yyerrcnt = 3;
yyerrorhit = true;
if yymajor == YYNOCODE {
break;
}
yyact = self.yystack[0].stateno;
} else if cfg!(feature = "YYNOERRORRECOVERY") {
self.yy_syntax_error(yymajor, &yyminor);
break;
} else {
if self.yyerrcnt <= 0 {
self.yy_syntax_error(yymajor, &yyminor);
}
self.yyerrcnt = 3;
if yyendofinput {
self.yy_parse_failed();
if cfg!(not(feature = "YYNOERRORRECOVERY")) {
self.yyerrcnt = -1;
}
}
break;
}
}
if self.yystack.yyidx <= 0 {
break;
}
}
#[cfg(not(feature = "NDEBUG"))]
{
if log_enabled!(target: TARGET, Debug) {
let msg = self.yystack.vec[1..=self.yystack.yyidx]
.iter()
.map(|entry| yyTokenName[entry.major as usize])
.collect::<std::vec::Vec<&str>>()
.join(" ");
debug!(target: TARGET, "Return. Stack=[{}]", msg);
}
}
return Ok(());
}
pub fn parse_fallback(i_token: YYCODETYPE) -> YYCODETYPE {
if YYFALLBACK {
return yyFallback[i_token as usize];
}
0
}
}