Skip to content

Commit

Permalink
Support bodyless class/struct/record/enum/interface
Browse files Browse the repository at this point in the history
  • Loading branch information
damieng committed Jan 6, 2025
1 parent 4bf615f commit 69ecc92
Show file tree
Hide file tree
Showing 12 changed files with 476,324 additions and 478,248 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ dist/
*.tar.gz
*.tgz
*.zip

# Build artifacts
parser.exp
parser.lib
bindings/*
34 changes: 24 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ module.exports = grammar({

class_declaration: $ => seq(
$._class_declaration_initializer,
$._optional_semi,
choice(
seq(field('body', $.declaration_list), $._optional_semi),
';'

Check failure on line 270 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
)

Check failure on line 271 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
),

_class_declaration_initializer: $ => seq(
Expand All @@ -275,13 +278,14 @@ module.exports = grammar({
field('name', $.identifier),
repeat(choice($.type_parameter_list, $.parameter_list, $.base_list)),
repeat($.type_parameter_constraints_clause),
field('body', $.declaration_list),
),

struct_declaration: $ => seq(
$._struct_declaration_initializer,
field('body', $.declaration_list),
$._optional_semi,
choice(
seq(field('body', $.declaration_list), $._optional_semi),
';'

Check failure on line 287 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
)

Check failure on line 288 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
),

_struct_declaration_initializer: $ => seq(
Expand All @@ -295,13 +299,19 @@ module.exports = grammar({
),

enum_declaration: $ => seq(
$._enum_declaration_initializer,
choice(
seq(field('body', $.enum_member_declaration_list), $._optional_semi),
';'

Check failure on line 305 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
)

Check failure on line 306 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
),

Check failure on line 308 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
_enum_declaration_initializer: $ => seq(
repeat($._attribute_list),
repeat($.modifier),
'enum',
field('name', $.identifier),
optional($.base_list),
field('body', $.enum_member_declaration_list),
$._optional_semi,
),

enum_member_declaration_list: $ => seq(
Expand All @@ -322,8 +332,10 @@ module.exports = grammar({

interface_declaration: $ => seq(
$._interface_declaration_initializer,
field('body', $.declaration_list),
$._optional_semi,
choice(
seq(field('body', $.declaration_list), $._optional_semi),
';'

Check failure on line 337 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
)

Check failure on line 338 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
),

_interface_declaration_initializer: $ => seq(
Expand Down Expand Up @@ -354,8 +366,10 @@ module.exports = grammar({

record_declaration: $ => seq(
$._record_declaration_initializer,
choice(field('body', $.declaration_list), ';'),
$._optional_semi,
choice(
seq(field('body', $.declaration_list), $._optional_semi),
';'

Check failure on line 371 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
)
),

_record_declaration_initializer: $ => seq(
Expand Down
11 changes: 9 additions & 2 deletions package.json

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

Loading

0 comments on commit 69ecc92

Please sign in to comment.