@@ -101,52 +101,43 @@ enum class_contents { ctor_decl(fn_decl, ~[attribute], blk, codemap::span),
101
101
type arg_or_capture_item = either < arg , capture_item > ;
102
102
type item_info = ( ident , item_ , option < ~[ attribute ] > ) ;
103
103
104
- fn dummy ( ) {
105
104
105
+ /* The expr situation is not as complex as I thought it would be.
106
+ The important thing is to make sure that lookahead doesn't balk
107
+ at ACTUALLY tokens */
108
+ macro_rules! maybe_whole_expr{
109
+ { $p: expr} => { alt copy $p. token {
110
+ ACTUALLY ( token:: w_expr( e) ) {
111
+ $p. bump( ) ;
112
+ ret pexpr( e) ;
113
+ }
114
+ ACTUALLY ( token:: w_path( pt) ) {
115
+ $p. bump( ) ;
116
+ ret $p. mk_pexpr( $p. span. lo, $p. span. lo,
117
+ expr_path( pt) ) ;
118
+ }
119
+ _ { }
120
+ } }
121
+ }
106
122
123
+ macro_rules! maybe_whole {
124
+ { $p: expr, $constructor: path} => { alt copy $p. token {
125
+ ACTUALLY ( $constructor( x) ) { $p. bump( ) ; ret x; }
126
+ _ { }
127
+ } }
128
+ }
107
129
108
- #macro[ [ #maybe_whole_item[ p] ,
109
- alt copy p. token {
110
- ACTUALLY ( token:: w_item ( i) ) { p. bump ( ) ; ret i; }
111
- _ { } } ] ] ;
112
- #macro[ [ #maybe_whole_block[ p] ,
113
- alt copy p. token {
114
- ACTUALLY ( token:: w_block ( b) ) { p. bump ( ) ; ret b; }
115
- _ { } } ] ] ;
116
- #macro[ [ #maybe_whole_stmt[ p] ,
117
- alt copy p. token {
118
- ACTUALLY ( token:: w_stmt ( s) ) { p. bump ( ) ; ret s; }
119
- _ { } } ] ] ;
120
- #macro[ [ #maybe_whole_pat[ p] ,
121
- alt copy p. token {
122
- ACTUALLY ( token:: w_pat ( pt) ) { p. bump ( ) ; ret pt; }
123
- _ { } } ] ] ;
124
- /* The expr situation is not as complex as I thought it would be.
125
- The important thing is to make sure that lookahead doesn't balk
126
- at ACTUALLY tokens */
127
- #macro[ [ #maybe_whole_expr_pexpr[ p] , /* ack! */
128
- alt copy p. token {
129
- ACTUALLY ( token:: w_expr ( e) ) {
130
- p. bump ( ) ;
131
- ret pexpr( e) ;
132
- }
133
- ACTUALLY ( token:: w_path ( pt) ) {
134
- p. bump ( ) ;
135
- ret p. mk_pexpr ( p. span . lo , p. span . lo ,
136
- expr_path ( pt) ) ;
137
- }
138
- _ { } } ] ] ;
139
- #macro[ [ #maybe_whole_ty[ p] ,
140
- alt copy p. token {
141
- ACTUALLY ( token:: w_ty ( t) ) { p. bump ( ) ; ret t; }
142
- _ { } } ] ] ;
143
- /* ident is handled by common.rs */
130
+ /* ident is handled by common.rs */
131
+
132
+ fn dummy ( ) {
133
+ /* we will need this to bootstrap maybe_whole! */
144
134
#macro[ [ #maybe_whole_path[ p] ,
145
135
alt p. token {
146
136
ACTUALLY ( token:: w_path ( pt) ) { p. bump ( ) ; ret pt; }
147
137
_ { } } ] ] ;
148
138
}
149
139
140
+
150
141
class parser {
151
142
let sess : parse_sess;
152
143
let cfg: crate_cfg ;
@@ -734,7 +725,7 @@ class parser {
734
725
}
735
726
736
727
fn parse_bottom_expr() -> pexpr {
737
- #maybe_whole_expr_pexpr[ self] ;
728
+ maybe_whole_expr!{ self} ;
738
729
let lo = self.span.lo;
739
730
let mut hi = self.span.hi;
740
731
0 commit comments