-
-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Description
For the following snippet
package pkg
func foo() {
// bar
the grammar produces an ERROR (not a MISSING "}"), and places the commentnode outside thefunction_declaration`:
source_file [0, 0] - [5, 0]
package_clause [0, 0] - [0, 11]
package [0, 0] - [0, 7]
package_identifier [0, 8] - [0, 11]
[0, 11] - [2, 0]
function_declaration [2, 0] - [2, 10]
func [2, 0] - [2, 4]
name: identifier [2, 5] - [2, 8]
parameters: parameter_list [2, 8] - [2, 10]
( [2, 8] - [2, 9]
) [2, 9] - [2, 10]
ERROR [2, 11] - [2, 12]
{ [2, 11] - [2, 12]
comment [3, 0] - [3, 6]
(In fact we get ERROR instead of MISSING for a completely empty body, too.)
If there's some other node in the body (either in addition to or instead of the comment), we get a more useful tree. For
package pkg
func foo() {
bar()
we get
source_file [0, 0] - [5, 0]
package_clause [0, 0] - [0, 11]
package [0, 0] - [0, 7]
package_identifier [0, 8] - [0, 11]
[0, 11] - [2, 0]
function_declaration [2, 0] - [5, 0]
func [2, 0] - [2, 4]
name: identifier [2, 5] - [2, 8]
parameters: parameter_list [2, 8] - [2, 10]
( [2, 8] - [2, 9]
) [2, 9] - [2, 10]
body: block [2, 11] - [5, 0]
{ [2, 11] - [2, 12]
expression_statement [3, 0] - [3, 5]
call_expression [3, 0] - [3, 5]
function: identifier [3, 0] - [3, 3]
arguments: argument_list [3, 3] - [3, 5]
( [3, 3] - [3, 4]
) [3, 4] - [3, 5]
[3, 5] - [5, 0]
MISSING "}" [5, 0] - [5, 0]
Metadata
Metadata
Assignees
Labels
No labels