Commit graph

5 commits

Author SHA1 Message Date
Marijn Suijten
d33edb4e9c ssr: Allow replacing expressions with statements
Now that statements can be matched and replaced (#6587) some usecases
require expressions to be replaced with statements as well. This happens
when something that can ambiguously be an expression or statement like
`if` and loop blocks appear in the last position of a block, as trailing
expression. In this case a replacement pattern of the form `if
foo(){$a();}==>>$a();` will only substitute `if` blocks in the list of
statements but not if they (implicitly) end up in the trailing
expression, where they are not wrapped by an EXPR_STMT (but the pattern
and template are, as parsing only succeeds for the `stmt ==>> stmt`
case).

Instead of adding two rules that match an expression - and emit
duplicate matching errors - allow the template for expressions to be a
statement if it fails to parse as an expression.
2021-01-04 10:55:09 +01:00
Marijn Suijten
cc081b7e1c syntax,ssr: Implement statement parsing 2021-01-03 11:29:33 +01:00
Aleksey Kladov
ba8d6d1e4e Remove more unreachable pubs 2020-11-02 16:58:33 +01:00
David Lattimore
c84f98385a Refactor SSR so that placeholders store a Var
This allows lookup of placeholder bindings given a placeholder without
needing to create a Var instance.
2020-08-14 20:12:26 +10:00
Aleksey Kladov
ae3abd6e57 Rename ra_ssr -> ssr 2020-08-13 17:02:44 +02:00
Renamed from crates/ra_ssr/src/parsing.rs (Browse further)