Class: Strling::Core::IRGroup
Overview
Represents a capturing or non-capturing group in the IR.
Groups pattern elements together.
Instance Attribute Summary collapse
-
#atomic ⇒ Boolean?
Whether the group is atomic.
-
#body ⇒ IROp
The body of the group.
-
#capturing ⇒ Boolean
Whether the group is capturing.
-
#name ⇒ String?
The name of the group (for named captures).
Instance Method Summary collapse
-
#initialize(capturing, body, name: nil, atomic: nil) ⇒ IRGroup
constructor
A new instance of IRGroup.
- #to_dict ⇒ Object
Constructor Details
#initialize(capturing, body, name: nil, atomic: nil) ⇒ IRGroup
Returns a new instance of IRGroup.
271 272 273 274 275 276 |
# File 'lib/strling/core/ir.rb', line 271 def initialize(capturing, body, name: nil, atomic: nil) @capturing = capturing @body = body @name = name @atomic = atomic end |
Instance Attribute Details
#atomic ⇒ Boolean?
Returns Whether the group is atomic.
265 266 267 |
# File 'lib/strling/core/ir.rb', line 265 def atomic @atomic end |
#body ⇒ IROp
Returns The body of the group.
259 260 261 |
# File 'lib/strling/core/ir.rb', line 259 def body @body end |
#capturing ⇒ Boolean
Returns Whether the group is capturing.
256 257 258 |
# File 'lib/strling/core/ir.rb', line 256 def capturing @capturing end |
#name ⇒ String?
Returns The name of the group (for named captures).
262 263 264 |
# File 'lib/strling/core/ir.rb', line 262 def name @name end |
Instance Method Details
#to_dict ⇒ Object
278 279 280 281 282 283 284 285 286 287 |
# File 'lib/strling/core/ir.rb', line 278 def to_dict data = { 'ir' => 'Group', 'capturing' => capturing, 'body' => body.to_dict } data['name'] = name unless name.nil? data['atomic'] = atomic unless atomic.nil? data end |