Module: Ibex::Frontend::AST::Node
- Included in:
- Alternative, Conversion, Convert, DisplayName, Empty, Expect, ExpectRR, Fragment, GrammarTest, Group, Include, InlineAction, Lexer, LexerRule, LexerState, NodeAnnotation, OnErrorReduce, Optional, Options, Parameter, ParameterizedReference, Plus, Precedence, PrecedenceLevel, Printer, Recovery, Root, Rule, SemanticType, SeparatedList, Star, Start, SymbolReference, Tokens, UserCode
- Defined in:
- lib/ibex/frontend/ast.rb
Overview
Adds deterministic, recursively serializable hashes to Struct nodes.
Instance Method Summary collapse
Instance Method Details
#to_h ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ibex/frontend/ast.rb', line 48 def to_h fields = each_pair.to_h { |name, value| [name, serialize(value)] } fields.delete(:aliases) if self.class.name.end_with?("::Tokens") && !fields[:aliases] if self.class.name.end_with?("::Root") fields.delete(:extended) unless fields[:extended] fields.delete(:cst) unless fields[:cst] end fields.delete(:node_annotation) if self.class.name.end_with?("::Alternative") && !fields[:node_annotation] { node: self.class.name.split("::").last }.merge(fields) end |