Class: BELParser::Language::Semantics::SemanticEncodingOf
- Inherits:
-
SemanticASTNode
- Object
- AST::Node
- SemanticASTNode
- BELParser::Language::Semantics::SemanticEncodingOf
- Defined in:
- lib/bel_parser/language/semantics_ast.rb
Overview
AST node for EncodingOf is a semantic AST.
Instance Attribute Summary
Attributes inherited from AST::Node
Instance Method Summary collapse
-
#initialize(encodings, **properties) ⇒ SemanticEncodingOf
constructor
A new instance of SemanticEncodingOf.
- #match(value_node, spec, will_match_partial = false) ⇒ Object
- #match_encoding ⇒ Object
Methods inherited from SemanticASTNode
Methods inherited from AST::Node
#==, #append, #concat, #dup, #eql?, #inspect, #to_a, #to_ast, #to_bel, #to_s, #to_sexp, #updated
Methods included from Parsers
Constructor Details
#initialize(encodings, **properties) ⇒ SemanticEncodingOf
Returns a new instance of SemanticEncodingOf.
609 610 611 |
# File 'lib/bel_parser/language/semantics_ast.rb', line 609 def initialize(encodings, **properties) super(:encoding_of, encodings, properties) end |
Instance Method Details
#match(value_node, spec, will_match_partial = false) ⇒ Object
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
# File 'lib/bel_parser/language/semantics_ast.rb', line 617 def match(value_node, spec, will_match_partial = false) unless value_node.respond_to?(:encoding) && value_node.encoding return invalid_encoding_warning(value_node, spec, match_encoding) end input = value_node.encoding match = match_encoding enc_match = input.product(match).any? do |(value_enc, match_enc)| value_enc.subtype_of?(match_enc) end if enc_match success(value_node, spec) else invalid_encoding_warning(value_node, spec, match_encoding) end end |
#match_encoding ⇒ Object
613 614 615 |
# File 'lib/bel_parser/language/semantics_ast.rb', line 613 def match_encoding children end |