Skip to content

Commit 139b276

Browse files
authored
Slight refactor to PathSteps in grammar (#406)
1 parent 0f49d1b commit 139b276

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

partiql-parser/src/parse/partiql.lalrpop

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,42 +1098,27 @@ FunctionArgName: ast::SymbolPrimitive = {
10981098
//
10991099
// See the path expression conformance tests under `partiql-tests` or parser unit-tests for more examples.
11001100
PathSteps: Vec<ast::PathStep> = {
1101-
<path:PathSteps> "." <v:PathExprVarRef> => {
1102-
let mut steps = path;
1103-
steps.push(ast::PathStep::PathExpr( ast::PathExpr{ index: Box::new(v) }));
1104-
steps
1105-
},
1106-
<lo:@L> <path:PathSteps> "[" "*" "]" <hi:@R> => {
1107-
let mut steps = path;
1108-
steps.push(ast::PathStep::PathWildCard);
1109-
steps
1110-
},
1111-
<lo:@L> <path:PathSteps> "." "*" <hi:@R> => {
1112-
let mut steps = path;
1113-
steps.push(ast::PathStep::PathUnpivot);
1114-
steps
1115-
},
1116-
<lo:@L> <path:PathSteps> "[" <expr:ExprQuery> "]" <hi:@R> => {
1117-
let step = ast::PathStep::PathExpr(
1118-
ast::PathExpr{
1119-
index: Box::new(*expr),
1120-
});
1121-
1101+
<path:PathSteps> <step:PathStep> => {
11221102
let mut steps = path;
11231103
steps.push(step);
11241104
steps
11251105
},
1106+
<step:PathStep> => {
1107+
vec![step]
1108+
},
1109+
}
1110+
PathStep: ast::PathStep = {
11261111
"." <v:PathExprVarRef> => {
1127-
vec![ast::PathStep::PathExpr( ast::PathExpr{ index: Box::new(v) })]
1112+
ast::PathStep::PathExpr( ast::PathExpr{ index: Box::new(v) })
11281113
},
11291114
"[" "*" "]" => {
1130-
vec![ast::PathStep::PathWildCard]
1115+
ast::PathStep::PathWildCard
11311116
},
11321117
"." "*" => {
1133-
vec![ast::PathStep::PathUnpivot]
1118+
ast::PathStep::PathUnpivot
11341119
},
11351120
"[" <expr:ExprQuery> "]" => {
1136-
vec![ast::PathStep::PathExpr( ast::PathExpr{ index: Box::new(*expr) })]
1121+
ast::PathStep::PathExpr( ast::PathExpr{ index: Box::new(*expr) })
11371122
},
11381123
}
11391124

0 commit comments

Comments
 (0)