Stream: t-compiler/wg-rls-2.0

Topic: rust-analyzer#930


vipentti (Mar 05 2019 at 08:59, on Zulip):

@matklad What does the recovery_set do ? Match arm has

    p.eat(PIPE);
    patterns::pattern_r(p, TokenSet::empty());
matklad (Mar 05 2019 at 09:00, on Zulip):

They control behavior when an unexpcted token is enountered

matklad (Mar 05 2019 at 09:00, on Zulip):

for struct Foo bar, you'll want to consume the bar token as an erroneous token

matklad (Mar 05 2019 at 09:01, on Zulip):

for struct Foo fn, you want to not consume fn, such that it can be parsed as a part of the folowing function for code liks this:

struct Foo

fn bar() {}
matklad (Mar 05 2019 at 09:01, on Zulip):

recovery_set is the set of tokens you can't consume

matklad (Mar 05 2019 at 09:01, on Zulip):

using the grammar language, it is something aking to a FOLLOW set

vipentti (Mar 05 2019 at 09:02, on Zulip):

Aha! Thanks, so I think when it comes to piped patterns both conditionals and matches can parse the first piped pattern with empty recovery set ?

vipentti (Mar 05 2019 at 09:05, on Zulip):

e.g.

    p.eat(PIPE);
    pattern_r(p, TokenSet::empty());
   // loop here for rest of the piped patterns
matklad (Mar 05 2019 at 09:05, on Zulip):

Yeah, I think something like this should work

matklad (Mar 05 2019 at 09:05, on Zulip):

though, we probably might want to be more careful in lets

matklad (Mar 05 2019 at 09:05, on Zulip):

for match, we have {}, so error recovery is not imiportant

matklad (Mar 05 2019 at 09:06, on Zulip):

for let, I expect the following should parse resonably:

let

let foo = 92;

That is, the second let should be recognized as such

matklad (Mar 05 2019 at 09:06, on Zulip):

I think we have a test for this

vipentti (Mar 05 2019 at 09:08, on Zulip):

Yeah, 0019_let_recover

matklad (Mar 05 2019 at 09:09, on Zulip):

So, I think the recovery set should be a parameter of the function

matklad (Mar 05 2019 at 09:09, on Zulip):

we set it to smth for let, and leave it empy for match

vipentti (Mar 05 2019 at 09:19, on Zulip):

hmm, I wonder what would be proper value for the conditional let pattern recovery set, it only occurs when you have if or while followed by let

matklad (Mar 05 2019 at 09:19, on Zulip):

the same as for usual let I suppose

Last update: Nov 12 2019 at 15:30UTC