@ -3,9 +3,7 @@ const PREC = {
using _directive : 1 ,
control : 1 ,
stable _type _id : 2 ,
binding _decl : 2 ,
while : 2 ,
binding _def : 3 ,
assign : 3 ,
case : 3 ,
stable _id : 4 ,
@ -91,6 +89,8 @@ module.exports = grammar({
[ $ . _class _constructor ] ,
// 'enum' _class_constructor '{' 'case' operator_identifier _full_enum_def_repeat1 • _automatic_semicolon …
[ $ . _full _enum _def ] ,
// _start_val identifier ',' identifier • ':' …
[ $ . identifiers , $ . val _declaration ] ,
] ,
word : $ => $ . _alpha _identifier ,
@ -456,51 +456,39 @@ module.exports = grammar({
) ,
val _definition : $ =>
prec (
PREC . binding _def ,
seq (
$ . _start _val ,
field ( "pattern" , choice ( $ . _pattern , $ . identifiers ) ) ,
optional ( seq ( ":" , field ( "type" , $ . _type ) ) ) ,
"=" ,
field ( "value" , $ . _indentable _expression ) ,
) ,
seq (
$ . _start _val ,
field ( "pattern" , choice ( $ . _pattern , $ . identifiers ) ) ,
optional ( seq ( ":" , field ( "type" , $ . _type ) ) ) ,
"=" ,
field ( "value" , $ . _indentable _expression ) ,
) ,
val _declaration : $ =>
prec (
PREC . binding _decl ,
seq (
$ . _start _val ,
commaSep1 ( field ( "name" , $ . _identifier ) ) ,
":" ,
field ( "type" , $ . _type ) ,
) ,
seq (
$ . _start _val ,
commaSep1 ( field ( "name" , $ . _identifier ) ) ,
":" ,
field ( "type" , $ . _type ) ,
) ,
_start _val : $ => seq ( repeat ( $ . annotation ) , optional ( $ . modifiers ) , "val" ) ,
var _declaration : $ =>
prec (
PREC . binding _decl ,
seq (
$ . _start _var ,
commaSep1 ( field ( "name" , $ . _identifier ) ) ,
":" ,
field ( "type" , $ . _type ) ,
) ,
seq (
$ . _start _var ,
commaSep1 ( field ( "name" , $ . _identifier ) ) ,
":" ,
field ( "type" , $ . _type ) ,
) ,
var _definition : $ =>
prec (
PREC . binding _def ,
seq (
$ . _start _var ,
field ( "pattern" , $ . _pattern ) ,
optional ( seq ( ":" , field ( "type" , $ . _type ) ) ) ,
"=" ,
field ( "value" , $ . _indentable _expression ) ,
) ,
seq (
$ . _start _var ,
field ( "pattern" , choice ( $ . _pattern , $ . identifiers ) ) ,
optional ( seq ( ":" , field ( "type" , $ . _type ) ) ) ,
"=" ,
field ( "value" , $ . _indentable _expression ) ,
) ,
_start _var : $ => seq ( repeat ( $ . annotation ) , optional ( $ . modifiers ) , "var" ) ,
@ -1384,8 +1372,7 @@ module.exports = grammar({
_identifier : $ => choice ( $ . identifier , $ . operator _identifier ) ,
identifiers : $ =>
prec . left ( - 1 , seq ( $ . identifier , "," , commaSep1 ( $ . identifier ) ) ) ,
identifiers : $ => seq ( $ . identifier , "," , commaSep1 ( $ . identifier ) ) ,
wildcard : $ => "_" ,