diff options
| author | Michael Sullivan <sully@msully.net> | 2012-07-13 19:08:18 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2012-07-13 19:08:18 -0700 |
| commit | 6247a529e3af664f885ac0bb05bf6be2c102ec6a (patch) | |
| tree | cdcd1ce105398ece5ff6eddc8fd9f3350df93ab6 /src/libsyntax/parse/parser.rs | |
| parent | eaf8b7675ea3989cce9ecfe845c44e13c135d1d0 (diff) | |
| download | rust-6247a529e3af664f885ac0bb05bf6be2c102ec6a.tar.gz rust-6247a529e3af664f885ac0bb05bf6be2c102ec6a.zip | |
Handle prefix notations for strings in patterns. This is kind of gross.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 23 |
1 files changed, 21 insertions, 2 deletions
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(); |
