Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

God Logo

God, a language for good ol' data

Data serialization can be better, without being too much.

{
  name = "Will";
  age = 26;
  married = false;

  favorite-movies = [
    {
      title = "Interstellar";
      starring = [
        "Matthew McConaughey"
        "Jessica Chastain"
        "Anne Hathaway"
      ];
      director = "Christopher Nolan";
      year = 2014;
    }
    {
      title = "Kill Bill: Volume 1";
      director = "Quinten Tarantino";
      starring = [
        { actor = "Uma Thurman"; character = "The Bride"; }
        { actor = "Lucy Liu"; character = "O-Ren Ishii"; }
        { actor = "David Carradine"; character = "Bill"; }
      ];
      year = 2003;
    }
    {
      title = "The Witch";
      director = "Robert Eggers";
      starring = [ "Anya Taylor-Joy" "Ralph Ineson" ];
      year = 2015;
    }
  ];

  friends = [
    {
      name = "Floyd";
      age = 29;
      married = true;
      favorite-movies = [
        {
          title = "The Departed";
          starring = [ "Leonardo DiCaprio" "Vera Farmiga" "Matt Daemon" ];
          director = "Martin Scorsese";
          year = 2006;
        }
        {
          title = "Shutter Island";
          starring = [ "Leonardo DiCaprio" "Mark Ruffalo" ];
          director = "Martin Scorsese";
          year = 2010;
        }
      ];
      friends = [];
    }
  ];
}

About

God is a flexible, easy to read/write/implement data serialization format derived from the Nix programming language. It is structured around basic data structures which can be found (in some form or another) in roughly any programming language.

It can effectively represent any data that can be represented in JSON, all while being easier to read and write due to a number of design choices.

Why?

As someone who has found themself needing to manually write and programatically work with data serialization formats, I wanted a better way. I tried many formats: JSON, YAML, TOML, CSV, XML, KDL, Lua tables, Java properties, and others. You name it, I tried it. Many of them had enough nagging issues to cause motivation in me to find a better format, which never arose.

"But JSON works fine"

Have you ever been in the position of writing JSON, rather than just having a library parse it? If you haven't; then yes that's a logical conclusion. Personally, I find myself in a position where I need to write data manually, and many of the popular formats make that experience have more friction than it should. For those that may need a data serialization format, but never (or rarely) have to deal directly with the data in its storage format, it may seems like nit-picking; however it becomes different when you find yourself manually writing in these formats.

Background

If you feel that God syntax is familiar, that's probably because it is.
God isn't a new syntax; it is derived directly from the Nix programming
language. Any valid God code can be validated directly by Nix, with
nix eval -f file.god. It is a subset of Nix which omits it's programming
syntax and dynamic features in favor of static data representation.

Benefits

  • Validation and JSON conversion with the nix eval
  • A number of existing tools for working with Nix code
  • A thorough Emacs mode
  • Static analyzers and linters such as statix
  • Language servers such as nixd and nil

Purpose

I'd say that God has about the same purpose as other serialization formats,
though we take a different approach to specification than most. The main goal
is to be as useful as possible to as many languages as possible, which is
not a goal you obtain by making an overly-complicated and restrictive spec.

If you would like to see some sample document files, see the examples page.

Implementations

Libgod, the official implementation

Written in C++, it can be found at wreedb/libgod.

Tree-sitter Grammar

With a bit of configuration, it can be used within both Neovim and Emacs for
syntax highlighting and indentation! wreedb/tree-sitter-god.

Note

If you have decided to implement the language, please contact me!

The Specification

Below you can navigate and learn about the various components that comprise
the language.

Value Types

File Structure

Values

The value types in GOD are intentionally rudimentary, with the goal of being useful to almost any programming language. They are flexible and have few restrictions.

Index

Strings

Strings in God must be valid UTF-8, and this validation should be done by the implementer. For compliance with this specification, a lack of this behavior for any reason (technical limitation or otherwise) MUST be documented.

Standard Strings

