AstCount

Description

struct Tinman.Core.Parsing.AstCount

Defines the cardinality of AST nodes.

Based on the initial values Zero and One, the following cardinalities are possible when using Add and Or:
[0] : zero
[0..1] : zero or one
[0..n] : zero or more
[1] : one
[1..n] : one or more
[2..n] : two or more
The AstCount.ToString can be used to obtain the string representations mentioned above.

Public / Constants

One


public static readonly attribute One → (AstCount)

One AST node: [1]

Zero


public static readonly attribute Zero → (AstCount)

Zero AST nodes: [0]

Public / Methods

Add


public method Add → (1)

count in : AstCount

The AstCount to combine with.

returns → AstCount

The resulting AstCount value.

Combines this AstCount value with the given one.

The Add operation is commutative and defined as follows:

   Add | [1..n] | [0..1] |    [1] |    [0] | [2..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------
[1..n] | [2..n] | [1..n] | [2..n] | [1..n] | [2..n] | [1..n]
-------+--------+--------+--------+--------+--------+-------
[0..1] | [1..n] | [0..n] | [1..n] | [0..1] | [2..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------
   [1] | [2..n] | [1..n] | [2..n] |    [1] | [2..n] | [1..n]
-------+--------+--------+--------+--------+--------+-------
   [0] | [1..n] | [0..1] |    [1] |    [0] | [2..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------
[2..n] | [2..n] | [2..n] | [2..n] | [2..n] | [2..n] | [2..n]
-------+--------+--------+--------+--------+--------+-------
[0..n] | [1..n] | [0..n] | [1..n] | [0..n] | [2..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------

Or


public method Or → (1)

count in : AstCount

The AstCount to combine with.

returns → AstCount

The resulting AstCount value.

Combines this AstCount value with the given one.

The Or operation is commutative and defined as follows:

    Or | [1..n] | [0..1] |    [1] |    [0] | [2..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------
[1..n] | [1..n] | [0..n] | [1..n] | [0..n] | [1..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------
[0..1] | [0..n] | [0..1] | [0..1] | [0..1] | [0..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------
   [1] | [1..n] | [0..1] |    [1] | [0..1] | [1..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------
   [0] | [0..n] | [0..1] | [0..1] |    [0] | [0..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------
[2..n] | [1..n] | [0..n] | [1..n] | [0..n] | [2..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------
[0..n] | [0..n] | [0..n] | [0..n] | [0..n] | [0..n] | [0..n]
-------+--------+--------+--------+--------+--------+-------

Public / Attributes

IsZero


public attribute IsZero → (get)

value : bool

true if AstCount value is equal to Zero?,
false if it is different.

Does this AST node value represent a cardinality of zero?