Class: Ibex::Runtime::CST::SerializedTree

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/runtime/cst/serialized_tree.rb

Overview

Validated CST serialization document and its reconstructed Red root.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grammar_digest:, table_format:, state_count:, production_count:, trivia_policy:, kinds:, green_root:, memo: nil) ⇒ SerializedTree

Returns a new instance of SerializedTree.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 21

def initialize(grammar_digest:, table_format:, state_count:, production_count:, trivia_policy:, kinds:,
               green_root:, memo: nil)
  @grammar_digest = grammar_digest.dup.freeze
  @table_format = table_format
  @state_count = state_count
  @production_count = production_count
  @trivia_policy = trivia_policy
  @kinds = kinds
  @green_root = green_root
  @memo = memo
  freeze
end

Instance Attribute Details

#grammar_digestObject (readonly)

: String



9
10
11
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 9

def grammar_digest
  @grammar_digest
end

#green_rootObject (readonly)

: GreenNode



15
16
17
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 15

def green_root
  @green_root
end

#kindsObject (readonly)

: Kind



14
15
16
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 14

def kinds
  @kinds
end

#memoObject (readonly)

: ParseMemo?



16
17
18
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 16

def memo
  @memo
end

#production_countObject (readonly)

: Integer



12
13
14
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 12

def production_count
  @production_count
end

#state_countObject (readonly)

: Integer



11
12
13
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 11

def state_count
  @state_count
end

#table_formatObject (readonly)

: Integer



10
11
12
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 10

def table_format
  @table_format
end

#trivia_policyObject (readonly)

: Symbol



13
14
15
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 13

def trivia_policy
  @trivia_policy
end

Instance Method Details

#syntax_rootObject



35
36
37
38
39
40
# File 'lib/ibex/runtime/cst/serialized_tree.rb', line 35

def syntax_root
  source = SourceText.new(@green_root.to_source)
  SyntaxNode.new(
    green: @green_root, kinds: @kinds, trivia_policy: @trivia_policy, source_text: source
  )
end