Module: Kumi::Syntax::Node
- Included in:
- ArrayExpression, CallExpression, CascadeExpression, CaseExpression, DeclarationReference, HashExpression, ImportCall, ImportDeclaration, InputDeclaration, InputElementReference, InputReference, Literal, Root, TraitDeclaration, ValueDeclaration
- Defined in:
- lib/kumi/syntax/node.rb
Overview
Base module included by all AST nodes to provide a standard interface for accessing source location information..
Instance Attribute Summary collapse
-
#hints ⇒ Object
Returns the value of attribute hints.
-
#loc ⇒ Object
Returns the value of attribute loc.
Instance Method Summary collapse
Instance Attribute Details
#hints ⇒ Object
Returns the value of attribute hints.
10 11 12 |
# File 'lib/kumi/syntax/node.rb', line 10 def hints @hints end |
#loc ⇒ Object
Returns the value of attribute loc.
10 11 12 |
# File 'lib/kumi/syntax/node.rb', line 10 def loc @loc end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kumi/syntax/node.rb', line 20 def ==(other) other.is_a?(self.class) && # for Struct-based nodes (if respond_to?(:members) members.all? { |m| self[m] == other[m] } else instance_variables.reject { |iv| iv == :@loc } .all? do |iv| instance_variable_get(iv) == other.instance_variable_get(iv) end end ) end |
#initialize(*args, hints: {}, loc: nil, **kwargs) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/kumi/syntax/node.rb', line 12 def initialize(*args, hints: {}, loc: nil, **kwargs) @loc = loc @hints = hints super(*args, **kwargs) freeze end |