Fix semicolon on package (#184)

Problem
-------
Package declaration with semicolon fails to parse.

Solution
--------
This adds an optional semicolon to fix that.
pull/481/head
eugene yokota 2023-01-28 02:45:37 +07:00 committed by GitHub
parent c7e00b85c4
commit f7b83364c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

@ -126,6 +126,17 @@ package c {
(template_body
(object_definition (identifier)))))
================================
Package with comma
================================
package a.b;
---
(compilation_unit
(package_clause (package_identifier (identifier) (identifier))))
================================
Package (Scala 3 syntax)
================================

@ -164,6 +164,7 @@ module.exports = grammar({
package_clause: $ => seq(
'package',
field('name', $.package_identifier),
optional($._semicolon),
// This is slightly more permissive than the EBNF in that it allows any
// kind of delcaration inside of the package blocks. As we're more
// concerned with the structure rather than the validity of the program