Support optional semicolon between statements (#1937)
Some checks failed
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled

This commit is contained in:
Yoav Cohen 2025-07-11 14:46:48 +02:00 committed by GitHub
parent ee31b64f9e
commit bc2c4e263d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 59 additions and 3 deletions

View file

@ -222,6 +222,9 @@ pub struct ParserOptions {
/// Controls how literal values are unescaped. See
/// [`Tokenizer::with_unescape`] for more details.
pub unescape: bool,
/// Controls if the parser expects a semi-colon token
/// between statements. Default is `true`.
pub require_semicolon_stmt_delimiter: bool,
}
impl Default for ParserOptions {
@ -229,6 +232,7 @@ impl Default for ParserOptions {
Self {
trailing_commas: false,
unescape: true,
require_semicolon_stmt_delimiter: true,
}
}
}
@ -467,6 +471,10 @@ impl<'a> Parser<'a> {
expecting_statement_delimiter = false;
}
if !self.options.require_semicolon_stmt_delimiter {
expecting_statement_delimiter = false;
}
match self.peek_token().token {
Token::EOF => break,

View file

@ -294,6 +294,11 @@ pub fn all_dialects() -> TestedDialects {
])
}
// Returns all available dialects with the specified parser options
pub fn all_dialects_with_options(options: ParserOptions) -> TestedDialects {
TestedDialects::new_with_options(all_dialects().dialects, options)
}
/// Returns all dialects matching the given predicate.
pub fn all_dialects_where<F>(predicate: F) -> TestedDialects
where