Skip to content

Commit 6369807

Browse files
committed
Add a predicate that determines whether a token can begin an expression
1 parent 48a69d2 commit 6369807

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/comp/front/token.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,27 @@ fn to_str(lexer::reader r, token t) -> str {
172172
case (EOF) { ret "<eof>"; }
173173
}
174174
}
175+
176+
177+
pred can_begin_expr(token t) -> bool {
178+
alt (t) {
179+
case (LPAREN) { true }
180+
case (LBRACE) { true }
181+
case (IDENT(_,_)) { true }
182+
case (UNDERSCORE) { true }
183+
case (TILDE) { true }
184+
case (LIT_INT(_)) { true }
185+
case (LIT_UINT(_)) { true }
186+
case (LIT_MACH_INT(_,_)) { true }
187+
case (LIT_FLOAT(_)) { true }
188+
case (LIT_MACH_FLOAT(_,_)) { true }
189+
case (LIT_STR(_)) { true }
190+
case (LIT_CHAR(_)) { true }
191+
case (POUND) { true }
192+
case (AT) { true }
193+
case (_) { false }
194+
}
195+
}
175196
// Local Variables:
176197
// fill-column: 78;
177198
// indent-tabs-mode: nil

0 commit comments

Comments
 (0)