mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-27 16:07:46 +00:00
35: More specific error for leading pipes r=matklad a=ammkrn Re: rust-analyzer/ungrammar#34; return a more detailed error message when counting an improperly placed leading pipe. Co-authored-by: ammkrn <ammkrn@tuta.io>
This commit is contained in:
commit
4457576f49
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "ungrammar"
|
||||
description = "A DSL for describing concrete syntax trees"
|
||||
version = "1.14.0"
|
||||
version = "1.14.1"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/matklad/ungrammar"
|
||||
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
|
||||
|
||||
@ -109,6 +109,14 @@ fn node(p: &mut Parser) -> Result<()> {
|
||||
}
|
||||
|
||||
fn rule(p: &mut Parser) -> Result<Rule> {
|
||||
if let Some(lexer::Token { kind: TokenKind::Pipe, loc }) = p.peek() {
|
||||
bail!(
|
||||
*loc,
|
||||
"The first element in a sequence of productions or alternatives \
|
||||
must not have a leading pipe (`|`)"
|
||||
);
|
||||
}
|
||||
|
||||
let lhs = seq_rule(p)?;
|
||||
let mut alt = vec![lhs];
|
||||
while let Some(token) = p.peek() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user