]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/contrib/otherlibs/labltk/compiler/ppparse.ml
update
[l4.git] / l4 / pkg / ocaml / contrib / otherlibs / labltk / compiler / ppparse.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                 MLTk, Tcl/Tk interface of Objective Caml            *)
4 (*                                                                     *)
5 (*    Francois Rouaix, Francois Pessaux, Jun Furuse and Pierre Weis    *)
6 (*               projet Cristal, INRIA Rocquencourt                    *)
7 (*            Jacques Garrigue, Kyoto University RIMS                  *)
8 (*                                                                     *)
9 (*  Copyright 2002 Institut National de Recherche en Informatique et   *)
10 (*  en Automatique and Kyoto University.  All rights reserved.         *)
11 (*  This file is distributed under the terms of the GNU Library        *)
12 (*  General Public License, with the special exception on linking      *)
13 (*  described in file LICENSE found in the Objective Caml source tree. *)
14 (*                                                                     *)
15 (***********************************************************************)
16
17 exception Error of string
18
19 let parse_channel ic =
20   let lexbuf = Lexing.from_channel ic in
21   try
22     Ppyac.code_list Pplex.token lexbuf 
23   with
24   | Pplex.Error s ->
25       let loc_start = Lexing.lexeme_start lexbuf 
26       and loc_end = Lexing.lexeme_end lexbuf
27       in
28       raise (Error (Printf.sprintf "parse error at char %d, %d: %s" 
29                  loc_start loc_end s))
30   | Parsing.Parse_error ->
31       let loc_start = Lexing.lexeme_start lexbuf 
32       and loc_end = Lexing.lexeme_end lexbuf
33       in
34       raise (Error (Printf.sprintf "parse error at char %d, %d" 
35                 loc_start loc_end))
36 ;;