Merge pull request #357 from susliko/better-semicolons

Better semicolons
pull/659/head
eugene yokota 2023-09-19 23:59:57 +07:00 committed by GitHub
commit 8f070fe470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 13 deletions

@ -418,6 +418,12 @@ object O4 extends {
val a: A = b val a: A = b
} }
object O5 {
;;
;
;
}
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(compilation_unit (compilation_unit
@ -440,7 +446,10 @@ object O4 extends {
(val_definition (val_definition
(identifier) (identifier)
(type_identifier) (type_identifier)
(identifier)))))) (identifier)))))
(object_definition
(identifier)
(template_body)))
================================================================================ ================================================================================
Object definitions Object definitions

@ -323,7 +323,7 @@ class C {
def other() { def other() {
if (a) { if (a) {
b b
} };
else c() else c()
} }
@ -669,6 +669,8 @@ def matchTest(x: Int): String = x match {
case 3 => { case 3 => {
"3" "3"
} }
case 4 =>
;
case A if a == 1 => case A if a == 1 =>
case A if a == 2 => 2 case A if a == 2 => 2
case ((i, _)) => i case ((i, _)) => i
@ -706,6 +708,8 @@ def matchTest(x: Int): String = x match {
(integer_literal) (integer_literal)
(block (block
(string))) (string)))
(case_clause
(integer_literal))
(case_clause (case_clause
(identifier) (identifier)
(guard (guard

@ -780,7 +780,7 @@ module.exports = grammar({
seq( seq(
sep1( sep1(
$._semicolon, $._semicolon,
choice($.expression, $._definition, $._end_marker), choice($.expression, $._definition, $._end_marker, ";"),
), ),
optional($._semicolon), optional($._semicolon),
), ),
@ -1106,16 +1106,20 @@ module.exports = grammar({
), ),
), ),
/*
* ::= [inline] if ( Expr ) {nl} Expr [[semi] else Expr]
* | [inline] if Expr then Expr [[semi] else Expr]
*/
if_expression: $ => if_expression: $ =>
prec.right( seq(
PREC.control, optional($.inline_modifier),
seq( "if",
optional($.inline_modifier), field("condition", $._if_condition),
"if", field("consequence", $._indentable_expression),
field("condition", $._if_condition), optional(seq(
field("consequence", $._indentable_expression), optional(";"),
optional(seq("else", field("alternative", $._indentable_expression))), "else",
), field("alternative", $._indentable_expression))),
), ),
// NOTE(susliko): _if_condition and its magic dynamic precedence were introduced as a fix to // NOTE(susliko): _if_condition and its magic dynamic precedence were introduced as a fix to

@ -4,7 +4,7 @@
SCALA_SCALA_LIBRARY_EXPECTED=100 SCALA_SCALA_LIBRARY_EXPECTED=100
SCALA_SCALA_COMPILER_EXPECTED=96 SCALA_SCALA_COMPILER_EXPECTED=96
DOTTY_COMPILER_EXPECTED=84 DOTTY_COMPILER_EXPECTED=85
SYNTAX_COMPLEXITY_CEILING=1400 SYNTAX_COMPLEXITY_CEILING=1400
if [ ! -d "$SCALA_SCALA_DIR" ]; then if [ ! -d "$SCALA_SCALA_DIR" ]; then