Class: ShEx::Algebra::SemAct
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/semact.rb
Constant Summary collapse
- NAME =
:semact
Constants inherited from Operator
Constants included from SPARQL::Algebra::Expression
SPARQL::Algebra::Expression::PATTERN_PARENTS
Constants included from RDF::Util::Logger
Instance Attribute Summary
Attributes inherited from Operator
#id, #logger, #operands, #options, #schema
Class Method Summary collapse
-
.from_shexj(operator, **options) ⇒ Operator
Creates an operator instance from a parsed ShExJ representation.
Instance Method Summary collapse
-
#enter(code, arcs_in, arcs_out, logging) ⇒ Boolean
Called on entry.
-
#exit(code: nil, matched: [], unmatched: [], depth: 0, **options)
Called on exit from containing TripleExpression.
-
#satisfies?(focus, matched: [], unmatched: [], depth: 0) ⇒ Boolean
The evaluation semActsSatisfied on a list of SemActs returns success or failure.
-
#semact? ⇒ Boolean
Does This operator is SemAct.
Methods inherited from Operator
#base_uri, #closed?, #dup, #each_descendant, #eql?, #expression, #expressions, #find, #focus, #focus=, #initialize, #inspect, #iri, iri, #json_type, #matched, #matched=, #message, #message=, #not_matched, #not_satisfied, #operand, #parent, #parent=, #references, #satisfied, #satisfied=, #satisfy, #semantic_actions, #serialize_value, #status, #structure_error, #to_h, #to_json, #to_sxp, #to_sxp_bin, #triple_expression?, #unmatched, #unmatched=, #unsatisfied, #unsatisfied=, #validate!, value, #value
Methods included from SPARQL::Algebra::Expression
cast, #constant?, #evaluate, extension, extension?, extensions, for, #invalid?, new, #node?, open, #optimize, #optimize!, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?
Methods included from RDF::Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
Constructor Details
This class inherits a constructor from ShEx::Algebra::Operator
Class Method Details
.from_shexj(operator, **options) ⇒ Operator
Creates an operator instance from a parsed ShExJ representation
10 11 12 13 14 15 16 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/semact.rb', line 10 def self.from_shexj(operator, **) raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == "SemAct" raise ArgumentError, "missing name in #{operator.inspect}" unless operator.has_key?('name') code = operator.delete('code') operator['code'] = code if code # Reorders operands appropriately super end |
Instance Method Details
#enter(code, arcs_in, arcs_out, logging) ⇒ Boolean
Called on entry
29 30 31 32 33 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/semact.rb', line 29 def enter(**) if implementation = schema.extensions[operands.first.to_s] implementation.enter(code: operands[0], expression: parent, **) end end |
#exit(code: nil, matched: [], unmatched: [], depth: 0, **options)
This method returns an undefined value.
Called on exit from containing TripleExpression
75 76 77 78 79 80 81 82 83 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/semact.rb', line 75 def exit(code: nil, matched: [], unmatched: [], depth: 0, **) if implementation = schema.extensions[operands.first.to_s] implementation.exit(code: operands[1], matched: matched, unmatched: unmatched, expresssion: parent, depth: depth) end end |
#satisfies?(focus, matched: [], unmatched: [], depth: 0) ⇒ Boolean
The evaluation semActsSatisfied on a list of SemActs returns success or failure. The evaluation of an individual SemAct is implementation-dependent.
In addition to standard arguments satsisfies
arguments, the current matched
and unmatched
statements may be passed. Additionally, all sub-classes of Operator
have available parent
, and schema
accessors, which allows access to the operands of the parent, for example.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/semact.rb', line 45 def satisfies?(focus, matched: [], unmatched: [], depth: 0) if implementation = schema.extensions[operands.first.to_s] if matched.empty? implementation.visit(code: operands[1], expression: parent, depth: depth) || not_satisfied("SemAct failed", unmatched: unmatched) end matched.all? do |statement| implementation.visit(code: operands[1], matched: statement, expression: parent, depth: depth) end || not_satisfied("SemAct failed", matched: matched, unmatched: unmatched) else status("unknown SemAct name #{operands.first}", depth: depth) {"expression: #{self.to_sxp}"} false end end |
#semact? ⇒ Boolean
Does This operator is SemAct
86 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/algebra/semact.rb', line 86 def semact?; true; end |