File: build/parser_util.ml (return to index)



Statistics:  
kind coverage
binding 5 / 5 (100 %)
sequence 2 / 4 (50 %)
for 0 / 0 (- %)
if/then 0 / 0 (- %)
try 1 / 1 (100 %)
while 0 / 0 (- %)
match/function 3 / 3 (100 %)
kind coverage
class expression 0 / 0 (- %)
class initializer 0 / 0 (- %)
class method 0 / 0 (- %)
class value 0 / 0 (- %)
toplevel expression 0 / 0 (- %)
lazy operator 0 / 0 (- %)



Source:

fold all unfold all
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) ->
000024|       ((*[0]*)print_string
000025|           (msg ^
000026|             (" at line " ^
000027|               ((string_of_int line) ^
000028|                 (" col " ^ ((string_of_int col) ^ "\n")))));
000029|         (*[0]*)exit 2)
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|

Legend:
   some code - line containing no point
   some code - line containing only visited points
   some code - line containing only unvisited points
   some code - line containing both visited and unvisited points