Module Rascl


module Rascl: sig .. end
RASCL's A Simple Configuration Language. Rascl is an OCaml library for processing RASCL files.

Introduction

This document describes the OCaml Rascl API. For a description of RASCL itself, please see the RASCL language documentation. You should have received that documentation with this package; the latest version can be found at http://matt.gushee.net/rascl/.

This library, like the language, follows a minimalist philosophy. It makes no attempt at universality, but tries to provide a simple interface with a few very widely applicable features. Thus there are a number of features that, while potentially useful, are deliberately left out. In particular, Rascl does not deal with the locations of configuration files. It recognizes only a few simple data types, and does not support any form of scripting.

On the other hand, RASCL files should be easy to edit, even for people with minimal technical skills, and the Rascl API should be extremely simple to use.

There are two principal ways to access RASCL configuration data: the low level dictionary structure implemented in the Dict module, and a configuration object system, the foundation for which is provided in the ConfigObject module. Each has its advantages and disadvantages.

The object system provides a very concise syntax. For example, a 'color' property might be accessed as:

      config_object#color
    

Properties are also type-safe: each accessor method returns (or accepts, for set_* methods) one of the RASCL data types, as specified in the configuration template that you create.

On the other hand, using the object system requires that all property names be valid OCaml method names. There is also a potential problem with configuration files containing values of incorrect types. Such errors will not be discovered until the program attempts to retrieve the property from the object (as opposed to, say, failing when the file is loaded). At that point an exception will be raised and the property will be inaccessible until the file is corrected and reloaded.

The dictionary structure is lower-level and less convenient. To access the 'color' property as in the above example, you would write:

      Dict.get "color" config_dict
    
Another important difference is that dictionaries only provide access to data in the form of strings (or lists thereof), though this will likely change in the near future.

In exchange for less convenience, however, you gain significant flexibility. Dictionary keys, for example, can be arbitrary strings. You can also add and remove nested dictionaries, and even create new properties on the fly.

For further information, see the documentation for the Dict and ConfigObject modules.


module Dict: sig .. end
This module implements the fundamental data structure of RASCL: the dictionary.
module Parser: sig .. end
An ocamlyacc-based parser for RASCL files.
module Lexer: sig .. end
An ocamllex-based lexer for RASCL files.
module ConfigObject: sig .. end
This is a framework for the object-oriented interface to RASCL configurations.
val read_config_file : string -> Dict.t
read_config_file path parses the configuration file indicated by path and returns the resulting dictionary.