From 6247a529e3af664f885ac0bb05bf6be2c102ec6a Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Fri, 13 Jul 2012 19:08:18 -0700 Subject: Handle prefix notations for strings in patterns. This is kind of gross. --- src/libsyntax/parse/parser.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2ab796db319..784044a2df0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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(); -- cgit 1.4.1-3-g733a5