use std::str::FromStr;
use crate::ir::*;
use crate::lexer::LexError;
use crate::ir_lexer::Tok;
use crate::concrete::BV;
#[allow(unused_extern_crates)]
extern crate lalrpop_util as __lalrpop_util;
#[allow(unused_imports)]
use self::__lalrpop_util::state_machine as __state_machine;
#[cfg_attr(rustfmt, rustfmt_skip)]
mod __parse__Assign {
#![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens)]
use std::str::FromStr;
use crate::ir::*;
use crate::lexer::LexError;
use crate::ir_lexer::Tok;
use crate::concrete::BV;
#[allow(unused_extern_crates)]
extern crate lalrpop_util as __lalrpop_util;
#[allow(unused_imports)]
use self::__lalrpop_util::state_machine as __state_machine;
use super::__ToTriple;
#[allow(dead_code)]
pub enum __Symbol<'input, B>
where B: BV
{
Variant0(Tok<'input>),
Variant1(&'input str),
Variant2((String, Val<B>)),
Variant3(String),
Variant4(Val<B>),
}
const __ACTION: &[i8] = &[
0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0,
11, 0, 3, 0, 12, 13, 14, 0, 15, 0, 16, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
fn __action(state: i8, integer: usize) -> i8 {
__ACTION[(state as usize) * 13 + integer]
}
const __EOF_ACTION: &[i8] = &[
0,
0,
0,
-14,
0,
0,
-13,
-12,
-10,
-1,
-7,
-2,
-9,
-3,
-5,
-8,
-11,
];
fn __goto(state: i8, nt: usize) -> i8 {
match nt {
0 => 3,
1 => 6,
2 => 7,
3 => 4,
4 => match state {
2 => 16,
_ => 8,
},
6 => 9,
_ => 0,
}
}
fn __expected_tokens(__state: i8) -> Vec<::std::string::String> {
const __TERMINAL: &[&str] = &[
r###""()""###,
r###"",""###,
r###""-""###,
r###""=""###,
r###""bin""###,
r###""false""###,
r###""hex""###,
r###""identifier""###,
r###""natural""###,
r###""string""###,
r###""true""###,
r###""{""###,
r###""}""###,
];
__TERMINAL.iter().enumerate().filter_map(|(index, terminal)| {
let next_state = __action(__state, index);
if next_state == 0 {
None
} else {
Some(terminal.to_string())
}
}).collect()
}
pub struct __StateMachine<'input, B>
where B: BV
{
__phantom: ::std::marker::PhantomData<(&'input (), B)>,
}
impl<'input, B> __state_machine::ParserDefinition for __StateMachine<'input, B>
where B: BV
{
type Location = usize;
type Error = LexError;
type Token = Tok<'input>;
type TokenIndex = usize;
type Symbol = __Symbol<'input, B>;
type Success = (String, Val<B>);
type StateIndex = i8;
type Action = i8;
type ReduceIndex = i8;
type NonterminalIndex = usize;
#[inline]
fn start_location(&self) -> Self::Location {
Default::default()
}
#[inline]
fn start_state(&self) -> Self::StateIndex {
0
}
#[inline]
fn token_to_index(&self, token: &Self::Token) -> Option<usize> {
__token_to_integer(token, ::std::marker::PhantomData::<(&(), B)>)
}
#[inline]
fn action(&self, state: i8, integer: usize) -> i8 {
__action(state, integer)
}
#[inline]
fn error_action(&self, state: i8) -> i8 {
__action(state, 13 - 1)
}
#[inline]
fn eof_action(&self, state: i8) -> i8 {
__EOF_ACTION[state as usize]
}
#[inline]
fn goto(&self, state: i8, nt: usize) -> i8 {
__goto(state, nt)
}
fn token_to_symbol(&self, token_index: usize, token: Self::Token) -> Self::Symbol {
__token_to_symbol(token_index, token, ::std::marker::PhantomData::<(&(), B)>)
}
fn expected_tokens(&self, state: i8) -> Vec<String> {
__expected_tokens(state)
}
#[inline]
fn uses_error_recovery(&self) -> bool {
false
}
#[inline]
fn error_recovery_symbol(
&self,
recovery: __state_machine::ErrorRecovery<Self>,
) -> Self::Symbol {
panic!("error recovery not enabled for this grammar")
}
fn reduce(
&mut self,
action: i8,
start_location: Option<&Self::Location>,
states: &mut Vec<i8>,
symbols: &mut Vec<__state_machine::SymbolTriple<Self>>,
) -> Option<__state_machine::ParseResult<Self>> {
__reduce(
action,
start_location,
states,
symbols,
::std::marker::PhantomData::<(&(), B)>,
)
}
fn simulate_reduce(&self, action: i8) -> __state_machine::SimulatedReduce<Self> {
panic!("error recovery not enabled for this grammar")
}
}
fn __token_to_integer<
'input,
B,
>(
__token: &Tok<'input>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> Option<usize>
where
B: BV,
{
match *__token {
Tok::Unit if true => Some(0),
Tok::Comma if true => Some(1),
Tok::Minus if true => Some(2),
Tok::Eq if true => Some(3),
Tok::Bin(_) if true => Some(4),
Tok::False if true => Some(5),
Tok::Hex(_) if true => Some(6),
Tok::Id(_) if true => Some(7),
Tok::Nat(_) if true => Some(8),
Tok::String(_) if true => Some(9),
Tok::True if true => Some(10),
Tok::Lbrace if true => Some(11),
Tok::Rbrace if true => Some(12),
_ => None,
}
}
fn __token_to_symbol<
'input,
B,
>(
__token_index: usize,
__token: Tok<'input>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> __Symbol<'input, B>
where
B: BV,
{
match __token_index {
0 | 1 | 2 | 3 | 5 | 10 | 11 | 12 => __Symbol::Variant0(__token),
4 | 6 | 7 | 8 | 9 => match __token {
Tok::Bin(__tok0) | Tok::Hex(__tok0) | Tok::Id(__tok0) | Tok::Nat(__tok0) | Tok::String(__tok0) if true => __Symbol::Variant1(__tok0),
_ => unreachable!(),
},
_ => unreachable!(),
}
}
pub struct AssignParser {
_priv: (),
}
impl AssignParser {
pub fn new() -> AssignParser {
AssignParser {
_priv: (),
}
}
#[allow(dead_code)]
pub fn parse<
'input,
B,
__TOKEN: __ToTriple<'input, B, >,
__TOKENS: IntoIterator<Item=__TOKEN>,
>(
&self,
__tokens0: __TOKENS,
) -> Result<(String, Val<B>), __lalrpop_util::ParseError<usize, Tok<'input>, LexError>>
where
B: BV,
{
let __tokens = __tokens0.into_iter();
let mut __tokens = __tokens.map(|t| __ToTriple::to_triple(t));
__state_machine::Parser::drive(
__StateMachine {
__phantom: ::std::marker::PhantomData::<(&(), B)>,
},
__tokens,
)
}
}
pub(crate) fn __reduce<
'input,
B,
>(
__action: i8,
__lookahead_start: Option<&usize>,
__states: &mut ::std::vec::Vec<i8>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> Option<Result<(String, Val<B>),__lalrpop_util::ParseError<usize, Tok<'input>, LexError>>>
where
B: BV,
{
let (__pop_states, __nonterminal) = match __action {
0 => {
__reduce0(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
1 => {
__reduce1(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
2 => {
__reduce2(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
3 => {
__reduce3(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
4 => {
__reduce4(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
5 => {
__reduce5(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
6 => {
__reduce6(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
7 => {
__reduce7(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
8 => {
__reduce8(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
9 => {
__reduce9(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
10 => {
__reduce10(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
11 => {
__reduce11(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
12 => {
__reduce12(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
13 => {
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action1::<B>(__sym0);
return Some(Ok(__nt));
}
14 => {
__reduce14(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
_ => panic!("invalid action code {}", __action)
};
let __states_len = __states.len();
__states.truncate(__states_len - __pop_states);
let __state = *__states.last().unwrap();
let __next_state = __goto(__state, __nonterminal);
__states.push(__next_state);
None
}
#[inline(never)]
fn __symbol_type_mismatch() -> ! {
panic!("symbol type mismatch")
}
fn __pop_Variant2<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, (String, Val<B>), usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant2(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant3<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, String, usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant3(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant0<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, Tok<'input>, usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant0(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant4<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, Val<B>, usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant4(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant1<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, &'input str, usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant1(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
pub(crate) fn __reduce0<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
assert!(__symbols.len() >= 3);
let __sym2 = __pop_Variant4(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant3(__symbols);
let __start = __sym0.0.clone();
let __end = __sym2.2.clone();
let __nt = super::__action9::<B>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 0)
}
pub(crate) fn __reduce1<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action14::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 1)
}
pub(crate) fn __reduce2<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action13::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 2)
}
pub(crate) fn __reduce3<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action10::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 3)
}
pub(crate) fn __reduce4<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action11::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 4)
}
pub(crate) fn __reduce5<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action12::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 5)
}
pub(crate) fn __reduce6<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action2::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce7<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action3::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce8<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action4::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce9<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant3(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action5::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce10<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant3(__symbols);
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0.clone();
let __end = __sym1.2.clone();
let __nt = super::__action6::<B>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(2, 6)
}
pub(crate) fn __reduce11<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant3(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action7::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce12<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant3(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action8::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce14<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant4(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action0::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 8)
}
}
pub use self::__parse__Assign::AssignParser;
#[cfg_attr(rustfmt, rustfmt_skip)]
mod __parse__Val {
#![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens)]
use std::str::FromStr;
use crate::ir::*;
use crate::lexer::LexError;
use crate::ir_lexer::Tok;
use crate::concrete::BV;
#[allow(unused_extern_crates)]
extern crate lalrpop_util as __lalrpop_util;
#[allow(unused_imports)]
use self::__lalrpop_util::state_machine as __state_machine;
use super::__ToTriple;
#[allow(dead_code)]
pub enum __Symbol<'input, B>
where B: BV
{
Variant0(Tok<'input>),
Variant1(&'input str),
Variant2((String, Val<B>)),
Variant3(String),
Variant4(Val<B>),
}
const __ACTION: &[i8] = &[
7, 0, 2, 0, 8, 9, 10, 0, 11, 0, 12, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
fn __action(state: i8, integer: usize) -> i8 {
__ACTION[(state as usize) * 13 + integer]
}
const __EOF_ACTION: &[i8] = &[
0,
0,
-13,
-12,
-10,
-15,
-7,
-2,
-9,
-3,
-5,
-8,
-11,
];
fn __goto(state: i8, nt: usize) -> i8 {
match nt {
1 => 2,
2 => 3,
4 => match state {
1 => 12,
_ => 4,
},
6 => 5,
_ => 0,
}
}
fn __expected_tokens(__state: i8) -> Vec<::std::string::String> {
const __TERMINAL: &[&str] = &[
r###""()""###,
r###"",""###,
r###""-""###,
r###""=""###,
r###""bin""###,
r###""false""###,
r###""hex""###,
r###""identifier""###,
r###""natural""###,
r###""string""###,
r###""true""###,
r###""{""###,
r###""}""###,
];
__TERMINAL.iter().enumerate().filter_map(|(index, terminal)| {
let next_state = __action(__state, index);
if next_state == 0 {
None
} else {
Some(terminal.to_string())
}
}).collect()
}
pub struct __StateMachine<'input, B>
where B: BV
{
__phantom: ::std::marker::PhantomData<(&'input (), B)>,
}
impl<'input, B> __state_machine::ParserDefinition for __StateMachine<'input, B>
where B: BV
{
type Location = usize;
type Error = LexError;
type Token = Tok<'input>;
type TokenIndex = usize;
type Symbol = __Symbol<'input, B>;
type Success = Val<B>;
type StateIndex = i8;
type Action = i8;
type ReduceIndex = i8;
type NonterminalIndex = usize;
#[inline]
fn start_location(&self) -> Self::Location {
Default::default()
}
#[inline]
fn start_state(&self) -> Self::StateIndex {
0
}
#[inline]
fn token_to_index(&self, token: &Self::Token) -> Option<usize> {
__token_to_integer(token, ::std::marker::PhantomData::<(&(), B)>)
}
#[inline]
fn action(&self, state: i8, integer: usize) -> i8 {
__action(state, integer)
}
#[inline]
fn error_action(&self, state: i8) -> i8 {
__action(state, 13 - 1)
}
#[inline]
fn eof_action(&self, state: i8) -> i8 {
__EOF_ACTION[state as usize]
}
#[inline]
fn goto(&self, state: i8, nt: usize) -> i8 {
__goto(state, nt)
}
fn token_to_symbol(&self, token_index: usize, token: Self::Token) -> Self::Symbol {
__token_to_symbol(token_index, token, ::std::marker::PhantomData::<(&(), B)>)
}
fn expected_tokens(&self, state: i8) -> Vec<String> {
__expected_tokens(state)
}
#[inline]
fn uses_error_recovery(&self) -> bool {
false
}
#[inline]
fn error_recovery_symbol(
&self,
recovery: __state_machine::ErrorRecovery<Self>,
) -> Self::Symbol {
panic!("error recovery not enabled for this grammar")
}
fn reduce(
&mut self,
action: i8,
start_location: Option<&Self::Location>,
states: &mut Vec<i8>,
symbols: &mut Vec<__state_machine::SymbolTriple<Self>>,
) -> Option<__state_machine::ParseResult<Self>> {
__reduce(
action,
start_location,
states,
symbols,
::std::marker::PhantomData::<(&(), B)>,
)
}
fn simulate_reduce(&self, action: i8) -> __state_machine::SimulatedReduce<Self> {
panic!("error recovery not enabled for this grammar")
}
}
fn __token_to_integer<
'input,
B,
>(
__token: &Tok<'input>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> Option<usize>
where
B: BV,
{
match *__token {
Tok::Unit if true => Some(0),
Tok::Comma if true => Some(1),
Tok::Minus if true => Some(2),
Tok::Eq if true => Some(3),
Tok::Bin(_) if true => Some(4),
Tok::False if true => Some(5),
Tok::Hex(_) if true => Some(6),
Tok::Id(_) if true => Some(7),
Tok::Nat(_) if true => Some(8),
Tok::String(_) if true => Some(9),
Tok::True if true => Some(10),
Tok::Lbrace if true => Some(11),
Tok::Rbrace if true => Some(12),
_ => None,
}
}
fn __token_to_symbol<
'input,
B,
>(
__token_index: usize,
__token: Tok<'input>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> __Symbol<'input, B>
where
B: BV,
{
match __token_index {
0 | 1 | 2 | 3 | 5 | 10 | 11 | 12 => __Symbol::Variant0(__token),
4 | 6 | 7 | 8 | 9 => match __token {
Tok::Bin(__tok0) | Tok::Hex(__tok0) | Tok::Id(__tok0) | Tok::Nat(__tok0) | Tok::String(__tok0) if true => __Symbol::Variant1(__tok0),
_ => unreachable!(),
},
_ => unreachable!(),
}
}
pub struct ValParser {
_priv: (),
}
impl ValParser {
pub fn new() -> ValParser {
ValParser {
_priv: (),
}
}
#[allow(dead_code)]
pub fn parse<
'input,
B,
__TOKEN: __ToTriple<'input, B, >,
__TOKENS: IntoIterator<Item=__TOKEN>,
>(
&self,
__tokens0: __TOKENS,
) -> Result<Val<B>, __lalrpop_util::ParseError<usize, Tok<'input>, LexError>>
where
B: BV,
{
let __tokens = __tokens0.into_iter();
let mut __tokens = __tokens.map(|t| __ToTriple::to_triple(t));
__state_machine::Parser::drive(
__StateMachine {
__phantom: ::std::marker::PhantomData::<(&(), B)>,
},
__tokens,
)
}
}
pub(crate) fn __reduce<
'input,
B,
>(
__action: i8,
__lookahead_start: Option<&usize>,
__states: &mut ::std::vec::Vec<i8>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> Option<Result<Val<B>,__lalrpop_util::ParseError<usize, Tok<'input>, LexError>>>
where
B: BV,
{
let (__pop_states, __nonterminal) = match __action {
0 => {
__reduce0(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
1 => {
__reduce1(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
2 => {
__reduce2(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
3 => {
__reduce3(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
4 => {
__reduce4(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
5 => {
__reduce5(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
6 => {
__reduce6(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
7 => {
__reduce7(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
8 => {
__reduce8(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
9 => {
__reduce9(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
10 => {
__reduce10(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
11 => {
__reduce11(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
12 => {
__reduce12(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
13 => {
__reduce13(__lookahead_start, __symbols, ::std::marker::PhantomData::<(&(), B)>)
}
14 => {
let __sym0 = __pop_Variant4(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action0::<B>(__sym0);
return Some(Ok(__nt));
}
_ => panic!("invalid action code {}", __action)
};
let __states_len = __states.len();
__states.truncate(__states_len - __pop_states);
let __state = *__states.last().unwrap();
let __next_state = __goto(__state, __nonterminal);
__states.push(__next_state);
None
}
#[inline(never)]
fn __symbol_type_mismatch() -> ! {
panic!("symbol type mismatch")
}
fn __pop_Variant2<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, (String, Val<B>), usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant2(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant3<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, String, usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant3(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant0<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, Tok<'input>, usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant0(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant4<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, Val<B>, usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant4(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
fn __pop_Variant1<
'input,
B,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>
) -> (usize, &'input str, usize)
where B: BV
{
match __symbols.pop().unwrap() {
(__l, __Symbol::Variant1(__v), __r) => (__l, __v, __r),
_ => __symbol_type_mismatch()
}
}
pub(crate) fn __reduce0<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
assert!(__symbols.len() >= 3);
let __sym2 = __pop_Variant4(__symbols);
let __sym1 = __pop_Variant0(__symbols);
let __sym0 = __pop_Variant3(__symbols);
let __start = __sym0.0.clone();
let __end = __sym2.2.clone();
let __nt = super::__action9::<B>(__sym0, __sym1, __sym2);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(3, 0)
}
pub(crate) fn __reduce1<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action14::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 1)
}
pub(crate) fn __reduce2<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action13::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 2)
}
pub(crate) fn __reduce3<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action10::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 3)
}
pub(crate) fn __reduce4<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action11::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 4)
}
pub(crate) fn __reduce5<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant1(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action12::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant3(__nt), __end));
(1, 5)
}
pub(crate) fn __reduce6<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action2::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce7<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action3::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce8<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action4::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce9<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant3(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action5::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce10<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
assert!(__symbols.len() >= 2);
let __sym1 = __pop_Variant3(__symbols);
let __sym0 = __pop_Variant0(__symbols);
let __start = __sym0.0.clone();
let __end = __sym1.2.clone();
let __nt = super::__action6::<B>(__sym0, __sym1);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(2, 6)
}
pub(crate) fn __reduce11<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant3(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action7::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce12<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant3(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action8::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant4(__nt), __end));
(1, 6)
}
pub(crate) fn __reduce13<
'input,
B,
>(
__lookahead_start: Option<&usize>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input, B>,usize)>,
_: ::std::marker::PhantomData<(&'input (), B)>,
) -> (usize, usize)
where
B: BV,
{
let __sym0 = __pop_Variant2(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action1::<B>(__sym0);
__symbols.push((__start, __Symbol::Variant2(__nt), __end));
(1, 7)
}
}
pub use self::__parse__Val::ValParser;
fn __action0<
'input,
B,
>(
(_, __0, _): (usize, Val<B>, usize),
) -> Val<B>
where
B: BV,
{
__0
}
fn __action1<
'input,
B,
>(
(_, __0, _): (usize, (String, Val<B>), usize),
) -> (String, Val<B>)
where
B: BV,
{
__0
}
fn __action2<
'input,
B,
>(
(_, __0, _): (usize, Tok<'input>, usize),
) -> Val<B>
where
B: BV,
{
Val::Unit
}
fn __action3<
'input,
B,
>(
(_, __0, _): (usize, Tok<'input>, usize),
) -> Val<B>
where
B: BV,
{
Val::Bool(true)
}
fn __action4<
'input,
B,
>(
(_, __0, _): (usize, Tok<'input>, usize),
) -> Val<B>
where
B: BV,
{
Val::Bool(false)
}
fn __action5<
'input,
B,
>(
(_, n, _): (usize, String, usize),
) -> Val<B>
where
B: BV,
{
Val::I128(i128::from_str(&n).unwrap())
}
fn __action6<
'input,
B,
>(
(_, _, _): (usize, Tok<'input>, usize),
(_, n, _): (usize, String, usize),
) -> Val<B>
where
B: BV,
{
Val::I128(- i128::from_str(&n).unwrap())
}
fn __action7<
'input,
B,
>(
(_, hex, _): (usize, String, usize),
) -> Val<B>
where
B: BV,
{
{
let len = hex.len();
if len <= 16 {
Val::Bits(B::new(u64::from_str_radix(&hex, 16).unwrap(), len as u32 * 4))
} else {
panic!("Bitvector literal larger than 64 bits")
}
}
}
fn __action8<
'input,
B,
>(
(_, bin, _): (usize, String, usize),
) -> Val<B>
where
B: BV,
{
{
let len = bin.len();
if len <= 64 {
Val::Bits(B::new(u64::from_str_radix(&bin, 2).unwrap(), len as u32))
} else {
panic!("Bitvector literal larger than 64 bits")
}
}
}
fn __action9<
'input,
B,
>(
(_, id, _): (usize, String, usize),
(_, _, _): (usize, Tok<'input>, usize),
(_, v, _): (usize, Val<B>, usize),
) -> (String, Val<B>)
where
B: BV,
{
(id, v)
}
fn __action10<
'input,
B,
>(
(_, id, _): (usize, &'input str, usize),
) -> String
where
B: BV,
{
id.to_string()
}
fn __action11<
'input,
B,
>(
(_, nat, _): (usize, &'input str, usize),
) -> String
where
B: BV,
{
nat.to_string()
}
fn __action12<
'input,
B,
>(
(_, s, _): (usize, &'input str, usize),
) -> String
where
B: BV,
{
s.to_string()
}
fn __action13<
'input,
B,
>(
(_, b, _): (usize, &'input str, usize),
) -> String
where
B: BV,
{
b.to_string()
}
fn __action14<
'input,
B,
>(
(_, b, _): (usize, &'input str, usize),
) -> String
where
B: BV,
{
b.to_string()
}
pub trait __ToTriple<'input, B, > {
fn to_triple(value: Self) -> Result<(usize,Tok<'input>,usize), __lalrpop_util::ParseError<usize, Tok<'input>, LexError>>;
}
impl<'input, B, > __ToTriple<'input, B, > for (usize, Tok<'input>, usize) {
fn to_triple(value: Self) -> Result<(usize,Tok<'input>,usize), __lalrpop_util::ParseError<usize, Tok<'input>, LexError>> {
Ok(value)
}
}
impl<'input, B, > __ToTriple<'input, B, > for Result<(usize, Tok<'input>, usize), LexError> {
fn to_triple(value: Self) -> Result<(usize,Tok<'input>,usize), __lalrpop_util::ParseError<usize, Tok<'input>, LexError>> {
match value {
Ok(v) => Ok(v),
Err(error) => Err(__lalrpop_util::ParseError::User { error }),
}
}
}