Skip to content

Commit 2de0704

Browse files
committed
use the parse_error function to display better error messages
1 parent 47e04ed commit 2de0704

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

frontc/cparser.mly

Lines changed: 6 additions & 5 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-
raise Parsing.Parse_error
291+
parse_error ()
291292
}
292293
| global_type old_proto old_pardefs body
293294
{ OLDFUNDEF (set_single $1 $2, List.rev $3, (snd $4)) }
@@ -374,14 +375,14 @@ global_dec opt_gcc_attributes
374375
PROTO _
375376
| OLD_PROTO _ ->
376377
(fst $1, snd $1, $2, NOTHING)
377-
| _ -> raise Parsing.Parse_error }
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-
| _ -> raise Parsing.Parse_error }
385+
| _ -> parse_error () }
385386
;
386387

387388

@@ -1146,7 +1147,7 @@ IDENT
11461147
{
11471148
match $1 with
11481149
[(Cabs.GNU_ID name)] -> name
1149-
| _ -> raise Parsing.Parse_error
1150+
| _ -> parse_error ()
11501151
}
11511152
;
11521153

0 commit comments

Comments
 (0)