about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 2b977153b03..135f7162157 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -5061,12 +5061,19 @@ impl Parser {
         }
     }
 
-    pub fn parse_str(&self) -> @str {
+    pub fn parse_optional_str(&self) -> Option<@str> {
         match *self.token {
             token::LIT_STR(s) => {
                 self.bump();
-                ident_to_str(&s)
+                Some(ident_to_str(&s))
             }
+            _ => None
+        }
+    }
+
+    pub fn parse_str(&self) -> @str {
+        match self.parse_optional_str() {
+            Some(s) => { s }
             _ =>  self.fatal("expected string literal")
         }
     }