Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit 0d7f29d

Browse files
committed
Normalizing CASE expression nodes. Refs #36
- `variant` `when` has a `condition` and a `consequent` - `variant` `else` has just a `consequent` - the outer `expression` is now `variant` `case` instead of `binary` - instead of taking whatever is provided between `CASE` and `WHEN` (e.g., `CASE foo WHEN ...`) and calling that the expression, it is now added as `discriminant`
1 parent 17218de commit 0d7f29d

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/grammar.pegjs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -594,34 +594,33 @@ expression_case "CASE Expression"
594594
{
595595
return Object.assign({
596596
'type': 'expression',
597-
'format': 'binary',
598597
'variant': keyNode(t),
599-
'condition': flattenAll([ w, s ])
598+
'expression': flattenAll([ w, s ])
600599
}, e);
601600
}
602601
case_expression
603602
= !WHEN e:( expression ) {
604603
return {
605-
'expression': e
604+
'discriminant': e
606605
};
607606
}
608607
expression_case_when "WHEN Clause"
609608
= s:( WHEN ) o w:( expression ) o THEN o t:( expression ) o
610609
{
611610
return {
612611
'type': 'condition',
613-
'format': keyNode(s),
614-
'when': w,
615-
'then': t
612+
'variant': keyNode(s),
613+
'condition': w,
614+
'consequent': t
616615
};
617616
}
618617
expression_case_else "ELSE Clause"
619618
= s:( ELSE ) o e:( expression ) o
620619
{
621620
return {
622621
'type': 'condition',
623-
'format': keyNode(s),
624-
'else': e
622+
'variant': keyNode(s),
623+
'consequent': e
625624
};
626625
}
627626

src/parser.js

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)