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:
[?] : unknown
[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]

Unknown


public static readonly attribute Unknown → (AstCount)

Unknown AST node count: [?]

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 |    [?] |    [0] | [0..1] | [0..n] |    [1] | [1..n] | [2..n]
-------+--------+--------+--------+--------+--------+--------+-------
   [?] |    [?] |    [?] | [0..1] | [0..n] |    [1] | [1..n] | [2..n]
-------+--------+--------+--------+--------+--------+--------+-------
   [0] |    [?] |    [0] | [0..1] | [0..n] |    [1] | [1..n] | [2..n]
-------+--------+--------+--------+--------+--------+--------+-------
[0..1] | [0..1] | [0..1] | [0..n] | [0..n] | [1..n] | [1..n] | [2..n]
-------+--------+--------+--------+--------+--------+--------+-------
[0..n] | [0..n] | [0..n] | [0..n] | [0..n] | [1..n] | [1..n] | [2..n]
-------+--------+--------+--------+--------+--------+--------+-------
   [1] |    [1] |    [1] | [1..n] | [1..n] | [2..n] | [2..n] | [2..n]
-------+--------+--------+--------+--------+--------+--------+-------
[1..n] | [1..n] | [1..n] | [1..n] | [1..n] | [2..n] | [2..n] | [2..n]
-------+--------+--------+--------+--------+--------+--------+-------
[2..n] | [2..n] | [2..n] | [2..n] | [2..n] | [2..n] | [2..n] | [2..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 |    [?] |    [0] | [0..1] | [0..n] |    [1] | [1..n] | [2..n]
-------+--------+--------+--------+--------+--------+--------+-------
   [?] |    [?] |    [?] | [0..1] | [0..n] |    [1] | [1..n] | [2..n]
-------+--------+--------+--------+--------+--------+--------+-------
   [0] |    [?] |    [0] | [0..1] | [0..n] | [0..1] | [0..n] | [0..n]
-------+--------+--------+--------+--------+--------+--------+-------
[0..1] | [0..1] | [0..1] | [0..1] | [0..n] | [0..1] | [0..n] | [0..n]
-------+--------+--------+--------+--------+--------+--------+-------
[0..n] | [0..n] | [0..n] | [0..n] | [0..n] | [0..n] | [0..n] | [0..n]
-------+--------+--------+--------+--------+--------+--------+-------
   [1] |    [1] | [0..1] | [0..1] | [0..n] |    [1] | [1..n] | [1..n]
-------+--------+--------+--------+--------+--------+--------+-------
[1..n] | [1..n] | [0..n] | [0..n] | [0..n] | [1..n] | [1..n] | [1..n]
-------+--------+--------+--------+--------+--------+--------+-------
[2..n] | [2..n] | [0..n] | [0..n] | [0..n] | [1..n] | [1..n] | [2..n]

Public / Attributes

Is​Unknown


public attribute IsUnknown → (get)

value : bool

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

Does this AST node value represent an unknown cardinality?

Is​Zero


public attribute IsZero → (get)

value : bool

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

Does this AST node value represent a cardinality of zero?