Merge pull request #211 from nixpulvis/ignore-doc-generated-files

Remove and ignore generated files.
This commit is contained in:
Niko Matsakis 2017-04-01 21:10:58 -04:00 committed by GitHub
commit 007d6a810e
7 changed files with 6 additions and 527025 deletions

6
.gitignore vendored
View File

@ -4,7 +4,13 @@ TAGS
Cargo.lock
lalrpop/src/parser/lrgrammar.rs
doc/calculator/src/calculator1.rs
doc/calculator/src/calculator2.rs
doc/calculator/src/calculator3.rs
doc/calculator/src/calculator4.rs
doc/calculator/src/calculator5.rs
doc/calculator/src/calculator6.rs
doc/pascal/lalrpop/src/pascal.rs
doc/whitespace/src/parser.rs
lalrpop-test/src/error.rs

View File

@ -1,809 +0,0 @@
#![allow(unused_imports)]
#![allow(unused_variables)]
use std::str::FromStr;
extern crate lalrpop_util as __lalrpop_util;
use self::__lalrpop_util::ParseError as __ParseError;
mod __parse__Term {
#![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports)]
use std::str::FromStr;
extern crate lalrpop_util as __lalrpop_util;
use self::__lalrpop_util::ParseError as __ParseError;
pub fn parse_Term<
'input,
>(
input: &'input str,
) -> Result<i32, __ParseError<usize,(usize, &'input str),()>>
{
let mut __tokens = super::__intern_token::__Matcher::new(input);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match try!(__state0(input, None, &mut __tokens, __lookahead)) {
(_, Some(__lookahead), _) => {
Err(__ParseError::ExtraToken { token: __lookahead })
}
(_, None, __Nonterminal::____Term(__nt)) => {
Ok(__nt)
}
_ => unreachable!(),
}
}
#[allow(dead_code)]
pub enum __Nonterminal<> {
Term(i32),
Num(i32),
____Term(i32),
}
// State 0
// Num = (*) r#"[0-9]+"# [EOF]
// Term = (*) Num [EOF]
// Term = (*) "(" Term ")" [EOF]
// __Term = (*) Term [EOF]
//
// "(" -> Shift(S2)
// r#"[0-9]+"# -> Shift(S4)
//
// Term -> S3
// Num -> S1
pub fn __state0<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
Some((_, (1, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym0 = &mut Some((__tok0));
__result = try!(__state2(input, __lookbehind, __tokens, __sym0));
}
Some((_, (0, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym0 = &mut Some((__tok0));
__result = try!(__state4(input, __lookbehind, __tokens, __sym0));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
loop {
let (__lookbehind, __lookahead, __nt) = __result;
match __nt {
__Nonterminal::Term(__nt) => {
let __sym0 = &mut Some(__nt);
__result = try!(__state3(input, __lookbehind, __tokens, __lookahead, __sym0));
}
__Nonterminal::Num(__nt) => {
let __sym0 = &mut Some(__nt);
__result = try!(__state1(input, __lookbehind, __tokens, __lookahead, __sym0));
}
_ => {
return Ok((__lookbehind, __lookahead, __nt));
}
}
}
}
// State 1
// Term = Num (*) [EOF]
//
// EOF -> Reduce(Term = Num => Call(ActionFn(1));)
//
pub fn __state1<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
None => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action1(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 2
// Num = (*) r#"[0-9]+"# [")"]
// Term = (*) Num [")"]
// Term = (*) "(" Term ")" [")"]
// Term = "(" (*) Term ")" [EOF]
//
// r#"[0-9]+"# -> Shift(S7)
// "(" -> Shift(S6)
//
// Num -> S8
// Term -> S5
pub fn __state2<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
Some((_, (0, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym1 = &mut Some((__tok0));
__result = try!(__state7(input, __lookbehind, __tokens, __sym1));
}
Some((_, (1, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym1 = &mut Some((__tok0));
__result = try!(__state6(input, __lookbehind, __tokens, __sym1));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
while __sym0.is_some() {
let (__lookbehind, __lookahead, __nt) = __result;
match __nt {
__Nonterminal::Num(__nt) => {
let __sym1 = &mut Some(__nt);
__result = try!(__state8(input, __lookbehind, __tokens, __lookahead, __sym1));
}
__Nonterminal::Term(__nt) => {
let __sym1 = &mut Some(__nt);
__result = try!(__state5(input, __lookbehind, __tokens, __lookahead, __sym0, __sym1));
}
_ => {
return Ok((__lookbehind, __lookahead, __nt));
}
}
}
return Ok(__result);
}
// State 3
// __Term = Term (*) [EOF]
//
// EOF -> Reduce(__Term = Term => Call(ActionFn(0));)
//
pub fn __state3<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
None => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action0(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::____Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 4
// Num = r#"[0-9]+"# (*) [EOF]
//
// EOF -> Reduce(Num = r#"[0-9]+"# => Call(ActionFn(3));)
//
pub fn __state4<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
None => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action3(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::Num(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 5
// Term = "(" Term (*) ")" [EOF]
//
// ")" -> Shift(S9)
//
pub fn __state5<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<&'input str>,
__sym1: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
Some((_, (2, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym2 = &mut Some((__tok0));
__result = try!(__state9(input, __lookbehind, __tokens, __sym0, __sym1, __sym2));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
return Ok(__result);
}
// State 6
// Num = (*) r#"[0-9]+"# [")"]
// Term = (*) Num [")"]
// Term = (*) "(" Term ")" [")"]
// Term = "(" (*) Term ")" [")"]
//
// "(" -> Shift(S6)
// r#"[0-9]+"# -> Shift(S7)
//
// Term -> S10
// Num -> S8
pub fn __state6<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
Some((_, (1, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym1 = &mut Some((__tok0));
__result = try!(__state6(input, __lookbehind, __tokens, __sym1));
}
Some((_, (0, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym1 = &mut Some((__tok0));
__result = try!(__state7(input, __lookbehind, __tokens, __sym1));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
while __sym0.is_some() {
let (__lookbehind, __lookahead, __nt) = __result;
match __nt {
__Nonterminal::Term(__nt) => {
let __sym1 = &mut Some(__nt);
__result = try!(__state10(input, __lookbehind, __tokens, __lookahead, __sym0, __sym1));
}
__Nonterminal::Num(__nt) => {
let __sym1 = &mut Some(__nt);
__result = try!(__state8(input, __lookbehind, __tokens, __lookahead, __sym1));
}
_ => {
return Ok((__lookbehind, __lookahead, __nt));
}
}
}
return Ok(__result);
}
// State 7
// Num = r#"[0-9]+"# (*) [")"]
//
// ")" -> Reduce(Num = r#"[0-9]+"# => Call(ActionFn(3));)
//
pub fn __state7<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
Some((_, (2, _), _)) => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action3(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::Num(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 8
// Term = Num (*) [")"]
//
// ")" -> Reduce(Term = Num => Call(ActionFn(1));)
//
pub fn __state8<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
Some((_, (2, _), _)) => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action1(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 9
// Term = "(" Term ")" (*) [EOF]
//
// EOF -> Reduce(Term = "(", Term, ")" => Call(ActionFn(2));)
//
pub fn __state9<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
__sym1: &mut Option<i32>,
__sym2: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
None => {
let __sym0 = __sym0.take().unwrap();
let __sym1 = __sym1.take().unwrap();
let __sym2 = __sym2.take().unwrap();
let __nt = super::__action2(input, __sym0, __sym1, __sym2);
return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 10
// Term = "(" Term (*) ")" [")"]
//
// ")" -> Shift(S11)
//
pub fn __state10<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<&'input str>,
__sym1: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
Some((_, (2, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym2 = &mut Some((__tok0));
__result = try!(__state11(input, __lookbehind, __tokens, __sym0, __sym1, __sym2));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
return Ok(__result);
}
// State 11
// Term = "(" Term ")" (*) [")"]
//
// ")" -> Reduce(Term = "(", Term, ")" => Call(ActionFn(2));)
//
pub fn __state11<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
__sym1: &mut Option<i32>,
__sym2: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
Some((_, (2, _), _)) => {
let __sym0 = __sym0.take().unwrap();
let __sym1 = __sym1.take().unwrap();
let __sym2 = __sym2.take().unwrap();
let __nt = super::__action2(input, __sym0, __sym1, __sym2);
return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
}
pub use self::__parse__Term::parse_Term;
mod __intern_token {
extern crate lalrpop_util as __lalrpop_util;
use self::__lalrpop_util::ParseError as __ParseError;
pub struct __Matcher<'input> {
text: &'input str,
consumed: usize,
}
fn __tokenize(text: &str) -> Option<(usize, usize)> {
let mut __chars = text.char_indices();
let mut __current_match: Option<(usize, usize)> = None;
let mut __current_state: usize = 0;
loop {
match __current_state {
0 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
'(' => {
__current_match = Some((1, __index + 1));
__current_state = 3;
continue;
}
')' => {
__current_match = Some((2, __index + 1));
__current_state = 2;
continue;
}
'0' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'1' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'2' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'3' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'4' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'5' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'6' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'7' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'8' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'9' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
_ => {
return __current_match;
}
}
}
1 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
'0' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'1' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'2' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'3' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'4' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'5' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'6' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'7' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'8' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
'9' => {
__current_match = Some((0, __index + 1));
__current_state = 1;
continue;
}
_ => {
return __current_match;
}
}
}
2 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
_ => {
return __current_match;
}
}
}
3 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
_ => {
return __current_match;
}
}
}
4 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
_ => {
return __current_match;
}
}
}
_ => { panic!("invalid state {}", __current_state); }
}
}
}
impl<'input> __Matcher<'input> {
pub fn new(s: &'input str) -> __Matcher<'input> {
__Matcher { text: s, consumed: 0 }
}
}
impl<'input> Iterator for __Matcher<'input> {
type Item = Result<(usize, (usize, &'input str), usize), __ParseError<usize,(usize, &'input str),()>>;
fn next(&mut self) -> Option<Self::Item> {
let __text = self.text.trim_left();
let __whitespace = self.text.len() - __text.len();
let __start_offset = self.consumed + __whitespace;
if __text.is_empty() {
self.text = __text;
self.consumed = __start_offset;
None
} else {
match __tokenize(__text) {
Some((__index, __length)) => {
let __result = &__text[..__length];
let __remaining = &__text[__length..];
let __end_offset = __start_offset + __length;
self.text = __remaining;
self.consumed = __end_offset;
Some(Ok((__start_offset, (__index, __result), __end_offset)))
}
None => {
Some(Err(__ParseError::InvalidToken { location: __start_offset }))
}
}
}
}
}
}
pub fn __action0<
'input,
>(
input: &'input str,
__0: i32,
) -> i32
{
(__0)
}
pub fn __action1<
'input,
>(
input: &'input str,
n: i32,
) -> i32
{
n
}
pub fn __action2<
'input,
>(
input: &'input str,
_: &'input str,
t: i32,
_: &'input str,
) -> i32
{
t
}
pub fn __action3<
'input,
>(
input: &'input str,
s: &'input str,
) -> i32
{
i32::from_str(s).unwrap()
}
pub trait __ToTriple<'input, > {
type Error;
fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),Self::Error>;
}
impl<'input, > __ToTriple<'input, > for (usize, (usize, &'input str), usize) {
type Error = ();
fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),()> {
Ok(value)
}
}
impl<'input, > __ToTriple<'input, > for Result<(usize, (usize, &'input str), usize),()> {
type Error = ();
fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),()> {
value
}
}

View File

@ -1,809 +0,0 @@
#![allow(unused_imports)]
#![allow(unused_variables)]
use std::str::FromStr;
extern crate lalrpop_util as __lalrpop_util;
use self::__lalrpop_util::ParseError as __ParseError;
mod __parse__Term {
#![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports)]
use std::str::FromStr;
extern crate lalrpop_util as __lalrpop_util;
use self::__lalrpop_util::ParseError as __ParseError;
pub fn parse_Term<
'input,
>(
input: &'input str,
) -> Result<i32, __ParseError<usize,(usize, &'input str),()>>
{
let mut __tokens = super::__intern_token::__Matcher::new(input);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match try!(__state0(input, None, &mut __tokens, __lookahead)) {
(_, Some(__lookahead), _) => {
Err(__ParseError::ExtraToken { token: __lookahead })
}
(_, None, __Nonterminal::____Term(__nt)) => {
Ok(__nt)
}
_ => unreachable!(),
}
}
#[allow(dead_code)]
pub enum __Nonterminal<> {
____Term(i32),
Num(i32),
Term(i32),
}
// State 0
// Num = (*) r#"[0-9]+"# [EOF]
// Term = (*) Num [EOF]
// Term = (*) "(" Term ")" [EOF]
// __Term = (*) Term [EOF]
//
// "(" -> Shift(S1)
// r#"[0-9]+"# -> Shift(S4)
//
// Term -> S2
// Num -> S3
pub fn __state0<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
Some((_, (1, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym0 = &mut Some((__tok0));
__result = try!(__state1(input, __lookbehind, __tokens, __sym0));
}
Some((_, (2, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym0 = &mut Some((__tok0));
__result = try!(__state4(input, __lookbehind, __tokens, __sym0));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
loop {
let (__lookbehind, __lookahead, __nt) = __result;
match __nt {
__Nonterminal::Term(__nt) => {
let __sym0 = &mut Some(__nt);
__result = try!(__state2(input, __lookbehind, __tokens, __lookahead, __sym0));
}
__Nonterminal::Num(__nt) => {
let __sym0 = &mut Some(__nt);
__result = try!(__state3(input, __lookbehind, __tokens, __lookahead, __sym0));
}
_ => {
return Ok((__lookbehind, __lookahead, __nt));
}
}
}
}
// State 1
// Num = (*) r#"[0-9]+"# [")"]
// Term = (*) Num [")"]
// Term = (*) "(" Term ")" [")"]
// Term = "(" (*) Term ")" [EOF]
//
// "(" -> Shift(S7)
// r#"[0-9]+"# -> Shift(S5)
//
// Num -> S6
// Term -> S8
pub fn __state1<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
Some((_, (1, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym1 = &mut Some((__tok0));
__result = try!(__state7(input, __lookbehind, __tokens, __sym1));
}
Some((_, (2, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym1 = &mut Some((__tok0));
__result = try!(__state5(input, __lookbehind, __tokens, __sym1));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
while __sym0.is_some() {
let (__lookbehind, __lookahead, __nt) = __result;
match __nt {
__Nonterminal::Num(__nt) => {
let __sym1 = &mut Some(__nt);
__result = try!(__state6(input, __lookbehind, __tokens, __lookahead, __sym1));
}
__Nonterminal::Term(__nt) => {
let __sym1 = &mut Some(__nt);
__result = try!(__state8(input, __lookbehind, __tokens, __lookahead, __sym0, __sym1));
}
_ => {
return Ok((__lookbehind, __lookahead, __nt));
}
}
}
return Ok(__result);
}
// State 2
// __Term = Term (*) [EOF]
//
// EOF -> Reduce(__Term = Term => Call(ActionFn(0));)
//
pub fn __state2<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
None => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action0(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::____Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 3
// Term = Num (*) [EOF]
//
// EOF -> Reduce(Term = Num => Call(ActionFn(1));)
//
pub fn __state3<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
None => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action1(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 4
// Num = r#"[0-9]+"# (*) [EOF]
//
// EOF -> Reduce(Num = r#"[0-9]+"# => Call(ActionFn(3));)
//
pub fn __state4<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
None => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action3(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::Num(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 5
// Num = r#"[0-9]+"# (*) [")"]
//
// ")" -> Reduce(Num = r#"[0-9]+"# => Call(ActionFn(3));)
//
pub fn __state5<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
Some((_, (0, _), _)) => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action3(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::Num(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 6
// Term = Num (*) [")"]
//
// ")" -> Reduce(Term = Num => Call(ActionFn(1));)
//
pub fn __state6<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
Some((_, (0, _), _)) => {
let __sym0 = __sym0.take().unwrap();
let __nt = super::__action1(input, __sym0);
return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 7
// Num = (*) r#"[0-9]+"# [")"]
// Term = (*) Num [")"]
// Term = (*) "(" Term ")" [")"]
// Term = "(" (*) Term ")" [")"]
//
// r#"[0-9]+"# -> Shift(S5)
// "(" -> Shift(S7)
//
// Num -> S6
// Term -> S9
pub fn __state7<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
Some((_, (2, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym1 = &mut Some((__tok0));
__result = try!(__state5(input, __lookbehind, __tokens, __sym1));
}
Some((_, (1, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym1 = &mut Some((__tok0));
__result = try!(__state7(input, __lookbehind, __tokens, __sym1));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
while __sym0.is_some() {
let (__lookbehind, __lookahead, __nt) = __result;
match __nt {
__Nonterminal::Num(__nt) => {
let __sym1 = &mut Some(__nt);
__result = try!(__state6(input, __lookbehind, __tokens, __lookahead, __sym1));
}
__Nonterminal::Term(__nt) => {
let __sym1 = &mut Some(__nt);
__result = try!(__state9(input, __lookbehind, __tokens, __lookahead, __sym0, __sym1));
}
_ => {
return Ok((__lookbehind, __lookahead, __nt));
}
}
}
return Ok(__result);
}
// State 8
// Term = "(" Term (*) ")" [EOF]
//
// ")" -> Shift(S10)
//
pub fn __state8<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<&'input str>,
__sym1: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
Some((_, (0, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym2 = &mut Some((__tok0));
__result = try!(__state10(input, __lookbehind, __tokens, __sym0, __sym1, __sym2));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
return Ok(__result);
}
// State 9
// Term = "(" Term (*) ")" [")"]
//
// ")" -> Shift(S11)
//
pub fn __state9<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__lookahead: Option<(usize, (usize, &'input str), usize)>,
__sym0: &mut Option<&'input str>,
__sym1: &mut Option<i32>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
match __lookahead {
Some((_, (0, __tok0), __loc)) => {
let mut __lookbehind = Some(__loc);
let mut __sym2 = &mut Some((__tok0));
__result = try!(__state11(input, __lookbehind, __tokens, __sym0, __sym1, __sym2));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
return Ok(__result);
}
// State 10
// Term = "(" Term ")" (*) [EOF]
//
// EOF -> Reduce(Term = "(", Term, ")" => Call(ActionFn(2));)
//
pub fn __state10<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
__sym1: &mut Option<i32>,
__sym2: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
None => {
let __sym0 = __sym0.take().unwrap();
let __sym1 = __sym1.take().unwrap();
let __sym2 = __sym2.take().unwrap();
let __nt = super::__action2(input, __sym0, __sym1, __sym2);
return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
// State 11
// Term = "(" Term ")" (*) [")"]
//
// ")" -> Reduce(Term = "(", Term, ")" => Call(ActionFn(2));)
//
pub fn __state11<
'input,
__TOKENS: Iterator<Item=Result<(usize, (usize, &'input str), usize),__ParseError<usize,(usize, &'input str),()>>>,
>(
input: &'input str,
__lookbehind: Option<usize>,
__tokens: &mut __TOKENS,
__sym0: &mut Option<&'input str>,
__sym1: &mut Option<i32>,
__sym2: &mut Option<&'input str>,
) -> Result<(Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>), __ParseError<usize,(usize, &'input str),()>>
{
let mut __result: (Option<usize>, Option<(usize, (usize, &'input str), usize)>, __Nonterminal<>);
let __lookahead = match __tokens.next() {
Some(Ok(v)) => Some(v),
None => None,
Some(Err(e)) => return Err(e),
};
match __lookahead {
Some((_, (0, _), _)) => {
let __sym0 = __sym0.take().unwrap();
let __sym1 = __sym1.take().unwrap();
let __sym2 = __sym2.take().unwrap();
let __nt = super::__action2(input, __sym0, __sym1, __sym2);
return Ok((__lookbehind, __lookahead, __Nonterminal::Term(__nt)));
}
_ => {
return Err(__ParseError::UnrecognizedToken {
token: __lookahead,
expected: vec![],
});
}
}
}
}
pub use self::__parse__Term::parse_Term;
mod __intern_token {
extern crate lalrpop_util as __lalrpop_util;
use self::__lalrpop_util::ParseError as __ParseError;
pub struct __Matcher<'input> {
text: &'input str,
consumed: usize,
}
fn __tokenize(text: &str) -> Option<(usize, usize)> {
let mut __chars = text.char_indices();
let mut __current_match: Option<(usize, usize)> = None;
let mut __current_state: usize = 0;
loop {
match __current_state {
0 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
'(' => {
__current_match = Some((1, __index + 1));
__current_state = 2;
continue;
}
')' => {
__current_match = Some((0, __index + 1));
__current_state = 3;
continue;
}
'0' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'1' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'2' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'3' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'4' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'5' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'6' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'7' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'8' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'9' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
_ => {
return __current_match;
}
}
}
1 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
'0' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'1' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'2' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'3' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'4' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'5' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'6' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'7' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'8' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
'9' => {
__current_match = Some((2, __index + 1));
__current_state = 1;
continue;
}
_ => {
return __current_match;
}
}
}
2 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
_ => {
return __current_match;
}
}
}
3 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
_ => {
return __current_match;
}
}
}
4 => {
let (__index, __ch) = match __chars.next() { Some(p) => p, None => return __current_match };
match __ch {
_ => {
return __current_match;
}
}
}
_ => { panic!("invalid state {}", __current_state); }
}
}
}
impl<'input> __Matcher<'input> {
pub fn new(s: &'input str) -> __Matcher<'input> {
__Matcher { text: s, consumed: 0 }
}
}
impl<'input> Iterator for __Matcher<'input> {
type Item = Result<(usize, (usize, &'input str), usize), __ParseError<usize,(usize, &'input str),()>>;
fn next(&mut self) -> Option<Self::Item> {
let __text = self.text.trim_left();
let __whitespace = self.text.len() - __text.len();
let __start_offset = self.consumed + __whitespace;
if __text.is_empty() {
self.text = __text;
self.consumed = __start_offset;
None
} else {
match __tokenize(__text) {
Some((__index, __length)) => {
let __result = &__text[..__length];
let __remaining = &__text[__length..];
let __end_offset = __start_offset + __length;
self.text = __remaining;
self.consumed = __end_offset;
Some(Ok((__start_offset, (__index, __result), __end_offset)))
}
None => {
Some(Err(__ParseError::InvalidToken { location: __start_offset }))
}
}
}
}
}
}
pub fn __action0<
'input,
>(
input: &'input str,
__0: i32,
) -> i32
{
(__0)
}
pub fn __action1<
'input,
>(
input: &'input str,
__0: i32,
) -> i32
{
(__0)
}
pub fn __action2<
'input,
>(
input: &'input str,
_: &'input str,
__0: i32,
_: &'input str,
) -> i32
{
(__0)
}
pub fn __action3<
'input,
>(
input: &'input str,
__0: &'input str,
) -> i32
{
i32::from_str(__0).unwrap()
}
pub trait __ToTriple<'input, > {
type Error;
fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),Self::Error>;
}
impl<'input, > __ToTriple<'input, > for (usize, (usize, &'input str), usize) {
type Error = ();
fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),()> {
Ok(value)
}
}
impl<'input, > __ToTriple<'input, > for Result<(usize, (usize, &'input str), usize),()> {
type Error = ();
fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),()> {
value
}
}

View File

@ -1,799 +0,0 @@
use std::str::FromStr;
extern crate lalrpop_util as __lalrpop_util;
mod __parse__Expr {
#![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports)]
use std::str::FromStr;
extern crate lalrpop_util as __lalrpop_util;
#[allow(dead_code)]
pub enum __Symbol<'input> {
Term_22_28_22(&'input str),
Term_22_29_22(&'input str),
Term_22_2a_22(&'input str),
Term_22_2b_22(&'input str),
Term_22_2d_22(&'input str),
Term_22_2f_22(&'input str),
Termr_23_22_5b0_2d9_5d_2b_22_23(&'input str),
Termerror(__lalrpop_util::ErrorRecovery<usize, (usize, &'input str), ()>),
NtExpr(i32),
NtFactor(i32),
NtNum(i32),
NtTerm(i32),
Nt____Expr(i32),
}
const __ACTION: &'static [i32] = &[
// State 0
6, 0, 0, 0, 0, 0, 7, 0,
// State 1
0, 0, 0, 8, 9, 0, 0, 0,
// State 2
0, 0, 10, -3, -3, 11, 0, 0,
// State 3
0, 0, -8, -8, -8, -8, 0, 0,
// State 4
0, 0, -6, -6, -6, -6, 0, 0,
// State 5
16, 0, 0, 0, 0, 0, 17, 0,
// State 6
0, 0, -7, -7, -7, -7, 0, 0,
// State 7
6, 0, 0, 0, 0, 0, 7, 0,
// State 8
6, 0, 0, 0, 0, 0, 7, 0,
// State 9
6, 0, 0, 0, 0, 0, 7, 0,
// State 10
6, 0, 0, 0, 0, 0, 7, 0,
// State 11
0, 22, 0, 23, 24, 0, 0, 0,
// State 12
0, -3, 25, -3, -3, 26, 0, 0,
// State 13
0, -8, -8, -8, -8, -8, 0, 0,
// State 14
0, -6, -6, -6, -6, -6, 0, 0,
// State 15
16, 0, 0, 0, 0, 0, 17, 0,
// State 16
0, -7, -7, -7, -7, -7, 0, 0,
// State 17
0, 0, 10, -1, -1, 11, 0, 0,
// State 18
0, 0, 10, -2, -2, 11, 0, 0,
// State 19
0, 0, -4, -4, -4, -4, 0, 0,
// State 20
0, 0, -5, -5, -5, -5, 0, 0,
// State 21
0, 0, -9, -9, -9, -9, 0, 0,
// State 22
16, 0, 0, 0, 0, 0, 17, 0,
// State 23
16, 0, 0, 0, 0, 0, 17, 0,
// State 24
16, 0, 0, 0, 0, 0, 17, 0,
// State 25
16, 0, 0, 0, 0, 0, 17, 0,
// State 26
0, 32, 0, 23, 24, 0, 0, 0,
// State 27
0, -1, 25, -1, -1, 26, 0, 0,
// State 28
0, -2, 25, -2, -2, 26, 0, 0,
// State 29
0, -4, -4, -4, -4, -4, 0, 0,
// State 30
0, -5, -5, -5, -5, -5, 0, 0,
// State 31
0, -9, -9, -9, -9, -9, 0, 0,
];
const __EOF_ACTION: &'static [i32] = &[
0,
-10,
-3,
-8,
-6,
0,
-7,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
-1,
-2,
-4,
-5,
-9,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
];
const __GOTO: &'static [i32] = &[
// State 0
2, 3, 4, 5, 0,
// State 1
0, 0, 0, 0, 0,
// State 2
0, 0, 0, 0, 0,
// State 3
0, 0, 0, 0, 0,
// State 4
0, 0, 0, 0, 0,
// State 5
12, 13, 14, 15, 0,
// State 6
0, 0, 0, 0, 0,
// State 7
0, 18, 4, 5, 0,
// State 8
0, 19, 4, 5, 0,
// State 9
0, 0, 4, 20, 0,
// State 10
0, 0, 4, 21, 0,
// State 11
0, 0, 0, 0, 0,
// State 12
0, 0, 0, 0, 0,
// State 13
0, 0, 0, 0, 0,
// State 14
0, 0, 0, 0, 0,
// State 15
27, 13, 14, 15, 0,
// State 16
0, 0, 0, 0, 0,
// State 17
0, 0, 0, 0, 0,
// State 18
0, 0, 0, 0, 0,
// State 19
0, 0, 0, 0, 0,
// State 20
0, 0, 0, 0, 0,
// State 21
0, 0, 0, 0, 0,
// State 22
0, 28, 14, 15, 0,
// State 23
0, 29, 14, 15, 0,
// State 24
0, 0, 14, 30, 0,
// State 25
0, 0, 14, 31, 0,
// State 26
0, 0, 0, 0, 0,
// State 27
0, 0, 0, 0, 0,
// State 28
0, 0, 0, 0, 0,
// State 29
0, 0, 0, 0, 0,
// State 30
0, 0, 0, 0, 0,
// State 31
0, 0, 0, 0, 0,
];
fn __expected_tokens(__state: usize) -> Vec<::std::string::String> {
const __TERMINAL: &'static [&'static str] = &[
r###""(""###,
r###"")""###,
r###""*""###,
r###""+""###,
r###""-""###,
r###""/""###,
r###"r#"[0-9]+"#"###,
];
__ACTION[(__state * 8)..].iter().zip(__TERMINAL).filter_map(|(&state, terminal)| {
if state == 0 {
None
} else {
Some(terminal.to_string())
}
}).collect()
}
pub fn parse_Expr<
'input,
>(
input: &'input str,
) -> Result<i32, __lalrpop_util::ParseError<usize, (usize, &'input str), ()>>
{
let mut __tokens = super::__intern_token::__Matcher::new(input);
let mut __states = vec![0_i32];
let mut __symbols = vec![];
let mut __integer;
let mut __lookahead;
let mut __last_location = Default::default();
'__shift: loop {
__lookahead = match __tokens.next() {
Some(Ok(v)) => v,
None => break '__shift,
Some(Err(e)) => return Err(e),
};
__last_location = __lookahead.2.clone();
__integer = match __lookahead.1 {
(1, _) if true => 0,
(2, _) if true => 1,
(3, _) if true => 2,
(4, _) if true => 3,
(5, _) if true => 4,
(6, _) if true => 5,
(0, _) if true => 6,
_ => {
let __state = *__states.last().unwrap() as usize;
let __error = __lalrpop_util::ParseError::UnrecognizedToken {
token: Some(__lookahead),
expected: __expected_tokens(__state),
};
return Err(__error);
}
};
'__inner: loop {
let __state = *__states.last().unwrap() as usize;
let __action = __ACTION[__state * 8 + __integer];
if __action > 0 {
let __symbol = match __integer {
0 => match __lookahead.1 {
(1, __tok0) => __Symbol::Term_22_28_22(__tok0),
_ => unreachable!(),
},
1 => match __lookahead.1 {
(2, __tok0) => __Symbol::Term_22_29_22(__tok0),
_ => unreachable!(),
},
2 => match __lookahead.1 {
(3, __tok0) => __Symbol::Term_22_2a_22(__tok0),
_ => unreachable!(),
},
3 => match __lookahead.1 {
(4, __tok0) => __Symbol::Term_22_2b_22(__tok0),
_ => unreachable!(),
},
4 => match __lookahead.1 {
(5, __tok0) => __Symbol::Term_22_2d_22(__tok0),
_ => unreachable!(),
},
5 => match __lookahead.1 {
(6, __tok0) => __Symbol::Term_22_2f_22(__tok0),
_ => unreachable!(),
},
6 => match __lookahead.1 {
(0, __tok0) => __Symbol::Termr_23_22_5b0_2d9_5d_2b_22_23(__tok0),
_ => unreachable!(),
},
_ => unreachable!(),
};
__states.push(__action - 1);
__symbols.push((__lookahead.0, __symbol, __lookahead.2));
continue '__shift;
} else if __action < 0 {
if let Some(r) = __reduce(input, __action, Some(&__lookahead.0), &mut __states, &mut __symbols, ::std::marker::PhantomData::<()>) {
return r;
}
} else {
let __state = *__states.last().unwrap() as usize;
let __error = __lalrpop_util::ParseError::UnrecognizedToken {
token: Some(__lookahead),
expected: __expected_tokens(__state),
};
return Err(__error)
}
}
}
loop {
let __state = *__states.last().unwrap() as usize;
let __action = __EOF_ACTION[__state];
if __action < 0 {
if let Some(r) = __reduce(input, __action, None, &mut __states, &mut __symbols, ::std::marker::PhantomData::<()>) {
return r;
}
} else {
let __state = *__states.last().unwrap() as usize;
let __error = __lalrpop_util::ParseError::UnrecognizedToken {
token: None,
expected: __expected_tokens(__state),
};
return Err(__error);
}
}
}
pub fn __reduce<
'input,
>(
input: &'input str,
__action: i32,
__lookahead_start: Option<&usize>,
__states: &mut ::std::vec::Vec<i32>,
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>,
_: ::std::marker::PhantomData<()>,
) -> Option<Result<i32,__lalrpop_util::ParseError<usize, (usize, &'input str), ()>>>
{
let __nonterminal = match -__action {
1 => {
// Expr = Expr, "+", Factor => ActionFn(1);
let __sym2 = __pop_NtFactor(__symbols);
let __sym1 = __pop_Term_22_2b_22(__symbols);
let __sym0 = __pop_NtExpr(__symbols);
let __start = __sym0.0.clone();
let __end = __sym2.2.clone();
let __nt = super::__action1::<>(input, __sym0, __sym1, __sym2);
let __states_len = __states.len();
__states.truncate(__states_len - 3);
__symbols.push((__start, __Symbol::NtExpr(__nt), __end));
0
}
2 => {
// Expr = Expr, "-", Factor => ActionFn(2);
let __sym2 = __pop_NtFactor(__symbols);
let __sym1 = __pop_Term_22_2d_22(__symbols);
let __sym0 = __pop_NtExpr(__symbols);
let __start = __sym0.0.clone();
let __end = __sym2.2.clone();
let __nt = super::__action2::<>(input, __sym0, __sym1, __sym2);
let __states_len = __states.len();
__states.truncate(__states_len - 3);
__symbols.push((__start, __Symbol::NtExpr(__nt), __end));
0
}
3 => {
// Expr = Factor => ActionFn(3);
let __sym0 = __pop_NtFactor(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action3::<>(input, __sym0);
let __states_len = __states.len();
__states.truncate(__states_len - 1);
__symbols.push((__start, __Symbol::NtExpr(__nt), __end));
0
}
4 => {
// Factor = Factor, "*", Term => ActionFn(4);
let __sym2 = __pop_NtTerm(__symbols);
let __sym1 = __pop_Term_22_2a_22(__symbols);
let __sym0 = __pop_NtFactor(__symbols);
let __start = __sym0.0.clone();
let __end = __sym2.2.clone();
let __nt = super::__action4::<>(input, __sym0, __sym1, __sym2);
let __states_len = __states.len();
__states.truncate(__states_len - 3);
__symbols.push((__start, __Symbol::NtFactor(__nt), __end));
1
}
5 => {
// Factor = Factor, "/", Term => ActionFn(5);
let __sym2 = __pop_NtTerm(__symbols);
let __sym1 = __pop_Term_22_2f_22(__symbols);
let __sym0 = __pop_NtFactor(__symbols);
let __start = __sym0.0.clone();
let __end = __sym2.2.clone();
let __nt = super::__action5::<>(input, __sym0, __sym1, __sym2);
let __states_len = __states.len();
__states.truncate(__states_len - 3);
__symbols.push((__start, __Symbol::NtFactor(__nt), __end));
1
}
6 => {
// Factor = Term => ActionFn(6);
let __sym0 = __pop_NtTerm(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action6::<>(input, __sym0);
let __states_len = __states.len();
__states.truncate(__states_len - 1);
__symbols.push((__start, __Symbol::NtFactor(__nt), __end));
1
}
7 => {
// Num = r#"[0-9]+"# => ActionFn(9);
let __sym0 = __pop_Termr_23_22_5b0_2d9_5d_2b_22_23(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action9::<>(input, __sym0);
let __states_len = __states.len();
__states.truncate(__states_len - 1);
__symbols.push((__start, __Symbol::NtNum(__nt), __end));
2
}
8 => {
// Term = Num => ActionFn(7);
let __sym0 = __pop_NtNum(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action7::<>(input, __sym0);
let __states_len = __states.len();
__states.truncate(__states_len - 1);
__symbols.push((__start, __Symbol::NtTerm(__nt), __end));
3
}
9 => {
// Term = "(", Expr, ")" => ActionFn(8);
let __sym2 = __pop_Term_22_29_22(__symbols);
let __sym1 = __pop_NtExpr(__symbols);
let __sym0 = __pop_Term_22_28_22(__symbols);
let __start = __sym0.0.clone();
let __end = __sym2.2.clone();
let __nt = super::__action8::<>(input, __sym0, __sym1, __sym2);
let __states_len = __states.len();
__states.truncate(__states_len - 3);
__symbols.push((__start, __Symbol::NtTerm(__nt), __end));
3
}
10 => {
// __Expr = Expr => ActionFn(0);
let __sym0 = __pop_NtExpr(__symbols);
let __start = __sym0.0.clone();
let __end = __sym0.2.clone();
let __nt = super::__action0::<>(input, __sym0);
return Some(Ok(__nt));
}
_ => panic!("invalid action code {}", __action)
};
let __state = *__states.last().unwrap() as usize;
let __next_state = __GOTO[__state * 5 + __nonterminal] - 1;
__states.push(__next_state);
None
}
fn __pop_Term_22_28_22<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, &'input str, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::Term_22_28_22(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_Term_22_29_22<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, &'input str, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::Term_22_29_22(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_Term_22_2a_22<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, &'input str, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::Term_22_2a_22(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_Term_22_2b_22<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, &'input str, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::Term_22_2b_22(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_Term_22_2d_22<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, &'input str, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::Term_22_2d_22(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_Term_22_2f_22<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, &'input str, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::Term_22_2f_22(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_Termr_23_22_5b0_2d9_5d_2b_22_23<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, &'input str, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::Termr_23_22_5b0_2d9_5d_2b_22_23(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_Termerror<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, __lalrpop_util::ErrorRecovery<usize, (usize, &'input str), ()>, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::Termerror(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_NtExpr<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, i32, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::NtExpr(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_NtFactor<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, i32, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::NtFactor(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_NtNum<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, i32, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::NtNum(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_NtTerm<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, i32, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::NtTerm(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
fn __pop_Nt____Expr<
'input,
>(
__symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
) -> (usize, i32, usize) {
match __symbols.pop().unwrap() {
(__l, __Symbol::Nt____Expr(__v), __r) => (__l, __v, __r),
_ => panic!("symbol type mismatch")
}
}
}
pub use self::__parse__Expr::parse_Expr;
mod __intern_token {
extern crate lalrpop_util as __lalrpop_util;
extern crate regex as __regex;
pub struct __Matcher<'input> {
text: &'input str,
consumed: usize,
regex_set: __regex::RegexSet,
regex_vec: Vec<__regex::Regex>,
}
impl<'input> __Matcher<'input> {
pub fn new(s: &'input str) -> __Matcher<'input> {
let __regex_set = __regex::RegexSet::new(&[
"^[0-9]+",
"^\\(",
"^\\)",
"^\\*",
"^\\+",
"^-",
"^/",
]).unwrap();
let __regex_vec = vec![
__regex::Regex::new("^[0-9]+").unwrap(),
__regex::Regex::new("^\\(").unwrap(),
__regex::Regex::new("^\\)").unwrap(),
__regex::Regex::new("^\\*").unwrap(),
__regex::Regex::new("^\\+").unwrap(),
__regex::Regex::new("^-").unwrap(),
__regex::Regex::new("^/").unwrap(),
];
__Matcher {
text: s,
consumed: 0,
regex_set: __regex_set,
regex_vec: __regex_vec,
}
}
}
impl<'input> Iterator for __Matcher<'input> {
type Item = Result<(usize, (usize, &'input str), usize), __lalrpop_util::ParseError<usize,(usize, &'input str),()>>;
fn next(&mut self) -> Option<Self::Item> {
let __text = self.text.trim_left();
let __whitespace = self.text.len() - __text.len();
let __start_offset = self.consumed + __whitespace;
if __text.is_empty() {
self.text = __text;
self.consumed = __start_offset;
None
} else {
let __matches = self.regex_set.matches(__text);
if !__matches.matched_any() {
Some(Err(__lalrpop_util::ParseError::InvalidToken {
location: __start_offset,
}))
} else {
let mut __longest_match = 0;
let mut __index = 0;
for __i in 0 .. 7 {
if __matches.matched(__i) {
let __match = self.regex_vec[__i].find(__text).unwrap();
let __len = __match.end();
if __len >= __longest_match {
__longest_match = __len;
__index = __i;
}
}
}
let __result = &__text[..__longest_match];
let __remaining = &__text[__longest_match..];
let __end_offset = __start_offset + __longest_match;
self.text = __remaining;
self.consumed = __end_offset;
Some(Ok((__start_offset, (__index, __result), __end_offset)))
}
}
}
}
}
#[allow(unused_variables)]
pub fn __action0<
'input,
>(
input: &'input str,
(_, __0, _): (usize, i32, usize),
) -> i32
{
(__0)
}
#[allow(unused_variables)]
pub fn __action1<
'input,
>(
input: &'input str,
(_, l, _): (usize, i32, usize),
(_, _, _): (usize, &'input str, usize),
(_, r, _): (usize, i32, usize),
) -> i32
{
l + r
}
#[allow(unused_variables)]
pub fn __action2<
'input,
>(
input: &'input str,
(_, l, _): (usize, i32, usize),
(_, _, _): (usize, &'input str, usize),
(_, r, _): (usize, i32, usize),
) -> i32
{
l - r
}
#[allow(unused_variables)]
pub fn __action3<
'input,
>(
input: &'input str,
(_, __0, _): (usize, i32, usize),
) -> i32
{
(__0)
}
#[allow(unused_variables)]
pub fn __action4<
'input,
>(
input: &'input str,
(_, l, _): (usize, i32, usize),
(_, _, _): (usize, &'input str, usize),
(_, r, _): (usize, i32, usize),
) -> i32
{
l * r
}
#[allow(unused_variables)]
pub fn __action5<
'input,
>(
input: &'input str,
(_, l, _): (usize, i32, usize),
(_, _, _): (usize, &'input str, usize),
(_, r, _): (usize, i32, usize),
) -> i32
{
l / r
}
#[allow(unused_variables)]
pub fn __action6<
'input,
>(
input: &'input str,
(_, __0, _): (usize, i32, usize),
) -> i32
{
(__0)
}
#[allow(unused_variables)]
pub fn __action7<
'input,
>(
input: &'input str,
(_, __0, _): (usize, i32, usize),
) -> i32
{
(__0)
}
#[allow(unused_variables)]
pub fn __action8<
'input,
>(
input: &'input str,
(_, _, _): (usize, &'input str, usize),
(_, __0, _): (usize, i32, usize),
(_, _, _): (usize, &'input str, usize),
) -> i32
{
(__0)
}
#[allow(unused_variables)]
pub fn __action9<
'input,
>(
input: &'input str,
(_, __0, _): (usize, &'input str, usize),
) -> i32
{
i32::from_str(__0).unwrap()
}
pub trait __ToTriple<'input, > {
type Error;
fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),Self::Error>;
}
impl<'input, > __ToTriple<'input, > for (usize, (usize, &'input str), usize) {
type Error = ();
fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),()> {
Ok(value)
}
}
impl<'input, > __ToTriple<'input, > for Result<(usize, (usize, &'input str), usize),()> {
type Error = ();
fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),()> {
value
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff