Skip to content

Commit

Permalink
Merge pull request #5058 from andylokandy/semicolon
Browse files Browse the repository at this point in the history
fix(parser): allow to omit semicolon
  • Loading branch information
BohuTANG authored Apr 26, 2022
2 parents c893a54 + 2bb63cb commit 62063a2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions common/ast/src/parser/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ use crate::parser::util::*;
use crate::rule;

pub fn statements(i: Input) -> IResult<Vec<Statement>> {
let stmt = map(
map(
rule! {
#statement ~ ";"
#statement ~ ";"? ~ &EOI
},
|(stmt, _)| stmt,
);
rule!(
#stmt+
|(stmt, _, _)| vec![stmt],
)(i)
}

Expand Down
2 changes: 1 addition & 1 deletion common/ast/tests/it/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn test_statement() {
let mut mint = Mint::new("tests/it/testdata");
let mut file = mint.new_goldenfile("statement.txt").unwrap();
let cases = &[
r#"show tables;"#,
r#"show tables"#,
r#"show processlist;"#,
r#"show create table a.b;"#,
r#"explain analyze select a from b;"#,
Expand Down
2 changes: 1 addition & 1 deletion common/ast/tests/it/testdata/statement.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---------- Input ----------
show tables;
show tables
---------- Output ---------
SHOW TABLES
---------- AST ------------
Expand Down

0 comments on commit 62063a2

Please sign in to comment.