Represented by a pair of double quotes with any amount of (valid UTF-8) text inside it.

greeting = "Hello, how are you?";

Multi-line

Strings that span across multiple lines are supported. They are declared using
two sets of single quotes; one at the beginning and one at the end.

about-me = ''
  Let me tell you
  about myself!
'';

Note

Multi-line string are also indentation aware; The indentation of the contained string is calculated relative to the furthest left column which contains meaningful (non-whitespace) text.

my-string = ''
    There are four spaces before this,
      but the they will not be preserved.
'';
# produces:
# "There are four spaces before this,\n  but they will not be preserved.\n"

Escaping

Yog can escape (double) quotes in a regular string using a backslash (\) before it. This is the same for line-feeds, carriage returns and tab characters (\n,\r,\t). To escape any character, prefix it with ''\

height = "6'2\"\n";
# produces:
# 6'2"\n
greeting = ''
  I said ''\'Hello!''\'
    to them.
'';
# produces:
# "I said 'Hello!'"\n  to them."

Additional notes

Unlike in Nix, there is no string interpolation here. The data represented
is purely static, and the implementater should have to do no computation
or transformation of values.

Numbers

Numbers in God are neither specifically intergers, doubles nor floats. They can be any of them; In Nix, integers have an upper and lower boundary of 9223372036854775807 and -9223372036854775807 respectively, as they are two's complement signed integers. God mimics this behavior, albeit slightly simpler due to all data here being completely static.

age = 26;
age-negative = -26;
pi = 3.14;
pi-negative = -3.14;

Important

Not all programming languages can represent these limits effectively; therefore the implementer should document any deviations from these limits clearly for their users.

If the technical details needed for proper usage are not documented by the implementation, the implementation MAY NOT claim to be compliant with this specification.

In practice, a number is a sequence of one or many numeric digits, it may be used with a leading negation operator for negative numbers.

my-numbers = [ 1 2 3 -4 -516.8 ];

Note that unlike in Nix, exponent notation is not valid; God is intended to be a completely static format. For exponential numeric values to be useful, they would need to be computed by the parser, which is not something God intends to do. If exponent notation is needed, it should be written as a string value and computed by other means.

Booleans

Boolean values in God are written as the unquoted text true and false. As in almost any context related to computer science, booleans are a data type used to describe something that has one of two possible values; most commonly true/false and 1/0.

yes = true;
no = false;

Some languages may have unconventional boolean data types, and therefore the implementer may want to use the closest analogue in their language, for example, in Emacs Lisp:

(setq foo t)
(setq bar nil)

There is not false boolean type in the language. There is t to represent a truthy value, and the nil keyword is often used in place of a falsy value.

Warning

Due to the permissiveness of identifiers in God (as well as in Nix), it is completely valid to use true, false and even null as identifiers.

true = false;
false = null;

Using identifiers that use the same name as built-in language types is highly discouraged for obvious reasons, however they are documented here for the purposes of completeness.

Null

Written as the unquoted text null, this value represents nothing.

This may correlate to a languages' null value, or represent the absence of a value in languages which do not have a null type. In some languages this may be best represented by 0 or an empty list ('()) as in some lisp style languages.

nothing = null;

It is at the discretion of the implementer to decide what makes the most sense for their use case and the capabilities of their language.

As described in booleans, null is able to be used as an identifier, though highly discouraged.

Maps

A map in God is a data structure that has an analogue in practically every programming language; Lua tables, Python dictionaries, Perl hash slices, (Type/Java)script objects, Lisp and Scheme association lists, and Java HashMaps just to name a few.

The commonality is the structure of an identifier which is assigned a group of fields. Fields can be seen as key-value pairs in an abstract sense.

In God specifically, they are delimited by opening and closing "curly" braces ({ }). When they are used as just a field, they must be use a termination operator; when used as an element, only any fields within it will require termination.

