Skip to content

Commit 47e04ed

Browse files
committed
Raise parse errors rather than asserting false
This results in more helpful error messages
1 parent be30bc9 commit 47e04ed

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

frontc/cparser.mly

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ global_type global_defs SEMICOLON
287287
| OLD_PROTO _ ->
288288
OLDFUNDEF (set_single $1 $2, [], (snd $3))
289289
| _ ->
290-
assert false
290+
raise Parsing.Parse_error
291291
}
292292
| global_type old_proto old_pardefs body
293293
{ OLDFUNDEF (set_single $1 $2, List.rev $3, (snd $4)) }
@@ -374,19 +374,14 @@ global_dec opt_gcc_attributes
374374
PROTO _
375375
| OLD_PROTO _ ->
376376
(fst $1, snd $1, $2, NOTHING)
377-
| _ -> begin (*fatal();*) assert false end}
377+
| _ -> raise Parsing.Parse_error }
378378
;
379379
old_proto:
380380
global_dec opt_gcc_attributes
381381
{match (snd $1) with
382382
OLD_PROTO _ -> (fst $1, snd $1, $2, NOTHING)
383383
(*| PROTO (typ, [], ell) -> fst $1, OLD_PROTO (typ, [], ell), $2, NOTHING*)
384-
| _ -> begin
385-
(*fatal();
386-
Cprint.print_type (fun _ -> ()) (snd $1);
387-
print_string ("[" ^ !Cprint.line ^ "]");*)
388-
assert false
389-
end }
384+
| _ -> raise Parsing.Parse_error }
390385
;
391386

392387

@@ -1151,7 +1146,7 @@ IDENT
11511146
{
11521147
match $1 with
11531148
[(Cabs.GNU_ID name)] -> name
1154-
| _ -> assert false
1149+
| _ -> raise Parsing.Parse_error
11551150
}
11561151
;
11571152

0 commit comments

Comments
 (0)