diff --git a/corpus/definitions.txt b/corpus/definitions.txt index 37ad21cb1..90f9fad9a 100644 --- a/corpus/definitions.txt +++ b/corpus/definitions.txt @@ -868,7 +868,8 @@ Value definitions class A { val b = 1 val c : String = "d" - val a1, a2 = pair + val a, b, c: T3 = triple + var a, b, c = triple } -------------------------------------------------------------------------------- @@ -886,6 +887,14 @@ class A { (string)) (val_definition (identifiers + (identifier) + (identifier) + (identifier)) + (type_identifier) + (identifier)) + (var_definition + (identifiers + (identifier) (identifier) (identifier)) (identifier))))) diff --git a/grammar.js b/grammar.js index d05078799..2ed1afbfa 100644 --- a/grammar.js +++ b/grammar.js @@ -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: $ => "_", diff --git a/script/smoke_test.sh b/script/smoke_test.sh index a1e847894..533deb5fe 100755 --- a/script/smoke_test.sh +++ b/script/smoke_test.sh @@ -2,8 +2,8 @@ # This is an integration test to generally check the quality of parsing. -SCALA_SCALA_LIBRARY_EXPECTED=95 -SCALA_SCALA_COMPILER_EXPECTED=89 +SCALA_SCALA_LIBRARY_EXPECTED=97 +SCALA_SCALA_COMPILER_EXPECTED=93 DOTTY_COMPILER_EXPECTED=82 SYNTAX_COMPLEXITY_CEILING=2500