mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-02 20:27:21 +00:00
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
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:
parent
ee31b64f9e
commit
bc2c4e263d
5 changed files with 59 additions and 3 deletions
|
@ -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,
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue