Skip to content

Commit

Permalink
fix: wildcard in a destructor was failing
Browse files Browse the repository at this point in the history
  • Loading branch information
srghma committed Nov 5, 2024
1 parent fabf1b9 commit c56a25c
Show file tree
Hide file tree
Showing 6 changed files with 21,033 additions and 20,951 deletions.
13 changes: 10 additions & 3 deletions grammar/pat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { parens, braces, sep, brackets, snoc_brackets } from './util.js';
import { parens, braces, sep, sep1, brackets, snoc_brackets } from './util.js';

const sepFirstXOtherYs = (sep, firstRule, otherRule) => optional(seq(firstRule, repeat(seq(sep, otherRule))))

export default {

Expand All @@ -7,15 +9,20 @@ export default {
$.ticked_operator,
),

pat_at: $ => '@',
pat_at: _ => '@',

pat_field: $ =>
seq(
$._field_name,
optional(seq(':', $._pat))
),

pat_fields: $ => braces(sep($.comma, $.pat_field)),
// {foo} - ok
// {foo,_} - ok
// {foo,bar,_} - ok
// {_} - error
pat_fields: $ => braces(sepFirstXOtherYs($.comma, $.pat_field, choice($.wildcard, $.pat_field))),
// pat_fields: $ => braces(sep1($.comma, $.pat_field)),

pat_record: $ => field('fields', $.pat_fields),

Expand Down
2 changes: 1 addition & 1 deletion grammar/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const quote = '\''

export const qualified = ($, id) => seq($._qualifying_module, id)

export const sep = (sep, rule) => optional(seq(rule, repeat(seq(sep, rule))))
export const sep = (sep, rule) => optional(sep1(sep, rule))

export const sep1 = (sep, rule) => seq(rule, repeat(seq(sep, rule)))

Expand Down
13 changes: 11 additions & 2 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c56a25c

Please sign in to comment.