Add if expressions
This commit is contained in:
parent
93cd163707
commit
19c1f11414
5 changed files with 1661 additions and 913 deletions
17
grammar.js
17
grammar.js
|
|
@ -47,6 +47,8 @@ module.exports = grammar({
|
|||
$.sequence_expression,
|
||||
|
||||
$.assignment_expression,
|
||||
|
||||
$.if_expression,
|
||||
),
|
||||
|
||||
nil_literal: (_) => "nil",
|
||||
|
|
@ -167,6 +169,21 @@ module.exports = grammar({
|
|||
field("right", $._expr),
|
||||
),
|
||||
),
|
||||
|
||||
if_expression: ($) => prec.right(
|
||||
seq(
|
||||
"if",
|
||||
field("condition", $._expr),
|
||||
"then",
|
||||
field("consequence", $._expr),
|
||||
optional(
|
||||
seq(
|
||||
"else",
|
||||
field("alternative", $._expr),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue