Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Implement if/unless/elsif/else. #25

Closed
wants to merge 2 commits into from

Conversation

hugopl
Copy link
Contributor

@hugopl hugopl commented Dec 5, 2024

"if modifier", (return foo if bar) not yet implemented.

Rules "inspired" from ruby grammar.

I think that if we finally do the assignment operator and parenthesis it will finally move us from the 0.01% pass from stdlib.

@hugopl
Copy link
Contributor Author

hugopl commented Dec 5, 2024

I did this on top of #24

"if modifier", (return foo if bar) not yet implemented.

Rules "inspired" from ruby grammar.
grammar.js Outdated Show resolved Hide resolved
'unless',
field('condition', $._expression),
choice($._terminator, field('consequence', $.then)),
field('alternative', optional(choice($.else, $.elsif))),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless doesn't have elsif

if: $ => seq(
'if',
field('condition', $._expression),
choice($._terminator, field('consequence', $.then)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to save the then to a field?

Copy link
Member

@nobodywasishere nobodywasishere Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I guess you're using it to store the body of the if, any terminators, and the then; would recommend not putting all 3 of these together in one field if possible

@hugopl
Copy link
Contributor Author

hugopl commented Dec 8, 2024

Closing this since the repo will be archived.

@hugopl hugopl closed this Dec 8, 2024
@hugopl hugopl deleted the if_unless branch December 8, 2024 17:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants