|
| 1 | +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +// compile-flags: -C codegen-units=8 -O |
| 12 | + |
| 13 | +fn main() { |
| 14 | + nom_sql::selection(b"x "); |
| 15 | +} |
| 16 | + |
| 17 | +pub enum Err<P>{ |
| 18 | + Position(P), |
| 19 | + NodePosition(u32), |
| 20 | +} |
| 21 | + |
| 22 | +pub enum IResult<I,O> { |
| 23 | + Done(I,O), |
| 24 | + Error(Err<I>), |
| 25 | + Incomplete(u32, u64) |
| 26 | +} |
| 27 | + |
| 28 | +pub fn multispace<T: Copy>(input: T) -> ::IResult<i8, i8> { |
| 29 | + ::IResult::Done(0, 0) |
| 30 | +} |
| 31 | + |
| 32 | +mod nom_sql { |
| 33 | + fn where_clause(i: &[u8]) -> ::IResult<&[u8], Option<String>> { |
| 34 | + let X = match ::multispace(i) { |
| 35 | + ::IResult::Done(..) => ::IResult::Done(i, None::<String>), |
| 36 | + _ => ::IResult::Error(::Err::NodePosition(0)), |
| 37 | + }; |
| 38 | + match X { |
| 39 | + ::IResult::Done(_, _) => ::IResult::Done(i, None), |
| 40 | + _ => X |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + pub fn selection(i: &[u8]) { |
| 45 | + let Y = match { |
| 46 | + match { |
| 47 | + where_clause(i) |
| 48 | + } { |
| 49 | + ::IResult::Done(_, o) => ::IResult::Done(i, Some(o)), |
| 50 | + ::IResult::Error(_) => ::IResult::Done(i, None), |
| 51 | + _ => ::IResult::Incomplete(0, 0), |
| 52 | + } |
| 53 | + } { |
| 54 | + ::IResult::Done(z, _) => ::IResult::Done(z, None::<String>), |
| 55 | + _ => return () |
| 56 | + }; |
| 57 | + match Y { |
| 58 | + ::IResult::Done(x, _) => { |
| 59 | + let bytes = b"; "; |
| 60 | + let len = x.len(); |
| 61 | + bytes[len]; |
| 62 | + } |
| 63 | + _ => () |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments