rust/crates/syntax/test_data/parser/err/0016_missing_semi.rast
Aleksey Kladov 2bf81922f7 internal: more reasonable grammar for blocks
Consider these expples

        { 92 }
  async { 92 }
    'a: { 92 }
   #[a] { 92 }

Previously the tree for them were

  BLOCK_EXPR
    { ... }

  EFFECT_EXPR
    async
    BLOCK_EXPR
      { ... }

  EFFECT_EXPR
    'a:
    BLOCK_EXPR
      { ... }

  BLOCK_EXPR
    #[a]
    { ... }

As you see, it gets progressively worse :) The last two items are
especially odd. The last one even violates the balanced curleys
invariant we have (#10357) The new approach is to say that the stuff in
`{}` is stmt_list, and the block is stmt_list + optional modifiers

  BLOCK_EXPR
    STMT_LIST
      { ... }

  BLOCK_EXPR
    async
    STMT_LIST
      { ... }

  BLOCK_EXPR
    'a:
    STMT_LIST
      { ... }

  BLOCK_EXPR
    #[a]
    STMT_LIST
      { ... }
2021-09-26 19:16:09 +03:00

45 lines
1.2 KiB
Plaintext

SOURCE_FILE@0..56
FN@0..55
FN_KW@0..2 "fn"
WHITESPACE@2..3 " "
NAME@3..6
IDENT@3..6 "foo"
PARAM_LIST@6..8
L_PAREN@6..7 "("
R_PAREN@7..8 ")"
WHITESPACE@8..9 " "
BLOCK_EXPR@9..55
STMT_LIST@9..55
L_CURLY@9..10 "{"
WHITESPACE@10..15 "\n "
EXPR_STMT@15..38
CALL_EXPR@15..38
PATH_EXPR@15..18
PATH@15..18
PATH_SEGMENT@15..18
NAME_REF@15..18
IDENT@15..18 "foo"
ARG_LIST@18..38
L_PAREN@18..19 "("
WHITESPACE@19..28 "\n "
LITERAL@28..29
INT_NUMBER@28..29 "1"
COMMA@29..30 ","
WHITESPACE@30..31 " "
LITERAL@31..32
INT_NUMBER@31..32 "2"
WHITESPACE@32..37 "\n "
R_PAREN@37..38 ")"
WHITESPACE@38..43 "\n "
EXPR_STMT@43..53
RETURN_EXPR@43..52
RETURN_KW@43..49 "return"
WHITESPACE@49..50 " "
LITERAL@50..52
INT_NUMBER@50..52 "92"
SEMICOLON@52..53 ";"
WHITESPACE@53..54 "\n"
R_CURLY@54..55 "}"
WHITESPACE@55..56 "\n"
error 38..38: expected SEMICOLON