It supports two popular configuration formats - Apache and C-like, property substitution and file inclusion. It works with Unix, DOS and Mac files. Both formats are line-oriented, declaration may be continued at next line with '\' before new line.
Property substitution may be used in quoted and unquoted string
values. If property doesn't exists or its value is not a string, empty
string is silently substituted. Syntax - ${property_name}
.
config := decls decls := decl* decl := bool_decl | simple_decl | struct_decl | include_decl bool_decl := property_name : {property_name, true} | property_name = bool : {property_name, bool} bool := 'true' | 'false' | 'yes' | 'no' simple_decl := property_name '=' simple_value+ : {property_name, [simple_value+]} struct_decl := property_name property_attr* '{' decl* '}' : {property_name, [property_attr], [decl]} property_attr := simple_value include_decl := '$INCLUDE' string simple_value := string | integer | float | ipv4_address | ipv4_netmask property_name := squoted_string | atom_string string := unquoted_string | "double quoted string" | 'single quoted string'
config := decls decls := decl* decl := bool_decl | simple_decl | struct_decl | include_decl bool_decl := property_name : {property_name, true} | property_name = bool : {property_name, bool} | property_name bool : {property_name, bool} bool := 'true' | 'false' | 'yes' | 'no' simple_decl := property_name '=' simple_value+ | property_name simple_value+ : {property_name, [simple_value+]} struct_decl := '<'property_name property_attr* '>' decl* '<'/property_name'>' : {property_name, [property_attr], [decl]} property_attr := simple_value include_decl := 'Include' string simple_value := string | integer | float | ipv4_address | ipv4_netmask property_name := squoted_string | atom_string string := unquoted_string | "double quoted string" | 'single quoted string' ipv4_netmask := ipv4 '/' ipv4 : {ipv4, bitmask} | ipv4 '/' integer_mask : {ipv4, bitmask} integer_mask =< 32
Exported Functions | |
---|---|
format_error/1 | Format error returned by parse/3 . |
parse/2 | The same as parse/3 but with empty initial environment. |
parse/3 | Parse file and return result or error. |
format_error(Error::term()) -> string()
Format error returned by parse/3
parse(FileName::string(), Mode::mode()) -> Result | Error
The same as parse/3
but with empty initial environment
See also: parse/3
.
parse(FileName::string(), Mode::mode(), Env::env_list()) -> Result | {error, Error}
Parse file and return result or error. Error can be formatted
with format_error/1
. Env is a list of parameters which
can be substituted in properties values.