about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2011-07-03 11:48:14 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2011-07-03 11:51:46 -0700
commit6369807ffedbe3f8fbfcef3febc5741dcf19cb43 (patch)
treebab9dd38fb5ab01f30c897fc9277c479a052f094 /src
parent48a69d2100622df88e3f1014eff00227401bf079 (diff)
downloadrust-6369807ffedbe3f8fbfcef3febc5741dcf19cb43.tar.gz
rust-6369807ffedbe3f8fbfcef3febc5741dcf19cb43.zip
Add a predicate that determines whether a token can begin an expression
Diffstat (limited to 'src')
-rw-r--r--src/comp/front/token.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/comp/front/token.rs b/src/comp/front/token.rs
index 50686d5093f..664a5db5e82 100644
--- a/src/comp/front/token.rs
+++ b/src/comp/front/token.rs
@@ -172,6 +172,27 @@ fn to_str(lexer::reader r, token t) -> str {
         case (EOF) { ret "<eof>"; }
     }
 }
+
+
+pred can_begin_expr(token t) -> bool {
+    alt (t) {
+        case (LPAREN) { true }
+        case (LBRACE) { true }
+        case (IDENT(_,_)) { true }
+        case (UNDERSCORE) { true }
+        case (TILDE) { true }
+        case (LIT_INT(_)) { true }
+        case (LIT_UINT(_)) { true }
+        case (LIT_MACH_INT(_,_)) { true }
+        case (LIT_FLOAT(_)) { true }
+        case (LIT_MACH_FLOAT(_,_)) { true }
+        case (LIT_STR(_)) { true }
+        case (LIT_CHAR(_)) { true }
+        case (POUND) { true }
+        case (AT) { true }
+        case (_) { false }
+    }
+}
 // Local Variables:
 // fill-column: 78;
 // indent-tabs-mode: nil