1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768(**************************************************************************)(* *)(* This file is part of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)typet=|Stringofstring|WStringofint64listexceptionOutOfBoundsexceptionNotAsciiofint64letget_char(s:t)(i:int):char=matchswith|Strings->begintryString.getsiwithInvalid_argument_->raiseOutOfBoundsend|WStrings->begintryletc=List.nthsiinif(c>=Int64.zero&&c<=(Int64.of_int255))thenChar.chr(Int64.to_intc)elseraise(NotAsciic)withFailure_->raiseOutOfBoundsendletget_wchar(s:t)(i:int):int64=matchswith|Strings->begintryInt64.of_int(Char.code(String.getsi))withInvalid_argument_->raiseOutOfBoundsend|WStrings->begintryList.nthsiwithFailure_->raiseOutOfBoundsendletsub_string(s:t)(start:int)(len:int):string=letinit_chari=get_chars(start+i)inString.initleninit_char