Next: , Previous: A Little Example, Up: Top


3 Fields and Records

A field is the written form of an association between a label and a value. For example, if we wanted to associate the label Name with the value Ada Lovelace we would write:

     Name: Ada Lovelace

The separator between the field name and the field value is a colon followed by a blank character (space and tabs, but not newlines). The name of the field shall begin in the first column of the line.

A field name is a sequence of alphanumeric characters plus dashes (-) and underscores (_), starting with a letter or the character %. The regular expression denoting a field name is:

     [a-zA-Z%][a-zA-Z0-9_-]+

Field names are case-sensitive. Foo and foo are considered different field names.

The following list contains valid field names (the final colon is not part of the names):

     Foo:
     foo:
     A23:
     ab1:
     A_Field:

The value of a field is a sequence of characters terminated by a single newline character (\n).

Sometimes a value is too long to fit in the usual width of terminals and screens. In that case, depending on the specific tool used to access the file, the readability of the data would not be that good. It is therefore possible to physically split a logical line by escaping a newline with a backslash character, as in:

     LongLine: This is a quite long value \
     composed by a unique logical line \
     split in several physical lines.

The sequence \n (newline) + (PLUS) and an optional _ (SPACE) is interpreted as a newline when found in a field value. For example, the C string "bar1\nbar2\n bar3" would be encoded in the following way in a field value:

     Foo: bar1
     + bar2
     +  bar3

A record is a group of one or more fields written one after the other:

     Name1: Value1
     Name2: Value2
     Name2: Value3

It is possible for several fields in a record to share the same name or/and the field value. The following is a valid record containing three fields:

     Name: John Smith
     Email: john.smith@foomail.com
     Email: john@smith.name

The size of a record is defined as the number of fields that it contains. There is no such like an empty record, so the minimum size for a record is 1. The maximum number of fields for a record is only limited by the available physical resources. The size of the previous record is 3.

Records are separated by one or more blank lines. For instance, the following example shows a file named personalities.rec featuring three records:

     Name: Ada Lovelace
     Age: 36
     
     Name: Peter the Great
     Age: 53
     
     Name: Matusalem
     Age: 969