Class: Ibex::Runtime::CST::ParseMemo::Entry
- Inherits:
-
Object
- Object
- Ibex::Runtime::CST::ParseMemo::Entry
- Defined in:
- lib/json5/generated_parser.rb
Overview
Lightweight construction tree flattened once when a parse completes.
Constant Summary collapse
- EMPTY_CHILDREN =
empty_children.freeze
Instance Method Summary collapse
- #append_to(output) ⇒ Object
-
#initialize(state, children: EMPTY_CHILDREN, segment: nil) ⇒ Entry
constructor
A new instance of Entry.
Constructor Details
#initialize(state, children: EMPTY_CHILDREN, segment: nil) ⇒ Entry
Returns a new instance of Entry.
2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 |
# File 'lib/json5/generated_parser.rb', line 2987 def initialize(state, children: EMPTY_CHILDREN, segment: nil) @state = state @children = if children.empty? EMPTY_CHILDREN elsif children.frozen? children else children.dup.freeze end @segment = segment&.then { |values| values.frozen? ? values : values.dup.freeze } freeze end |
Instance Method Details
#append_to(output) ⇒ Object
3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 |
# File 'lib/json5/generated_parser.rb', line 3001 def append_to(output) segment = @segment if segment output.concat(segment) return end output << @state @children.each { |child| child.append_to(output) } end |