Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit c022a08

Browse files
authored
[#64] Inline if not working without else (#65)
1 parent 8873140 commit c022a08

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ module.exports = grammar({
315315
field('condition', $._simple_expression),
316316
'then',
317317
field('consequence', $._simple_expression),
318-
seq('else', field('alternative', $._simple_expression))
318+
optional(seq('else', field('alternative', $._simple_expression)))
319319
)),
320320
compound_if: $ => prec.right(seq(
321321
'if',

test/corpus/expressions.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ a :=
460460
else if true
461461
1
462462

463-
if false then 1
463+
fn(if false then 1)
464464
if true then 1 else 1
465465

466466
---
@@ -491,10 +491,13 @@ if true then 1 else 1
491491
condition: (boolean)
492492
consequence: (block
493493
(number))))))
494-
(if
495-
condition: (boolean)
496-
consequence: (block
497-
(number)))
494+
(application
495+
abstraction: (identifier)
496+
arguments: (arguments
497+
(argument
498+
value: (if
499+
condition: (boolean)
500+
consequence: (number)))))
498501
(if
499502
condition: (boolean)
500503
consequence: (number)

0 commit comments

Comments
 (0)