Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One-line pattern matching #194

Merged
merged 5 commits into from
Feb 3, 2023

Conversation

aibaars
Copy link
Contributor

@aibaars aibaars commented Nov 17, 2021

This pull request adds the one-line pattern matching syntax (expr in pattern and expr => pattern).

Checklist:

  • All tests pass in CI.
  • There are sufficient tests for the new fix/feature.
  • Grammar rules have not been renamed unless absolutely necessary.
  • The conflicts section hasn't grown too much.
  • The parser size hasn't grown too much (check the value of STATE_COUNT in src/parser.c).

@aibaars aibaars marked this pull request as draft November 17, 2021 20:27
@aibaars aibaars mentioned this pull request Nov 17, 2021
5 tasks
@aibaars aibaars force-pushed the oneline-pattern-matching branch from 2ee19e3 to b2ed421 Compare January 17, 2022 15:08
Unresolved conflict for symbol sequence:

  'case'  _arg  •  'in'  …

Possible interpretations:

  1:  'case'  (_expression  _arg)  •  'in'  …
  2:  'case'  (test_pattern  _arg  •  'in'  _pattern_expr)

Possible resolutions:

  1:  Specify a higher precedence in `test_pattern` than in the other rules.
  2:  Specify a higher precedence in `_expression` than in the other rules.
  3:  Specify a left or right associativity in `_expression`
  4:  Add a conflict for these rules: `_expression`, `test_pattern`
@aibaars aibaars force-pushed the oneline-pattern-matching branch from b2ed421 to 0b56cc0 Compare January 25, 2023 12:20
@aibaars aibaars marked this pull request as ready for review January 25, 2023 12:51
Copy link
Contributor

@hendrikvanantwerpen hendrikvanantwerpen left a comment

Choose a reason for hiding this comment

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

Grammar precedences, right? As discussed, the FIXME test will serve as documentation of the unresolved issue, and approved as-is.

@aibaars aibaars merged commit 206c707 into tree-sitter:master Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants