Skip to content

Commit a6e188f

Browse files
committed
rustc: Rename parser.err to parser.fatal
1 parent fe09256 commit a6e188f

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/comp/front/parser.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type parser =
2828
obj {
2929
fn peek() -> token::token ;
3030
fn bump() ;
31-
fn err(str) -> ! ;
31+
fn fatal(str) -> ! ;
3232
fn restrict(restriction) ;
3333
fn get_restriction() -> restriction ;
3434
fn get_file_type() -> file_type ;
@@ -74,7 +74,7 @@ fn new_parser(session::session sess, eval::env env,
7474
lo = rdr.get_mark_chpos();
7575
hi = rdr.get_chpos();
7676
}
77-
fn err(str m) -> ! { sess.span_fatal(rec(lo=lo, hi=hi), m); }
77+
fn fatal(str m) -> ! { sess.span_fatal(rec(lo=lo, hi=hi), m); }
7878
fn restrict(restriction r) { res = r; }
7979
fn get_restriction() -> restriction { ret res; }
8080
fn get_session() -> session::session { ret sess; }
@@ -164,7 +164,7 @@ fn bad_expr_word_table() -> hashmap[str, ()] {
164164
fn unexpected(&parser p, token::token t) -> ! {
165165
let str s = "unexpected token: ";
166166
s += token::to_str(p.get_reader(), t);
167-
p.err(s);
167+
p.fatal(s);
168168
}
169169

170170
fn expect(&parser p, token::token t) {
@@ -175,7 +175,7 @@ fn expect(&parser p, token::token t) {
175175
s += token::to_str(p.get_reader(), t);
176176
s += ", found ";
177177
s += token::to_str(p.get_reader(), p.peek());
178-
p.err(s);
178+
p.fatal(s);
179179
}
180180
}
181181

@@ -186,7 +186,7 @@ fn spanned[T](uint lo, uint hi, &T node) -> common::spanned[T] {
186186
fn parse_ident(&parser p) -> ast::ident {
187187
alt (p.peek()) {
188188
case (token::IDENT(?i, _)) { p.bump(); ret p.get_str(i); }
189-
case (_) { p.err("expecting ident"); fail; }
189+
case (_) { p.fatal("expecting ident"); fail; }
190190
}
191191
}
192192

@@ -209,12 +209,12 @@ fn parse_str_lit_or_env_ident(&parser p) -> ast::ident {
209209
eval::lookup(p.get_session(), p.get_env(), p.get_span(),
210210
p.get_str(i));
211211
if (!eval::val_is_str(v)) {
212-
p.err("expecting string-valued variable");
212+
p.fatal("expecting string-valued variable");
213213
}
214214
p.bump();
215215
ret eval::val_as_str(v);
216216
}
217-
case (_) { p.err("expecting string literal"); fail; }
217+
case (_) { p.fatal("expecting string literal"); fail; }
218218
}
219219
}
220220

@@ -239,7 +239,7 @@ fn eat_word(&parser p, &str word) -> bool {
239239

240240
fn expect_word(&parser p, &str word) {
241241
if (!eat_word(p, word)) {
242-
p.err("expecting " + word + ", found " +
242+
p.fatal("expecting " + word + ", found " +
243243
token::to_str(p.get_reader(), p.peek()));
244244
}
245245
}
@@ -249,7 +249,7 @@ fn check_bad_word(&parser p) {
249249
case (token::IDENT(?sid, false)) {
250250
auto w = p.get_str(sid);
251251
if (p.get_bad_expr_words().contains_key(w)) {
252-
p.err("found " + w + " in expression position");
252+
p.fatal("found " + w + " in expression position");
253253
}
254254
}
255255
case (_) { }
@@ -436,7 +436,7 @@ fn parse_ty_postfix(@ast::ty orig_t, &parser p) -> @ast::ty {
436436
ann));
437437
}
438438
case (_) {
439-
p.err("type parameter instantiation only allowed for " +
439+
p.fatal("type parameter instantiation only allowed for " +
440440
"paths");
441441
}
442442
}
@@ -572,7 +572,7 @@ fn parse_ty(&parser p) -> @ast::ty {
572572
auto path = parse_path(p);
573573
t = ast::ty_path(path, p.get_id());
574574
hi = path.span.hi;
575-
} else { p.err("expecting type"); t = ast::ty_nil; fail; }
575+
} else { p.fatal("expecting type"); t = ast::ty_nil; fail; }
576576
ret parse_ty_postfix(@spanned(lo, hi, t), p);
577577
}
578578