me = {
    name = "Will";
    age = 26;
    married = false;
    favorite-songs = [
        { artist = "Slint"; title = "Nosferatu Man"; }
        { artist = "OutKast"; title = "Hey Ya!"; }
    ];
    best-friend = {
        name = "Floyd";
        age = 29;
        married = true;
        favorite-songs = [
            { artist = "Tool"; title = "Lateralus"; }
            { artist = "Deafheaven"; title = "Dream House"; }
        ];
    };
};

Any type of field is allowed within a map, so long as it follows any necessary rules of field termination.

Warning

Repeated use of the same identifier name in the same scope will result in the last occurrence determining its' value.

me = {
    name = "Will";
    age = 26;
    age = 27; # 27 will 'overwrite' the previous value
};

Lists

These are a grouping of any number of elements. They may be the element assigned to a field, or nested within another list as one of its' elements. They are delimited by opening and closing "square" brackets ([ ]). The elements contained are separated by whitespace.

They have no strict type requirements for their elements, meaning it can hold numbers, strings, maps and other lists.

favorite-movies = [
    "Interstellar"
    "The Witch"
    "Kill Bill Vol. 1"
];

list-of-lists = [
    [ 1 2 3 ]
    [ true false null ]
    [ "foo" "bar" ]
    [
        { name = "Will"; age = 26; }
        { name = "Floyd"; age = 29; }
    ]
];

Note

As you can see in the above examples, field termination is required when within the fourth list-of-list element, since maps contain fields; but the maps themselves are only elements, meaning they do not require field termination. For more clarification, see maps and fields.

Structure

Document

The document is used to describe the starting and ending boundaries of data in a God file. It is delimited by opening and closing "curly" braces ({ }). There can only be one set of document-level delimiters in a God file.

{ # document begins here
    name = "Will";
    hobbies = [ "Programming" "Watching Movies" "Playing Video Games" ];
} # document ends here

Within a document, any number of fields are allowed in any order at any level of depth.

Note

The document is not a field, therefore it does not use a field termination operator.

As stated above, only one document-level set of delimiters are allowed, meaning the following example is invalid:

{
    name = "Will";
}
{
    age = 26;
}

Operators

The following symbols are operators in God:

Assignment

This is the operator that denotes an identifier being assigned a value. It is written as an equal sign.

thing = "value";

Termination

These are the integral final part of a field; distinguishing where a given field ends. They are are required to terminate all fields. They are written as a semi-colon.

numbers = { one = 1; two = 2; three = 3; };

Negation

These are used as a prefix to number values; denoting the negativity of the number in question.

negative-numbers = [ -1 -2 -3 -3.14 ];
positive-numbers = [ 1 2 3 3.14 ];

Elements

An element is a raw value, either as a the assigned value of a field, or an item in a list. They can be any of the fundamental data types.

things = [ 
    "string"
    1
    null
    false
    ''
      Multi-line
      string
    ''
    [ "another" "list" ]
    { text = "another map"; }
];

In the above example, the only parts which are not elements are the two identifiers things and text, everything else is an element, including the map that contains the text identifier and the list that the things identifier is assigned to.

Identifiers

Identifiers are unquoted text denoting the name or identity of a field. The rules governing what an identifier is allowed to be are as follows:

They may consist solely of:

  • Letters: A-Z a-z
  • Numbers: 0-9
  • Underscores: _
  • Hyphens: -
  • Single quotes: '

However, the first character of an identifier must be a letter or underscore. No other characters are permitted.

Examples of VALID identifiers

{
    my-list = [];
    my_list = [];
    _my_list_ = [];
    my-list- = [];
    my'list' = [];
}

Examples of INVALID identifiers

{
    'my-list = [];
    -my-list = [];
    1my-list = [];
}

Warning

The use of non-ASCII Unicode characters (emojis, non-Latin characters, accented characters, etc.) in identifiers is invalid.

Fields

These are the most common and fundamental pieces of data in the language.

They are a combination of four parts:

