
000001| (**

000002| This program is free software; you can redistribute it and / or modify

000003| it under the terms of the GNU General Public License as published by

000004| the Free Software Foundation; version 3 of the License.

000005|

000006| This program is distributed in the hope that it will be useful,

000007| but WITHOUT ANY WARRANTY; without even the implied warranty of

000008| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

000009| GNU General Public License for more details.

000010|

000011| Routines to parse a file

000012|

000013| @author Tony BenBrahim < tony.benbrahim at gmail.com >

000014|

000015| *)

000016|

000017| open RuntimeError

000018|

000019| let get_ast lexbuf =

000020| (*[20]*)let _ = Parsing.set_trace false in

000021| (*[20]*)try (*[20]*)Parser.program Lexer.main lexbuf

000022| with

000023| | RuntimeError.LexerException (msg, line, col) ->

000030|

000031| let parse channel name =

000032| (*[20]*)let lexbuf = Lexing.from_channel channel in

000033| (*[20]*)let pos = lexbuf.Lexing.lex_curr_p in

000034| (*[20]*)let _ =

000035| lexbuf.Lexing.lex_curr_p <-

000036| { (pos) with Lexing.pos_lnum = 1; Lexing.pos_fname = name; }

000037| in (*[20]*)get_ast lexbuf

000038|

000039| let parse_filename filename =

000040| (*[20]*)let channel = open_in filename in

000041| (*[20]*)let ast = parse channel filename in

000042| (*[20]*)close_in channel;

000043| (*[20]*)ast

000044|