Including Libraries - overturetool/vdm-vscode GitHub Wiki

You can import libraries into your project by right-clicking on the project folder and selecting VDM > Add VDM Library. This displays a window with the libraries that are available. Some standard libraries are available by default, but you can also include your own custom libraries. After libraries have been included, the VDM source will be added to your project in a "lib" folder.

Add Library

If you inspect the library files, you will notice that the body of many of these functions/operations is declared as "is not yet specified" but the actual functionality for all of these are located in jar files so the user can get access to this when the respective standard libraries are included.

Standard Libraries

  • IO: This library provides functionality for input and output from/to files and the standard console.
  • Math: This library provides functionality for standard mathematical functions such as sine and cosine.
  • VDM Util: This library provides functionality for converting different kinds of VDM values mainly to and from files and strings.
  • CSV: This library is an extension of the IO library which provides additional functionality for saving and reading VDM values to/from comma separate format used by excel spreadsheets.
  • VDM Unit: This library provides functionality for unit testing of VDM models similar to the well-known JUnit library

These libraries, except VDM Unit, are available for all VDM dialects. VDM Unit is object orientated thus it cannot be used with VDM-SL.

Custom Libraries

A custom library is expected to be located within a jar file. It can contain one or more libraries all described by a library.json file located in the META-INF directory of the jar. To see the structure of the library.json file, open the stdlib library jar that is included with the extension.

Note: Dependencies can be located either in the same jar as the library or in another included library jar.

See here for a guide on how to use VDM values in Java.

Including a custom library

To include a custom library the path to the library jar must be added in the settings (vdm-vscode.server.libraries.VDM-Libraries) and the extension must be reloaded. It is expected that the user keeps included custom libraries consistent with the project's high-precision setting (vdm-vscode.server.highPrecision).

Encoding

It is assumed that the VDM files in the library jars are UTF-8 encoded. However, when they are included in the project using VDM > Add VDM Library the encoding is converted into the encoding format specified by the VS Code encoding setting (files.encoding).