Skip to content

Commit 4b55b31

Browse files
committed
[lib,parser/earley] Back to stable, baby!
1 parent 356ebeb commit 4b55b31

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
unstable_name_collisions
44
)]
55
#![warn(missing_debug_implementations)]
6-
#![feature(box_patterns, try_blocks)]
76

87
//! # Beans
98
//!

src/parser/earley.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,40 +1240,40 @@ impl EarleyParser {
12401240
let allowed = Allowed::Some(possible_scans.clone());
12411241
let next_token = match input.next(allowed) {
12421242
Ok(r) => r,
1243-
Err(Error {
1244-
kind: box ErrorKind::LexingError { .. },
1245-
}) => {
1246-
let error = if let Some(token) = input.next(Allowed::All)? {
1247-
let span = token.span().clone();
1248-
let name = {
1249-
let id = token.id();
1250-
let name = token.name().to_string();
1251-
if let Some(description) =
1252-
input.lexer().grammar().description_of(id)
1253-
{
1254-
description.to_string()
1255-
} else {
1256-
name
1243+
Err(error) => {
1244+
if let ErrorKind::LexingError { .. } = *error.kind {
1245+
let error = if let Some(token) = input.next(Allowed::All)? {
1246+
let span = token.span().clone();
1247+
let name = {
1248+
let id = token.id();
1249+
let name = token.name().to_string();
1250+
if let Some(description) =
1251+
input.lexer().grammar().description_of(id)
1252+
{
1253+
description.to_string()
1254+
} else {
1255+
name
1256+
}
1257+
};
1258+
ErrorKind::SyntaxError {
1259+
name,
1260+
alternatives: possible_first_nonterminals
1261+
.drain()
1262+
.map(|x| x.to_string())
1263+
.chain(possible_first_terminals.drain())
1264+
.collect(),
1265+
span: Fragile::new(span),
1266+
}
1267+
} else {
1268+
ErrorKind::SyntaxErrorValidPrefix {
1269+
span: input.last_span().into(),
12571270
}
12581271
};
1259-
ErrorKind::SyntaxError {
1260-
name,
1261-
alternatives: possible_first_nonterminals
1262-
.drain()
1263-
.map(|x| x.to_string())
1264-
.chain(possible_first_terminals.drain())
1265-
.collect(),
1266-
span: Fragile::new(span),
1267-
}
1272+
return error.err();
12681273
} else {
1269-
ErrorKind::SyntaxErrorValidPrefix {
1270-
span: input.last_span().into(),
1271-
}
1272-
};
1273-
return error.err();
1274+
return Err(error);
1275+
}
12741276
}
1275-
// Reallocation is necessary, because the type differs
1276-
Err(error) => return Err(error),
12771277
};
12781278
possible_first_nonterminals.clear();
12791279
possible_first_terminals.clear();

0 commit comments

Comments
 (0)