Skip to content

Commit

Permalink
Fix doctest + better lex error message
Browse files Browse the repository at this point in the history
  • Loading branch information
AZWN committed Nov 24, 2023
1 parent ac8348f commit 012d1e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scopegraphs-regular-expressions/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,8 @@ impl<'a> Lexer<'a> {
return Ok(Token::End);
}

let lookahead = input.lookahead1();

// Rust performs parenthesis matching: leverage that here.
if lookahead.peek(syn::token::Paren) {
if input.peek(syn::token::Paren) {
let inner;
parenthesized!(inner in input);
return Regex::parse(&inner).map(|re| Token::Regex(Rc::new(re)));
Expand Down Expand Up @@ -241,7 +239,10 @@ impl<'a> Lexer<'a> {
return Ok(Token::And);
}

Err(lookahead.error())
Err(syn::Error::new(
input.span(),
"expected '0', 'e', '~', '*', '+', '?', '|', '&', '(' or label here.",
))
}

/// Peeks the first token in the stream.
Expand Down
1 change: 1 addition & 0 deletions scopegraphs-regular-expressions/src/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl Regex {
/// Examples of this include the `e` itself, any 0-ary repeat `A*`, `e | A`, etc.
///
/// ```
/// # use scopegraphs_regular_expressions::Regex;
/// assert!(Regex::EmptyString.is_nullable())
/// ```
pub fn is_nullable(&self) -> bool {
Expand Down

0 comments on commit 012d1e3

Please sign in to comment.