Skip to content

Commit 28d791b

Browse files
committed
Fix: bounds_list_is_sorted ICE
1 parent df66492 commit 28d791b

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

src/lib.rs

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
//!
33
//! # Example
44
//!
5-
//! ```ignore
6-
//! # //TODO Unignore this once it stops ICEing
5+
//! ```
76
//! # extern crate combine;
87
//! # extern crate combine_language;
9-
//! # use combine::*;
10-
//! # use combine_language::*;
8+
//! # use combine::{alpha_num, letter, satisfy, string, Parser, ParserExt};
9+
//! # use combine_language::{Identifier, LanguageEnv, LanguageDef};
1110
//! # fn main() {
1211
//! let env = LanguageEnv::new(LanguageDef {
1312
//! ident: Identifier {
@@ -16,17 +15,17 @@
1615
//! reserved: ["if", "then", "else", "let", "in", "type"].iter().map(|x| (*x).into()).collect()
1716
//! },
1817
//! op: Identifier {
19-
//! start: satisfy(|c| "+-*/".chars().find(|x| *x == c).is_some()),
20-
//! rest: satisfy(|c| "+-*/".chars().find(|x| *x == c).is_some()),
18+
//! start: satisfy(|c| "+-*/".chars().any(|x| x == c)),
19+
//! rest: satisfy(|c| "+-*/".chars().any(|x| x == c)),
2120
//! reserved: ["+", "-", "*", "/"].iter().map(|x| (*x).into()).collect()
2221
//! },
23-
//! comment_start: "/*",
24-
//! comment_end: "*/",
25-
//! comment_line: "//"
22+
//! comment_start: string("/*").map(|_| ()),
23+
//! comment_end: string("*/").map(|_| ()),
24+
//! comment_line: string("//").map(|_| ())
2625
//! });
2726
//! let id = env.identifier();//An identifier parser
2827
//! let integer = env.integer();//An integer parser
29-
//! let result = (id, integer).parse_state("this /* Skips comments */ 42");
28+
//! let result = (id, integer).parse("this /* Skips comments */ 42");
3029
//! assert_eq!(result, Ok(((String::from("this"), 42), "")));
3130
//! # }
3231
//! ```
@@ -36,11 +35,14 @@ extern crate combine;
3635
use std::cell::RefCell;
3736
use std::marker::PhantomData;
3837
use std::borrow::Cow;
39-
use combine::*;
40-
use combine::primitives as prim;
4138
use combine::char as pc;
4239
use combine::combinator::{Between, NotFollowedBy, Skip, Try, Token};
4340
use combine::primitives::{Consumed, Error, Stream};
41+
use combine::{
42+
any, between, char, digit, optional, many, many1, not_followed_by,
43+
parser, satisfy, skip_many, skip_many1, space, string, try, unexpected,
44+
Parser, ParserExt, ParseError, ParseResult, State
45+
};
4446

4547
///A language parser
4648
pub struct LanguageParser<'a: 'b, 'b, I: 'b, T>
@@ -52,8 +54,9 @@ pub struct LanguageParser<'a: 'b, 'b, I: 'b, T>
5254

5355
impl <'a, 'b, I, O> Parser for LanguageParser<'a, 'b, I, O>
5456
where I: Stream<Item=char> {
55-
type Output = O;
5657
type Input = I;
58+
type Output = O;
59+
5760
fn parse_lazy(&mut self, input: State<I>) -> ParseResult<O, I> {
5861
(self.parser)(self.env, input)
5962
}
@@ -73,8 +76,9 @@ pub struct Lex<'a: 'b, 'b, P>
7376
impl <'a, 'b, P> Parser for Lex<'a, 'b, P>
7477
where P: Parser
7578
, P::Input: Stream<Item=char> + 'b {
76-
type Output = P::Output;
7779
type Input = P::Input;
80+
type Output = P::Output;
81+
7882
fn parse_state(&mut self, input: State<P::Input>) -> ParseResult<P::Output, P::Input> {
7983
self.parser.parse_state(input)
8084
}
@@ -95,8 +99,8 @@ pub struct WhiteSpace<'a: 'b, 'b, I>
9599

96100
impl <'a, 'b, I> Parser for WhiteSpace<'a, 'b, I>
97101
where I: Stream<Item=char> + 'b {
98-
type Output = ();
99102
type Input = I;
103+
type Output = ();
100104
fn parse_state(&mut self, input: State<I>) -> ParseResult<(), I> {
101105
let mut comment_start = self.env.comment_start.borrow_mut();
102106
let mut comment_end = self.env.comment_end.borrow_mut();
@@ -140,8 +144,8 @@ pub struct Reserved<'a: 'b, 'b, I>
140144

141145
impl <'a, 'b, I> Parser for Reserved<'a, 'b, I>
142146
where I: Stream<Item=char> + 'b {
143-
type Output = &'static str;
144147
type Input = I;
148+
type Output = &'static str;
145149
fn parse_state(&mut self, input: State<I>) -> ParseResult<&'static str, I> {
146150
self.parser.parse_state(input)
147151
}
@@ -163,8 +167,8 @@ pub struct BetweenChar<'a: 'b, 'b, P>
163167
impl <'a, 'b, I, P> Parser for BetweenChar<'a, 'b, P>
164168
where I: Stream<Item=char> + 'b
165169
, P: Parser<Input=I> {
166-
type Output = P::Output;
167170
type Input = I;
171+
type Output = P::Output;
168172
fn parse_state(&mut self, input: State<I>) -> ParseResult<P::Output, I> {
169173
self.parser.parse_state(input)
170174
}
@@ -553,7 +557,7 @@ impl <O, P, F, T> Expression<O, P, F>
553557
, F: Fn(P::Output, T, P::Output) -> P::Output {
554558

555559
fn parse_expr(&mut self, min_precedence: i32, mut l: P::Output, mut input: Consumed<State<P::Input>>)
556-
-> prim::ParseResult<P::Output, P::Input> {
560+
-> ParseResult<P::Output, P::Input> {
557561

558562
loop {
559563
let ((op, op_assoc), rest) = tryb!(self.op.parse_lazy(input.clone().into_inner()));
@@ -585,7 +589,8 @@ impl <O, P, F, T> Parser for Expression<O, P, F>
585589
, F: Fn(P::Output, T, P::Output) -> P::Output {
586590
type Input = P::Input;
587591
type Output = P::Output;
588-
fn parse_lazy(&mut self, input: State<Self::Input>) -> prim::ParseResult<Self::Output, Self::Input> {
592+
593+
fn parse_lazy(&mut self, input: State<Self::Input>) -> ParseResult<Self::Output, Self::Input> {
589594
let (l, input) = try!(self.term.parse_lazy(input));
590595
self.parse_expr(0, l, input)
591596
}
@@ -597,12 +602,11 @@ impl <O, P, F, T> Parser for Expression<O, P, F>
597602
///Constructs an expression parser out of a term parser, an operator parser and a function which
598603
///combines a binary expression to new expressions.
599604
///
600-
/// ```ignore
601-
/// //TODO unignore once its stops ICEing
602-
/// # extern crate combine as pc;
603-
/// # extern crate combine_language as pcl;
604-
/// # use pc::*;
605-
/// # use pcl::*;
605+
/// ```
606+
/// # extern crate combine;
607+
/// # extern crate combine_language;
608+
/// # use combine::{letter, many, spaces, string, Parser, ParserExt};
609+
/// # use combine_language::{expression_parser, Assoc, Fixity};
606610
/// use self::Expr::*;
607611
/// #[derive(PartialEq, Debug)]
608612
/// enum Expr {

0 commit comments

Comments
 (0)