name = "Will";
favorite-things = [ "Movies" "Programming" ];
favorite-movie = {
    title = "Interstellar";
    director = "Christopher Nolan";
    release-year = 2014;
    leading-roles = [
        {
            character = "Joseph Cooper";
            actor = "Matthew McConaughey";
        }
        {
            character = "Dr. Amelia Brand";
            actor = "Anne Hathaway";
        }
    ];
};

In this example, there are 11 fields in total. Let's break down the biggest one:

favorite-movie = {
    title = "Interstellar";
    director = "Christopher Nolan";
    release-year = 2014;
    leading-roles = [
        {
            character = "Joseph Cooper";
            actor = "Matthew McConaughey";
        }
        {
            character = "Dr. Amelia Brand";
            actor = "Anne Hathaway";
        }
    ];
};

Here, there are nine total fields including the favorite-movies map. Within it, there are eight fields:

identifierassigned value
titlestring "Interstellar"
directorstring "Christopher Nolan"
release-yearnumber 2014
leading-rolesan list containing two maps as elements

The first element of leading-roles:

identifierassigned value
characterstring "Joseph Cooper"
actorstring "Matthew McConaughey"

The second element of leading-roles

identifierassigned value
characterstring "Dr. Amelia Brand"
actorstring "Anne Hathaway"

Important

It is an important distiction that the two elements within the leading-roles list are NOT fields; they are elements that contain fields.

Whitespace

The following are considered whitespace in God:

namevalue
space characters\x20
tab characters\t
line-feed (LF)\n
carriage-return (CR)\r
commentsVaried

The only context in which whitespace is meaningful is within lists,
where it is used to separate elements.

Comments

Comments in God only come in one variety, line comments:

# this is a line comment, occupying an entire line.
name = "Will"; # this is another line comment, occupying only the end of the line

Despite Nix supporting multi-line and mid-statement comments, God does not. In practice, any meaning that can be conveyed through comments can be conveyed well enough by line comments (whether they occupy a full line or only the end of one), making the other types unnecessary.

Terminology explanation

Terminology regarding comments has garnered a lot of misconception; so in an effort to make it perfectly clear, here are the different types of comments, using C as the language to demonstrate.

Multi-line "Block" comments:

int main() {
    /* this is foo
     * it equals two
     * */
    int foo = 2;
    return 0;
}

Line comments:

int main() {
    // this is foo
    int foo = 2; // it equals two
    return 0;
}

Mid-statement comments:

int main() {
    int /* this is foo, it equals two */ foo = 2;
    return 0;
}

As stated above, God only supports line comments, the other types are invalid.

Grammars

This specification provides two formal grammars:

ABNF Format

EBNF Format

Formal ABNF (Augmented Backus-Naur Form) Grammar

ALPHA  = %x41-5A / %x61-7A
DIGIT  = %x30-39
DQUOTE = %x22
SP     = %x20
TAB    = %x09
CR     = %x0D
LF     = %x0A

; whitespace
WSP      = SP / TAB
line-end = CRLF / LF
blank    = WSP / line-end
comment  = "#" *(%x09 / %x20 / %x21-7E) line-end
ws       = *(blank / comment)  ; optional
mws      = 1*(blank / comment) ; mandatory

; the document
document = ws "{" ws *field ws "}" ws

; identifiers
identifier = identifier-begin *identifier-contents
identifier-begin = ALPHA / "_"
identifier-contents = ALPHA / DIGIT / "_" / "-" / "'"

; Field: { ident -> assign -> element -> termination }
field = identifier ws "=" ws element ws ";" ws

; Element: one of [string|multi-line string|list|map|number|boolean|null]
element = string / multiline-string / list / map / number / boolean / null

; Map: sequence of zero to any number of fields
map = "{" ws *field ws "}"

; List: sequence of zero to any number of elements
list = "[" ws [list-items] ws "]"
list-items = element *(mws element)

