(* * Copyright (c) 2002 by Laboratoire Spécification et Vérification (LSV), * CNRS UMR 8643 & ENS Cachan. * Written by Jean Goubault-Larrecq. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. Neither the author nor its employer is responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * 4. This software is restricted to non-commercial use only. Commercial * use is subject to a specific license, obtainable from LSV. * This was developed as part of the EVA project; as such, access * to this software by partners of the RNTL EVA Project (Trusted * Logic S.A., Verimag) is defined by the intellectual property * agreement signed as part of this project. *) open Lisptoken open Lispin open Term exception LispNoFunction exception LispUnexpectedFunction of string exception LispRParen exception LispExpectedInt exception LispExpectedFile exception LispExpectedRParen let rec lispread1 lexbuf = match lisptoken lexbuf with LISP_LPAREN -> (match lisptoken lexbuf with LISP_ID "line" -> let t = lispread1 lexbuf in let m = lispreadint lexbuf in let n = lispreadint lexbuf in let p = lispreadint lexbuf in let q = lispreadint lexbuf in let s = lispreadstring lexbuf in (match lisptoken lexbuf with LISP_RPAREN -> LINE (t, { first_line = m; first_column = n; last_line = p; last_column = q; in_file = s}) | _ -> raise LispExpectedRParen) | LISP_ID fname -> APP (fname, lispreadlist lexbuf) | _ -> raise LispNoFunction) | LISP_RPAREN -> raise LispRParen | LISP_INT n -> INT n | LISP_STRING s -> VAR s | LISP_ID s -> raise (LispUnexpectedFunction s) and lispreadlist lexbuf = try let fst = lispread1 lexbuf in let rest = lispreadlist lexbuf in fst::rest with LispRParen -> [] and lispreadint lexbuf = match lispread1 lexbuf with INT n -> n | _ -> raise LispExpectedInt and lispreadstring lexbuf = match lispread1 lexbuf with VAR s -> s | APP ("nil", []) -> "" | _ -> raise LispExpectedFile let lispread file = let lexbuf = Lexing.from_channel file in lispread1 lexbuf