Warning, /education/kalzium/src/solver/calc.ml is written in an unsupported language. File is not indexed.
0001 (* 0002 SPDX-FileCopyrightText: 2004 Thomas Nagy <tnagy2^8@yahoo.fr> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 *) 0006 0007 open Printf;; 0008 open Chemset;; 0009 open Datastruct;; 0010 open Chem;; 0011 open Hashtbl;; 0012 0013 let create_equation str = 0014 let lexbuf = Lexing.from_string str in 0015 let result = Parser.main Lexer.token lexbuf in 0016 result 0017 ;; 0018 0019 exception Not_found;; 0020 0021 let solve_equation (str:string) = 0022 let eq = new eqtable in 0023 try 0024 eq#build (create_equation str); 0025 try 0026 (* eq#print_all (); *) 0027 solve eq; 0028 eq#get_eq_sol (); 0029 0030 with | _ -> begin 0031 let str = (eq#get_eq_orig ())^" : No solution found" in 0032 (*cleanup eq;*) 0033 str 0034 end 0035 with | _ -> str^" : Parse Error"; 0036 ;; 0037 0038 let _ = Callback.register "solve_equation" solve_equation;;