include "cfg.m"; cfg := load Cfg Cfg->PATH; Attr: adt { name: string; value: string; }; Tuple: adt { lnum: int; attrs: list of Attr; lookup: fn(t: self ref Tuple, name: string): string; }; Record: adt { tuples: list of ref Tuple; lookup: fn(r: self ref Record, name: string) : (string, ref Tuple); }; init: fn(path: string): string; lookup: fn(name: string): list of (string, ref Record); getkeys: fn(): list of string;
Each line of the configuration file is comprised of a tuple of attributes. Comments are introduced by the '#' character and run to the end of the input line. Empty lines and comments are ignored.
An attribute has a name followed by an optional value. The value is specified by separating the name and value by an '=' character. Attribute names and values are input words. A word is delimited by spacing characters and the '=' character. If a word needs to include any of these characters then the word may be quoted using single or double quotes. The start and end quotes must be the same. The quoting character may be included in the word by appearing twice.
Examples:
'a b c' yields a b c "a b c" yields a b c 'a " c' yields a " c 'a '' c' yields a ' c
The name of the first attribute of a tuple is its key. The primary tuple value is the value of its first attribute.
Tuples whose first attribute name appears at the start of a line (having no preceeding spacing characters) are treated as the start of a new record. A record incorporates all tuples up to the start of the next record. The record key is defined to be the name of its first attribute. The primary record value is the value of the first attribute.
The adt types Attr, Tuple and Record are direct analogues of the constructs defined above.
CFG(2 ) | Rev: Tue Mar 31 02:42:39 GMT 2015 |