Commit graph

122 commits

Author SHA1 Message Date
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
Aleksey Kladov
56964c9bd3 feat: allow attributes on all expressions
Attrs are syntactically valid on any expression, even if they are not
allowed semantically everywhere yet.
2021-09-25 22:19:27 +03:00
Aleksey Kladov
7dc331faef fix: correct extend_to logic in parser
Previously we swapped to events in the buffer, but that might be wrong
if there aer `forward_parent` links pointing to the swapped-out node.

Let's do the same via parent links instead, keeping the nodes in place
2021-09-25 22:09:50 +03:00
Aleksey Kladov
6997adfee7 simplify attribute parsing 2021-09-25 18:07:51 +03:00
Aleksey Kladov
f27cda6865 minor: more condensed tests 2021-09-25 14:24:57 +03:00
Aleksey Kladov
f692be853b minor: link my own pratt parsing article :-) 2021-09-25 14:20:34 +03:00
Aleksey Kladov
1567bbb73e minor: more focusted tests 2021-09-25 14:04:27 +03:00
Aleksey Kladov
a6f17f7436 minor: more readable code 2021-09-25 13:27:53 +03:00
Aleksey Kladov
a6181bfdb7 internal: more focused tests for const arguments 2021-09-19 16:35:10 +03:00
Aleksey Kladov
09531b703d minor: simplify 2021-09-19 14:50:53 +03:00
Aleksey Kladov
0005678649 minor: simplify 2021-09-19 14:26:35 +03:00
Aleksey Kladov
f99bdf4cc0 fix: don't allow two turbo-fishes in generic arguments 2021-09-19 12:09:50 +03:00
Aleksey Kladov
8009ccc27d minor: improve readability 2021-09-19 11:34:25 +03:00
Aleksey Kladov
25adc5e9f0 minor: reduce duplication 2021-09-19 11:19:31 +03:00
Aleksey Kladov
fbb6a6a95b fix: correctly handle jointness 2021-09-18 16:09:12 +03:00
Aleksey Kladov
c0556bd8c1 minor: improve readability 2021-09-18 15:56:26 +03:00
Aleksey Kladov
ed84717869 internal: better naming 2021-09-18 15:55:07 +03:00
Aleksey Kladov
3dc2aeea0f internal: parser cleanup 2021-09-18 15:46:28 +03:00
Aleksey Kladov
af9fd37cd9 internal: minimize use_tree parser tests
The code here is intentionally dense and does exactly what is written.
Explaining semantic difference between Rust 2015 and 2018 doesn't help
with understanding syntax. Better to just add more targeted tests.
2021-09-18 15:22:49 +03:00
Aleksey Kladov
1d2e9818d6 internal: parser cleanups 2021-09-18 14:53:46 +03:00
Aleksey Kladov
aaadaa40bd internal: more focused trait item parsing tests 2021-09-18 14:34:29 +03:00
Aleksey Kladov
3474e3b3b1 intenral: more local tests for statics 2021-09-18 01:02:43 +03:00
Aleksey Kladov
1feb8e89d5 minor: cleanup const parsing 2021-09-18 00:58:35 +03:00
Aleksey Kladov
46326b8db7 minor: better test placement 2021-09-18 00:54:03 +03:00
Aleksey Kladov
2195ecd7e7 internal: cleanup adt parsing 2021-09-18 00:50:27 +03:00
Aleksey Kladov
d890c767c4 internal: cleanup item parsing 2021-09-18 00:33:42 +03:00
Aleksey Kladov
ec2043a082 minor: parser cleanup 2021-09-18 00:14:20 +03:00
Aleksey Kladov
4d2956e775 minor: simplify 2021-09-17 23:31:37 +03:00
Aleksey Kladov
366d3d7544 minor: cleanup 2021-09-17 23:27:26 +03:00
Aleksey Kladov
329b01ca67 minor: simplify 2021-09-17 22:26:39 +03:00
Aleksey Kladov
77e8421d0f internal: more local parsing tests for macros 2021-09-17 22:21:57 +03:00
Aleksey Kladov
073d5f7733 internal: more focused parsing tests 2021-09-17 22:15:12 +03:00
Aleksey Kladov
55078c81e0 internal: more local test for mod item 2021-09-17 21:53:24 +03:00
Aleksey Kladov
715cd8d938 internal: more local parsing tests 2021-09-17 21:49:01 +03:00
Aleksey Kladov
f632b5e481 internal: parser cleanups 2021-09-17 21:40:28 +03:00
Aleksey Kladov
c56f041477 internal: simplify 2021-09-13 13:35:31 +03:00
Aleksey Kladov
940b3afd00 internal: fix bugs in tests by simplifying code 2021-09-13 13:29:27 +03:00
Aleksey Kladov
682fbbbd5a minor: modernize 2021-09-06 18:54:16 +03:00
Aleksey Kladov
104cd0ce88 internal: make name consistent with usage 2021-09-06 18:34:03 +03:00
Aleksey Kladov
dbb702cfc1 internal: remove accidental code re-use
FragmentKind played two roles:

* entry point to the parser
* syntactic category of a macro call

These are different use-cases, and warrant different types. For example,
macro can't expand to visibility, but we have such fragment today.

This PR introduces `ExpandsTo` enum to separate this two use-cases.

I suspect we might further split `FragmentKind` into `$x:specifier` enum
specific to MBE, and a general parser entry point, but that's for
another PR!
2021-09-05 22:36:36 +03:00
Aleksey Kladov
4452f9ec48 internal: improve style
Group related stuff together, use only on path for parsing extern blocks
(they actually have modifiers).

Perhaps we should get rid of items_without_modifiers altogether? Better
to handle these kinds on diagnostics in validation layer...
2021-08-30 15:55:40 +03:00
Aleksey Kladov
8dc3b46017 fix: avoid panic when parsing extern block
closes #10083
2021-08-30 15:40:47 +03:00
Frank Steffahn
75073451c6 Fix three more (reverse) “a”/“an” typos 2021-08-22 17:48:15 +02:00
Jonas Schievink
d568e7686a Support if let match guards 2021-08-13 00:25:14 +02:00
Jade
775670e32c Split the test 2021-08-04 03:01:48 -07:00
Jade
b90ed92a5c Support exclusive_range_pattern
Fix #9779
2021-08-03 21:36:29 -07:00
Jade
e3a67ccec6 tree-wide: fix rustdoc warnings, add some links 2021-08-03 21:34:20 -07:00
Lukas Wirth
f04cff102f Simplify 2021-07-30 13:12:52 +02:00
Lukas Wirth
4de447b293 Attach comma token to MATCH_ARM instead of MATCH_ARM_LIST 2021-07-29 23:02:52 +02:00
Lukas Wirth
f43cd562bc Fix generic_arg not parsing opt_generic_arg_list properly in arg lists 2021-07-26 15:21:19 +02:00