; String: Any valid UTF-8 text content enclosed within
;         double quotes, can span multiple lines, but are
;         not indentation aware like multi-line strins are.
string = DQUOTE *chars DQUOTE
chars = string-escape / string-literal
string-escape = "\" (DQUOTE / "\")
string-literal = %x09 / %x0A / %x0D / %x20-21 / %x23-5B / %x5D-7E / %x80-10FFFF

;; NOTES {multi-line string}:
;;   Escape sequences are initiated by the sequence `''\`, followed by
;;   any (single) valid UTF-8 character, sequences that are otherwise
;;   transformed include only the following:
;; ______________________________
;; | sequence | result          |
;; |__________|_________________|
;; | `''\n`   | line feed       |
;; | `''\r`   | carriage return |
;; | `''\t`   | tab character   |
;; |____________________________|
;;
;; Other than those displayed in this table are treated generically as
;; the raw character alone.

multiline-string  = "''" *multiline-chars "''"
multiline-chars   = multiline-escape / multiline-literal
multiline-escape  = "''" "\" UTF8-char
multiline-literal = %x09 / %x0A / %x0D / %x20-7E / %x80-10FFFF

UTF8-char = %x09 / %x0A / %x0D / %x20-7E    ; ASCII printable + whitespace
          / %xC2-DF %x80-BF                 ; 2-byte UTF-8
          / %xE0    %xA0-BF %x80-BF         ; 3-byte UTF-8 (E0)
          / %xE1-EC %x80-BF %x80-BF         ; 3-byte UTF-8 (E1–EC)
          / %xED    %x80-9F %x80-BF         ; 3-byte UTF-8 (ED, excl. surrogates)
          / %xEE-EF %x80-BF %x80-BF         ; 3-byte UTF-8 (EE–EF)
          / %xF0    %x90-BF %x80-BF %x80-BF ; 4-byte UTF-8 (F0)
          / %xF1-F3 %x80-BF %x80-BF %x80-BF ; 4-byte UTF-8 (F1–F3)
          / %xF4    %x80-8F %x80-BF %x80-BF ; 4-byte UTF-8 (F4, up to U+10FFFF)

; Numbers:
;; integers: optionally negated digit sequence
;; decimals: optionally negated digit sequence with one decimal point
number = ["-"] (decimal / integer)
integer = "0" / (non-zero *DIGIT)
decimal = [integer] "." 1*DIGIT
non-zero = %x31-39

;; NOTES {Boolean/Null}:
;;   It is not possible to clearly define (in a context-free grammar)
;;   that these are also valid when used as identifiers. This is highly
;;   discouraged in practice but should be noted.
boolean = "true" / "false"
null = "null"

Formal EBNF (Extended Backus-Naur Form) Grammar

ALPHA = "A".."Z" | "a".."z" ;
DIGIT = "0".."9" ;
DQUOTE = '"' ;
SP = " " ;
TAB = ? U+0009 ? ;
CR  = ? U+000D ? ;
LF  = ? U+000A ? ;

WSP = SP | TAB ;
line_end = (CR , LF) | LF ;
blank = WSP | line_end ;
comment = "#" , { ? U+0009 | U+0020-U+007E ? } , line_end ;
ws      = { blank | comment } ;
mws     = (blank | comment) , { blank | comment } ;

document = ws , "{" , ws , { field } , ws , "}" , ws ;

identifier = identifier_begin , { identifier_contents } ;

identifier_begin = ALPHA | "_" ;
identifier_contents = ALPHA | DIGIT | "_" | "-" | "'" ;

field =
    identifier
  , ws
  , "="
  , ws
  , element
  , ws
  , ";"
  , ws ;

element =
    string
  | multiline_string
  | list
  | map
  | number
  | boolean
  | null ;

map = "{" , ws , { field } , ws , "}" ;

list =
    "["
  , ws
  , [ list_items ]
  , ws
  , "]" ;

list_items = element , { mws , element } ;

string = DQUOTE , { chars } , DQUOTE ;

chars = string_escape | string_literal ;

string_escape = "\" , ( DQUOTE | "\" ) ;

string_literal =
    ? U+0009 | U+000A | U+000D
    | U+0020–U+0021
    | U+0023–U+005B
    | U+005D–U+007E
    | U+0080–U+10FFFF ? ;

multiline_string = "''" , { multiline_chars } , "''" ;

multiline_chars = multiline_escape | multiline_literal ;

multiline_literal = 
    ? U+0009 | U+000A | U+000D
    | U+0020-U+007E
    | U+0080-U+10FFFF ? ;


UTF8_char =
      ? U+0009 
      | U+000A
      | U+000D
      | U+0020–U+007E ?
    | ? 2-byte UTF-8 sequence ?
    | ? 3-byte UTF-8 sequence (excluding surrogates) ?
    | ? 4-byte UTF-8 sequence up to U+10FFFF ? ;

number = [ "-" ] , ( decimal | integer ) ;
integer = "0" | ( non_zero , { DIGIT } ) ;
decimal = [ integer ] , "." , DIGIT , { DIGIT } ;

non_zero = "1".."9" ;

boolean = "true" | "false" ;
null = "null" ;

Gotchas

Some specific things are not easy to describe in just text with a couple examples; therefore this section is for such topics that I feel could use a more thorough or visual discussion.

Field termination within lists

In a list, there are only elements, however, due to the fact that a map is an element, and can contain fields, this leads to:

{
    my-list = [
        {
            something = "foo";
        }
    ]
}

As you can see in the above example, the context is important. my-list has only one element, being a map. As noted in the specification, a map is a container for fields, so any fields within that map need field terminators.

However as you may also notice, the map itself is not terminated, due to it being only an element! It may be useful to think of it as:

Does this value have an identifier (name)?

If it does, it's part of a field; if not, it is an element.

The 'document'

The document is the outer enclosing braces, one at the beginning denotes the start, and the other denotes the end. Strictly speaking, this language could have dropped these from the spec, given that unlike in Nix, they aren't actually necessary here. They have however been kept as part of God for a few reasons:

  • They help simplify the creation of parsers, offering an unambiguous beginning and end
  • JSON data often is also enclosed within an outer set of braces, so it may familiar to those who are used to JSON.

Examples

These can all be found in the example/ directory of the project's Git repository.


simple.god

{
    name = "Will";
    age = 26;
    numbers = [ 9 -45 3.14 ];
    special = {
        yes = true;
        no = false;
        none = null;
    };
    
    long-string = ''
        Hello
        there!
    '';
}

package.god

{
    name = "shepherd";
    version = "1.0.5";
    licensing = [ "GPL-3.0-or-later" ];
    
    links = {
        home = "https://gnu.org/software/shepherd";
        repo = "https://codeberg.org/shepherd/shepherd.git";
    };
    
    tag = {
        release = true;
        name = "v1.0.5";
    };

    foreign = [
        "usr/share/doc/shepherd-1.0.5"
        "usr/share/guile/site/3.0/shepherd"
        "usr/lib/guile/3.0/site-ccache/shepherd"
        "usr/libexec/shepherd"
    ];
}

types.god

{
    name = "Will";
    nums = [ 1 2 3 true false null "string" ];

    mapping = { age = 26; };

    yes = true;
    no = false;
    nothing = null;

    things = {
        one = true;
        zero = false;
        nada = null;
        list = [ true false null "string" 1 2 3 { map = "self"; catch = 22; lie = true; } ];
    };

    list-of-maps = [
        {
            string-with-escapes = "\"\\there should be a single slash at the beginning when interpreted and this would be entirely quoted and\r\n\tindented on a new line here as well.\"";
            list-within-map-within-list = [ 1 2 3 true false null "\"escaped quotes\"" ];
        }
        {
            more = "less";
        }
    ];

}

directions.god

{
    directions = [
        {
            name = "north";
            cardinal = true;
        }
        {
            name = "east";
            cardinal = true;
        }
        {
            name = "west";
            cardinal = true;
        }
        {
            name = "south";
            cardinal = true;
        }
        {
            name = "down";
            cardinal = false;
        }
    ];
}

deep.god

{
    user = {
        name = "Will";
        age = 26;
        married = false;
        friends = [
            {
                name = "Floyd";
                age = 29;
                married = true;
                favorite-numbers = [ 1 2 -3.14 false null true "Hello!" 69 ];
                qualities = {
                    emotional = [ "patient" 1 "nice" null ];
                };
            }
        ];
    };
}

complex.god

{
    name = "Will";
    age = 26;
    married = false;
    favorite-movies = [
        {
            title = "Interstellar";
            director = "Christopher Nolan";
        }
        {
            title = "Kill Bill Volume 1";
            director = "Quinten Tarantino";
        }
    ];
    friends = [
        {
            name = "Floyd";
            age = 29;
            married = false;
            favorite-movies = [
                {
                    title = "Training Day";
                    director = null;
                }
                {
                    title = "The Departed";
                    director = "Martin Scorcese";
                }
            ];
            friends = [];
        }
    ];
}

string-escapes.god

{
    string = "normal string";
    special-strings = [
        "\"\\entirely quoted with a single slash at the start and\r\n\tnewline + indent here.\""
        "\" \\ this should quoted with slashes on both sides \\ \""
        "\\tabs\t\\and\t\\slashes\t\\with\t\\every\t\\word."
        "\nline-feeds above and below\n"
        "\r\ncarriage-return/line-feeds above and below\r\n"
        "\rcarriage-returns on both sides\r"
    ];
}

Contact

If you have any questions about the spec, implementing it or otherwise, you can contact me by email at wreed@disroot.org.

You may also find me on BlueSky at wreedb.bsky.social

GNU Free Documentation License

Version 1.3, 3 November 2008

Copyright (C) Will Reed wreed@disroot.org

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

0. PREAMBLE

The purpose of this License is to make a manual, textbook, or other functional and useful document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

1. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not "Transparent" is called "Opaque".

Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.

The "publisher" means any person or entity that distributes copies of the Document to the public.

A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when you modify the Document means that it remains a section "Entitled XYZ" according to this definition.

The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.

2. VERBATIM COPYING

You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and you may publicly display copies.

3. COPYING IN QUANTITY

If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

4. MODIFICATIONS

You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

  • A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
  • B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
  • C. State on the Title page the name of the publisher of the Modified Version, as the publisher.
  • D. Preserve all the copyright notices of the Document.
  • E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
  • F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
  • G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.
  • H. Include an unaltered copy of this License.
  • I. Preserve the section Entitled "History", Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
  • J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
  • K. For any section Entitled "Acknowledgements" or "Dedications", Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
  • L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
  • M. Delete any section Entitled "Endorsements". Such a section may not be included in the Modified Version.
  • N. Do not retitle any existing section to be Entitled "Endorsements" or to conflict in title with any Invariant Section.
  • O. Preserve any Warranty Disclaimers.

If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.

You may add a section Entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

5. COMBINING DOCUMENTS

You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections Entitled "History" in the various original documents, forming one section Entitled "History"; likewise combine any sections Entitled "Acknowledgements", and any sections Entitled "Dedications". You must delete all sections Entitled "Endorsements".

6. COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

7. AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.

8. TRANSLATION

Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.

9. TERMINATION

You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.

However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.

10. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See https://www.gnu.org/licenses/.

Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Document.

11. RELICENSING

"Massive Multiauthor Collaboration Site" (or "MMC Site") means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A "Massive Multiauthor Collaboration" (or "MMC") contained in the site means any set of copyrightable works thus published on the MMC site.

"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.

"Incorporate" means to publish or republish a Document, in whole or in part, as part of another Document.

An MMC is "eligible for relicensing" if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.

The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

    Copyright (C)  YEAR  YOUR NAME.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU
    Free Documentation License".

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the "with … Texts." line with this:

    with the Invariant Sections being LIST THEIR TITLES, with the
    Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.