Handle prefix notations for strings in patterns. This is kind of gross.
This commit is contained in:
parent
eaf8b7675e
commit
6247a529e3
1 changed files with 21 additions and 2 deletions
|
@ -1696,14 +1696,33 @@ class parser {
|
|||
token::AT {
|
||||
self.bump();
|
||||
let sub = self.parse_pat();
|
||||
pat = pat_box(sub);
|
||||
hi = sub.span.hi;
|
||||
// HACK: parse @"..." as a literal of a vstore @str
|
||||
pat = alt sub.node {
|
||||
pat_lit(e@@{node: expr_lit(@{node: lit_str(_), span: _}), _}) {
|
||||
let vst = @{id: self.get_id(), callee_id: self.get_id(),
|
||||
node: expr_vstore(e, vstore_box),
|
||||
span: mk_sp(lo, hi)};
|
||||
pat_lit(vst)
|
||||
}
|
||||
_ { pat_box(sub) }
|
||||
};
|
||||
}
|
||||
token::TILDE {
|
||||
self.bump();
|
||||
let sub = self.parse_pat();
|
||||
pat = pat_uniq(sub);
|
||||
hi = sub.span.hi;
|
||||
// HACK: parse ~"..." as a literal of a vstore ~str
|
||||
pat = alt sub.node {
|
||||
pat_lit(e@@{node: expr_lit(@{node: lit_str(_), span: _}), _}) {
|
||||
let vst = @{id: self.get_id(), callee_id: self.get_id(),
|
||||
node: expr_vstore(e, vstore_uniq),
|
||||
span: mk_sp(lo, hi)};
|
||||
pat_lit(vst)
|
||||
}
|
||||
_ { pat_uniq(sub) }
|
||||
};
|
||||
|
||||
}
|
||||
token::LBRACE {
|
||||
self.bump();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue