Skip to content

Commit a52aca5

Browse files
authored
Merge pull request #7 from cdisselkoen/asserts-to-parse-errors
Raise parse errors rather than asserting false
2 parents be30bc9 + 2de0704 commit a52aca5

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

frontc/cparser.mly

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
let version = "Cparser V3.0b 10.9.99 Hugues Cassé"
3737
3838
let parse_error _ =
39-
Clexer.display_error "Syntax error" (Parsing.symbol_start ()) (Parsing.symbol_end ())
39+
Clexer.display_error "Syntax error" (Parsing.symbol_start ()) (Parsing.symbol_end ());
40+
raise Parsing.Parse_error
4041
4142
(*let fatal _ =
4243
Clexer.display_error "fatal error" (Parsing.symbol_start ()) (Parsing.symbol_end
@@ -287,7 +288,7 @@ global_type global_defs SEMICOLON
287288
| OLD_PROTO _ ->
288289
OLDFUNDEF (set_single $1 $2, [], (snd $3))
289290
| _ ->
290-
assert false
291+
parse_error ()
291292
}
292293
| global_type old_proto old_pardefs body
293294
{ OLDFUNDEF (set_single $1 $2, List.rev $3, (snd $4)) }
@@ -374,19 +375,14 @@ global_dec opt_gcc_attributes
374375
PROTO _
375376
| OLD_PROTO _ ->
376377
(fst $1, snd $1, $2, NOTHING)
377-
| _ -> begin (*fatal();*) assert false end}
378+
| _ -> parse_error () }
378379
;
379380
old_proto:
380381
global_dec opt_gcc_attributes
381382
{match (snd $1) with
382383
OLD_PROTO _ -> (fst $1, snd $1, $2, NOTHING)
383384
(*| 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 }
385+
| _ -> parse_error () }
390386
;
391387

392388

@@ -1151,7 +1147,7 @@ IDENT
11511147
{
11521148
match $1 with
11531149
[(Cabs.GNU_ID name)] -> name
1154-
| _ -> assert false
1150+
| _ -> parse_error ()
11551151
}
11561152
;
11571153

0 commit comments

Comments
 (0)