rust/crates/syntax/test_data/parser/err/0023_mismatched_paren.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..94
FN@0..55
FN_KW@0..2 "fn"
WHITESPACE@2..3 " "
NAME@3..7
IDENT@3..7 "main"
PARAM_LIST@7..9
L_PAREN@7..8 "("
R_PAREN@8..9 ")"
WHITESPACE@9..10 " "
BLOCK_EXPR@10..55
STMT_LIST@10..55
L_CURLY@10..11 "{"
WHITESPACE@11..16 "\n "
MACRO_CALL@16..49
PATH@16..19
PATH_SEGMENT@16..19
NAME_REF@16..19
IDENT@16..19 "foo"
BANG@19..20 "!"
WHITESPACE@20..21 " "
TOKEN_TREE@21..49
L_PAREN@21..22 "("
WHITESPACE@22..31 "\n "
IDENT@31..34 "bar"
COMMA@34..35 ","
WHITESPACE@35..36 " "
STRING@36..41 "\"baz\""
COMMA@41..42 ","
WHITESPACE@42..43 " "
INT_NUMBER@43..44 "1"
COMMA@44..45 ","
WHITESPACE@45..46 " "
FLOAT_NUMBER@46..49 "2.0"
WHITESPACE@49..54 "\n "
R_CURLY@54..55 "}"
WHITESPACE@55..56 " "
COMMENT@56..91 "//~ ERROR incorrect c ..."
WHITESPACE@91..92 "\n"
ERROR@92..93
R_CURLY@92..93 "}"
WHITESPACE@93..94 "\n"
error 49..49: unmatched `}`
error 92..92: unmatched `}`