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

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

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.

RBS:

  • (grammar_digest: String, table_format: Integer, state_count: Integer, production_count: Integer, trivia_policy: Symbol, kinds: Kind, green_root: GreenNode, ?memo: ParseMemo?) -> void

Parameters:

  • grammar_digest: (String)
  • table_format: (Integer)
  • state_count: (Integer)
  • production_count: (Integer)
  • trivia_policy: (Symbol)
  • kinds: (Kind)
  • green_root: (GreenNode)
  • memo: (ParseMemo, nil) (defaults to: nil)


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_digestString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def grammar_digest
  @grammar_digest
end

#green_rootGreenNode (readonly)

Signature:

  • GreenNode

Returns:



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

def green_root
  @green_root
end

#kindsKind (readonly)

Signature:

  • Kind

Returns:



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

def kinds
  @kinds
end

#memoParseMemo? (readonly)

Signature:

  • ParseMemo?

Returns:



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

def memo
  @memo
end

#production_countInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def production_count
  @production_count
end

#state_countInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def state_count
  @state_count
end

#table_formatInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def table_format
  @table_format
end

#trivia_policySymbol (readonly)

Signature:

  • Symbol

Returns:

  • (Symbol)


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

def trivia_policy
  @trivia_policy
end

Instance Method Details

#syntax_rootSyntaxNode

RBS:

  • () -> SyntaxNode

Returns:



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