Skip to content

Commit 29ab704

Browse files
committed
More specific error for leading pipes
1 parent 0ee885c commit 29ab704

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "ungrammar"
33
description = "A DSL for describing concrete syntax trees"
4-
version = "1.14.0"
4+
version = "1.14.1"
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/matklad/ungrammar"
77
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]

src/parser.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ fn node(p: &mut Parser) -> Result<()> {
109109
}
110110

111111
fn rule(p: &mut Parser) -> Result<Rule> {
112+
if let Some(lexer::Token { kind: TokenKind::Pipe, loc }) = p.peek() {
113+
bail!(
114+
*loc,
115+
"The first element in a sequence of productions or alternatives \
116+
must not have a leading pipe (`|`)"
117+
);
118+
}
119+
112120
let lhs = seq_rule(p)?;
113121
let mut alt = vec![lhs];
114122
while let Some(token) = p.peek() {

0 commit comments

Comments
 (0)