Skip to content

Commit

Permalink
fix #192
Browse files Browse the repository at this point in the history
  • Loading branch information
kitta65 committed Apr 26, 2023
1 parent 764d7b0 commit 6db8aaf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,13 @@ impl Parser {
let type_ = self.parse_type(false)?;
self.next_token()?; // > -> [
let mut arr = self.construct_node(NodeType::ArrayLiteral)?;
self.next_token()?; // [ -> exprs
arr.push_node_vec("exprs", self.parse_exprs(&vec![], false)?);
self.next_token()?; // exprs -> ]
self.next_token()?; // [ -> exprs | ]
if self.get_token(0)?.is("]") {
arr.push_node_vec("exprs", vec![]);
} else {
arr.push_node_vec("exprs", self.parse_exprs(&vec![], false)?);
self.next_token()?; // exprs -> ]
}
arr.push_node("rparen", self.construct_node(NodeType::Symbol)?);
arr.push_node("type", type_);
left = arr;
Expand Down
22 changes: 22 additions & 0 deletions src/parser/tests/tests_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,28 @@ exprs:
// array with type declaration
Box::new(SuccessTestCase::new(
"\
SELECT ARRAY<STRING>[]
",
"\
self: SELECT (SelectStatement)
exprs:
- self: [ (ArrayLiteral)
exprs: []
rparen:
self: ] (Symbol)
type:
self: ARRAY (Type)
type_declaration:
self: < (GroupedType)
rparen:
self: > (Symbol)
type:
self: STRING (Type)
",
0,
)),
Box::new(SuccessTestCase::new(
"\
SELECT ARRAY<INT64>[1]
",
"\
Expand Down

0 comments on commit 6db8aaf

Please sign in to comment.