Skip to content

Commit

Permalink
Do not expose enum_body node
Browse files Browse the repository at this point in the history
Closes #15.
  • Loading branch information
bbannier committed Mar 30, 2023
1 parent b588f9a commit 94c6b62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions corpus/test
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ redef record X += {
};

type E: enum { eA, eB };
redef enum E += { eC };
redef enum E += { eC = 3 };

function foo()
{
Expand Down Expand Up @@ -72,16 +72,16 @@ function foo()
(type_decl
(id)
(type
(enum_body
(enum_body_elem
(id))
(enum_body_elem
(id)))))
(enumerator
(id))
(enumerator
(id))))
(redef_enum_decl
(id)
(enum_body
(enum_body_elem
(id))))
(enumerator
(id)
(constant
(integer))))
(func_decl
(func_hdr
(func
Expand Down
8 changes: 4 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = grammar({
const_decl: $ => seq('const', $.id, optional(seq(':', $.type)), optional($.initializer), optional($.attr_list), ';'),
redef_decl: $ => seq('redef', $.id, optional(seq(':', $.type)), optional($.initializer), optional($.attr_list), ';'),

redef_enum_decl: $ => seq('redef', 'enum', $.id, '+=', '{', $.enum_body, '}', ';'),
redef_enum_decl: $ => seq('redef', 'enum', $.id, '+=', '{', $._enum_body, '}', ';'),
redef_record_decl: $ => seq('redef', 'record', $.id, '+=', '{', repeat($.type_spec), '}', optional($.attr_list), ';'),
type_decl: $ => seq('type', $.id, ':', $.type, optional($.attr_list), ';'),
func_decl: $ => seq($.func_hdr, repeat($.preproc_directive), $.func_body),
Expand Down Expand Up @@ -122,7 +122,7 @@ module.exports = grammar({
'timer',
seq('record', '{', repeat($.type_spec), '}'),
seq('union', '{', list1($.type, ','), '}'),
seq('enum', '{', $.enum_body, '}'),
seq('enum', '{', $._enum_body, '}'),
'list',
seq('list', 'of', $.type),
seq('vector', 'of', $.type),
Expand All @@ -135,9 +135,9 @@ module.exports = grammar({
$.id,
),

enum_body: $ => list1($.enum_body_elem, ',', true),
_enum_body: $ => list1($.enumerator, ',', true),

enum_body_elem: $ => choice(
enumerator: $ => choice(
seq($.id, '=', $.constant, optional($.deprecated)),
seq($.id, optional($.deprecated)),
),
Expand Down

0 comments on commit 94c6b62

Please sign in to comment.