@@ -917,7 +917,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
917917
if (/*check*/ast::is_call_expr(e)) {
918918
hi = e.span.hi;
919919
ex = ast::expr_be(e);
920-
} else { p.err("Non-call expression in tail call"); }
920+
} else { p.fatal("Non-call expression in tail call"); }
921921
} else if (eat_word(p, "port")) {
922922
expect(p, token::LPAREN);
923923
expect(p, token::RPAREN);
@@ -982,7 +982,7 @@ fn expand_syntax_ext(&parser p, common::span sp, &ast::path path,
982982
assert (vec::len(path.node.idents) > 0u);
983983
auto extname = path.node.idents.(0);
984984
alt (p.get_syntax_expanders().find(extname)) {
985-
case (none) { p.err("unknown syntax expander: '" + extname + "'"); }
985+
case (none) { p.fatal("unknown syntax expander: '" + extname + "'"); }
986986
case (some(ext::x(?ext))) {
987987
auto ext_cx = ext::mk_ctxt(p);
988988
ret ast::expr_ext(path, args, body, ext(ext_cx, sp, args, body));
@@ -1313,7 +1313,7 @@ fn parse_alt_expr(&parser p) -> @ast::expr {
13131313
/* empty */
13141314

13151315
} else {
1316-
p.err("expected 'case' or '}' when parsing 'alt' statement " +
1316+
p.fatal("expected 'case' or '}' when parsing 'alt' statement " +
13171317
"but found " + token::to_str(p.get_reader(), p.peek()));
13181318
}
13191319
}
@@ -1391,7 +1391,7 @@ fn parse_pat(&parser p) -> @ast::pat {
13911391
ast::pat_bind(p.get_str(id), p.get_id());
13921392
}
13931393
case (?tok) {
1394-
p.err("expected identifier after '?' in pattern but " +
1394+
p.fatal("expected identifier after '?' in pattern but " +
13951395
"found " + token::to_str(p.get_reader(), tok));
13961396
fail;
13971397
}
@@ -1503,7 +1503,7 @@ fn parse_source_stmt(&parser p) -> @ast::stmt {
15031503
alt (maybe_item) {
15041504
case (got_item(_)) { /* fallthrough */ }
15051505
case (_) {
1506-
ret p.err("expected item");
1506+
ret p.fatal("expected item");
15071507
}
15081508
}
15091509
}
@@ -1528,7 +1528,7 @@ fn parse_source_stmt(&parser p) -> @ast::stmt {
15281528
}
15291529
}
15301530
}
1531-
p.err("expected statement");
1531+
p.fatal("expected statement");
15321532
fail;
15331533
}
15341534

@@ -1612,7 +1612,7 @@ fn parse_block(&parser p) -> ast::block {
16121612
case (token::RBRACE) { expr = some(e); }
16131613
case (?t) {
16141614
if (stmt_ends_with_semi(*stmt)) {
1615-
p.err("expected ';' or '}' after " +
1615+
p.fatal("expected ';' or '}' after " +
16161616
"expression but found " +
16171617
token::to_str(p.get_reader(),
16181618
t));
@@ -1798,7 +1798,7 @@ fn parse_mod_items(&parser p, token::token term,
17981798
alt (parse_item(p, attrs)) {
17991799
case (got_item(?i)) { vec::push(items, i); }
18001800
case (_) {
1801-
p.err("expected item but found " +
1801+
p.fatal("expected item but found " +
18021802
token::to_str(p.get_reader(), p.peek()));
18031803
}
18041804
}
@@ -1903,7 +1903,7 @@ fn parse_item_native_mod(&parser p, vec[ast::attribute] attrs) -> @ast::item {
19031903
abi = ast::native_abi_llvm;
19041904
} else if (str::eq(t, "rust-intrinsic")) {
19051905
abi = ast::native_abi_rust_intrinsic;
1906-
} else { p.err("unsupported abi: " + t); fail; }
1906+
} else { p.fatal("unsupported abi: " + t); fail; }
19071907
}
19081908
expect_word(p, "mod");
19091909
auto id = parse_ident(p);
@@ -1971,7 +1971,7 @@ fn parse_item_tag(&parser p, vec[ast::attribute] attrs) -> @ast::item {
19711971
}
19721972
case (token::RBRACE) {/* empty */ }
19731973
case (_) {
1974-
p.err("expected name of variant or '}' but found " +
1974+
p.fatal("expected name of variant or '}' but found " +
19751975
token::to_str(p.get_reader(), tok));
19761976
}
19771977
}
@@ -2104,7 +2104,7 @@ fn parse_inner_attrs_and_next(&parser p) -> tup(vec[ast::attribute],
21042104
fn parse_inner_attrs(&parser p) -> vec[ast::attribute] {
21052105
auto attrs_and_next = parse_inner_attrs_and_next(p);
21062106
if (vec::len(attrs_and_next._1) > 0u) {
2107-
ret p.err("expected crate directive but found " +
2107+
ret p.fatal("expected crate directive but found " +
21082108
token::to_str(p.get_reader(), p.peek()));
21092109
}
21102110
ret attrs_and_next._0;
@@ -2120,7 +2120,7 @@ fn parse_meta_item(&parser p) -> @ast::meta_item {
21202120
p.bump();
21212121
ret @spanned(lo, hi, rec(key=ident, value=p.get_str(s)));
21222122
}
2123-
case (_) { p.err("Metadata items must be string literals"); }
2123+
case (_) { p.fatal("Metadata items must be string literals"); }
21242124
}
21252125
fail;
21262126
}
@@ -2158,10 +2158,10 @@ fn parse_rest_import_name(&parser p, ast::ident first,
21582158
alt (p.peek()) {
21592159
case (token::SEMI) { p.bump(); break; }
21602160
case (token::MOD_SEP) {
2161-
if (glob) { p.err("cannot path into a glob"); }
2161+
if (glob) { p.fatal("cannot path into a glob"); }
21622162
p.bump();
21632163
}
2164-
case (_) { p.err("expecting '::' or ';'"); }
2164+
case (_) { p.fatal("expecting '::' or ';'"); }
21652165
}
21662166
alt (p.peek()) {
21672167
case (token::IDENT(_, _)) { identifiers += [parse_ident(p)]; }
@@ -2171,14 +2171,14 @@ fn parse_rest_import_name(&parser p, ast::ident first,
21712171
glob = true;
21722172
p.bump();
21732173
}
2174-
case (_) { p.err("expecting an identifier, or '*'"); }
2174+
case (_) { p.fatal("expecting an identifier, or '*'"); }
21752175
}
21762176
}
21772177
auto hi = p.get_hi_pos();
21782178
auto import_decl;
21792179
alt (def_ident) {
21802180
case (some(?i)) {
2181-
if (glob) { p.err("globbed imports can't be renamed"); }
2181+
if (glob) { p.fatal("globbed imports can't be renamed"); }
21822182
import_decl =
21832183
ast::view_item_import(i, identifiers, p.get_id());
21842184
}
@@ -2204,7 +2204,7 @@ fn parse_full_import_name(&parser p, ast::ident def_ident) ->
22042204
p.bump();
22052205
ret parse_rest_import_name(p, p.get_str(i), some(def_ident));
22062206
}
2207-
case (_) { p.err("expecting an identifier"); }
2207+
case (_) { p.fatal("expecting an identifier"); }
22082208
}
22092209
fail;
22102210
}
@@ -2223,7 +2223,7 @@ fn parse_import(&parser p) -> @ast::view_item {
22232223
}
22242224
}
22252225
}
2226-
case (_) { p.err("expecting an identifier"); }
2226+
case (_) { p.fatal("expecting an identifier"); }
22272227
}
22282228
fail;
22292229
}

0 commit comments

Comments
 (0)