Exemplo n.º 1
0
def NullField():
    """
    Create a null field.

    Null fields are valid only when they override an abstract field. They are a
    way to say that this field is absent on all concrete nodes that inherit
    this null field.
    """
    return _Field(null=True)
Exemplo n.º 2
0
def AbstractField(type, doc=''):
    """
    Create an abstract field.

    Concrete node subclasses must override all inherited abstract fields, and
    only concrete fields can override abstract fields. Abstract fields are
    useful to make syntax fields available in abstract nodes when these don't
    have the same field index in derived nodes.

    :param DSLType|CompiledType type: DSLType or CompiledType subclass for
        values this field holds.

    :param str doc: User documentation for this field.
    """
    return _Field(type=type, doc=doc, abstract=True)
Exemplo n.º 3
0
def Field(repr=True, doc='', type=None):
    """
    Create a field that is meant to store parsing results. Only AST nodes can
    hold such fields.

    :param bool repr: Whether the field will be displayed when pretty-printing
        the embedding AST node.

    :param str doc: User documentation for this field.

    :param DSLType|CompiledType|None type: DSLType or CompiledType subclass for
        values this field holds. If left to None, the type will be inferred
        from the grammar.
    """
    return _Field(repr, doc, type)