Class: Strling::Core::Alt
Overview
Represents an alternation (OR) operation in the AST.
Matches any one of the provided branches. Equivalent to the | operator in traditional regex syntax.
Instance Attribute Summary collapse
-
#branches ⇒ Array<Node>
The alternative branches.
Instance Method Summary collapse
-
#initialize(branches) ⇒ Alt
constructor
A new instance of Alt.
- #to_dict ⇒ Object
Constructor Details
#initialize(branches) ⇒ Alt
Returns a new instance of Alt.
111 112 113 |
# File 'lib/strling/core/nodes.rb', line 111 def initialize(branches) @branches = branches end |
Instance Attribute Details
#branches ⇒ Array<Node>
Returns The alternative branches.
108 109 110 |
# File 'lib/strling/core/nodes.rb', line 108 def branches @branches end |
Instance Method Details
#to_dict ⇒ Object
115 116 117 |
# File 'lib/strling/core/nodes.rb', line 115 def to_dict { 'kind' => 'Alt', 'branches' => branches.map(&:to_dict) } end |