This Page

syntax.relation

Defines classes for parsing and compiling relation declarations, which consist of a name, then a series of newline-separated box and connection declarations inside a block of curly braces. Shell-style comments (prefixed with #) may be included within the body:

name
{
    <box|connection>
    <box|connection>
    ...
    <box|connection>
}
class RelationSyntax(name, boxes, connections)[source]

Represents the abstract syntax of a relation constraint declaration, consisting of a name, a list of box syntax objects, and a list of connection syntax objects. Note that order is preserved among boxes and among connections respectively, but that the order of connections relative to boxes is insignificant.

__init__(name, boxes, connections)[source]

Initializes a new relation syntax object with the given name and the the provided box and connection structures.

__str__()[source]

Converts the syntax object into its raw string representation.

compile(relations)[source]

Checks and compiles this relation constraint from its abstract syntax into a new RelationDeclaration. object.

Parameters:relations – The list of relation declarations compiled so far. Used to resolve macro references.
Returns:the newly created relation declaration.
Raises :a CompilationError if any static checks fail.
classmethod parse(text)[source]

Parses the given input text to produce a new RelationSyntax object.

Returns:the newly created syntax object.
Raises :a ParsingError if syntax is invalid.
classmethod splitBodyLines(text)[source]

Given the input text for a relation constraint definition’s body, returns a list of the individual lines of that definition, omitting whitespace and comments.