about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorLindsey Kuper <lindsey@rockstargirl.org>2012-07-13 13:20:49 -0700
committerLindsey Kuper <lindsey@rockstargirl.org>2012-07-13 15:31:39 -0700
commit5a63b2100ed69b14e929671430101cc786f41ea7 (patch)
treec275c71c293887dac091c36287322bb45e016142 /src/libsyntax/parse
parent07a81ad12e5cb7f84138af6624f30c5dbb75512f (diff)
downloadrust-5a63b2100ed69b14e929671430101cc786f41ea7.tar.gz
rust-5a63b2100ed69b14e929671430101cc786f41ea7.zip
More consistent use of backticks and "expected" in error messages.
Got some of the debug messages, here, too.  I figure it doesn't hurt
to get used to doing this even in places where users won't ever see
it.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/common.rs27
-rw-r--r--src/libsyntax/parse/parser.rs23
2 files changed, 27 insertions, 23 deletions
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs
index 6f11f18540a..9e5f2ac2c9b 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -28,23 +28,23 @@ impl parser_common for parser {
     fn unexpected_last(t: token::token) -> ! {
         self.span_fatal(
             copy self.last_span,
-            "unexpected token: '" + token_to_str(self.reader, t) + "'");
+            "unexpected token: `" + token_to_str(self.reader, t) + "`");
     }
 
     fn unexpected() -> ! {
-        self.fatal("unexpected token: '"
-                   + token_to_str(self.reader, self.token) + "'");
+        self.fatal("unexpected token: `"
+                   + token_to_str(self.reader, self.token) + "`");
     }
 
     fn expect(t: token::token) {
         if self.token == t {
             self.bump();
         } else {
-            let mut s: str = "expecting '";
+            let mut s: str = "expected `";
             s += token_to_str(self.reader, t);
-            s += "' but found '";
+            s += "` but found `";
             s += token_to_str(self.reader, self.token);
-            self.fatal(s + "'");
+            self.fatal(s + "`");
         }
     }
 
@@ -53,8 +53,9 @@ impl parser_common for parser {
           token::IDENT(i, _) { self.bump(); ret self.get_str(i); }
           token::ACTUALLY(token::w_ident(*)) { self.bug(
               "ident interpolation not converted to real token"); }
-          _ { self.fatal("expecting ident, found "
-                      + token_to_str(self.reader, self.token)); }
+          _ { self.fatal("expected ident, found `"
+                         + token_to_str(self.reader, self.token)
+                         + "`"); }
         }
     }
 
@@ -121,8 +122,9 @@ impl parser_common for parser {
     fn expect_keyword(word: str) {
         self.require_keyword(word);
         if !self.eat_keyword(word) {
-            self.fatal("expecting " + word + ", found " +
-                    token_to_str(self.reader, self.token));
+            self.fatal("expected `" + word + "`, found `" +
+                       token_to_str(self.reader, self.token) +
+                       "`");
         }
     }
 
@@ -152,10 +154,11 @@ impl parser_common for parser {
         } else if self.token == token::BINOP(token::SHR) {
             self.swap(token::GT, self.span.lo + 1u, self.span.hi);
         } else {
-            let mut s: str = "expecting ";
+            let mut s: str = "expected `";
             s += token_to_str(self.reader, token::GT);
-            s += ", found ";
+            s += "`, found `";
             s += token_to_str(self.reader, self.token);
+            s += "`";
             self.fatal(s);
         }
     }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 7448f246698..54c268722c8 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -311,7 +311,7 @@ class parser {
                            vis: public})
               }
 
-              _ { self.fatal("expected ';' or '}` \
+              _ { self.fatal("expected `;` or `}` \
                               but found `"
                              + token_to_str(self.reader, self.token) + "`");
                 }
@@ -545,7 +545,7 @@ class parser {
         } else if self.token == token::MOD_SEP || is_ident(self.token) {
             let path = self.parse_path_with_tps(colons_before_params);
             ty_path(path, self.get_id())
-        } else { self.fatal("expecting type"); };
+        } else { self.fatal("expected type"); };
 
         let sp = mk_sp(lo, self.last_span.hi);
         ret @{id: self.get_id(),
@@ -1176,7 +1176,7 @@ class parser {
                 self.bump();
                 ret (some(sep), zerok);
             } else {
-                self.fatal("expected '*' or '+'");
+                self.fatal("expected `*` or `+`");
             }
         }
     }
@@ -1709,8 +1709,9 @@ class parser {
                 if self.token == token::UNDERSCORE {
                     self.bump();
                     if self.token != token::RBRACE {
-                        self.fatal("expecting }, found " +
-                                   token_to_str(self.reader, self.token));
+                        self.fatal("expected `}`, found `" +
+                                   token_to_str(self.reader, self.token) +
+                                   "`");
                     }
                     etc = true;
                     break;
@@ -1855,7 +1856,7 @@ class parser {
             is_mutbl = class_mutable;
         }
         if !is_plain_ident(self.token) {
-            self.fatal("expecting ident");
+            self.fatal("expected ident");
         }
         let name = self.parse_ident();
         self.expect(token::COLON);
@@ -2000,9 +2001,9 @@ class parser {
                       }
                       t {
                         if classify::stmt_ends_with_semi(*stmt) {
-                            self.fatal("expected ';' or '}' after expression \
-                                        but found '"
-                                       + token_to_str(self.reader, t) + "'");
+                            self.fatal("expected `;` or `}` after expression \
+                                        but found `"
+                                       + token_to_str(self.reader, t) + "`");
                         }
                         vec::push(stmts, stmt);
                       }
@@ -2363,8 +2364,8 @@ class parser {
             alt self.parse_item(attrs, vis) {
               some(i) { vec::push(items, i); }
               _ {
-                self.fatal("expected item but found '" +
-                           token_to_str(self.reader, self.token) + "'");
+                self.fatal("expected item but found `" +
+                           token_to_str(self.reader, self.token) + "`");
               }
             }
             #debug["parse_mod_items: attrs=%?", attrs];