Class: Predicate::ToS
- Inherits:
-
Sexpr::Processor
- Object
- Sexpr::Processor
- Predicate::ToS
- Defined in:
- lib/predicate/processors/to_s.rb
Instance Method Summary collapse
- #on_and(sexpr) ⇒ Object
- #on_contradiction(sexpr) ⇒ Object
- #on_dyadic(sexpr) ⇒ Object (also: #on_eq, #on_neq, #on_lt, #on_lte, #on_gt, #on_gte)
- #on_empty(sexpr) ⇒ Object
- #on_identifier(sexpr) ⇒ Object
- #on_in(sexpr) ⇒ Object
- #on_intersect(sexpr) ⇒ Object
- #on_literal(sexpr) ⇒ Object
- #on_match(sexpr) ⇒ Object
- #on_missing(sexpr) ⇒ Object
-
#on_native(sexpr) ⇒ Object
jeny(predicate) def on_$op_name(sexpr) jeny(predicate) “$OP_NAME(#commalist(sexprcommalist(sexpr.body))” jeny(predicate) end.
- #on_not(sexpr) ⇒ Object
- #on_opaque(sexpr) ⇒ Object
- #on_or(sexpr) ⇒ Object
- #on_qualified_identifier(sexpr) ⇒ Object
- #on_size(sexpr) ⇒ Object
- #on_subset(sexpr) ⇒ Object
- #on_superset(sexpr) ⇒ Object
- #on_tautology(sexpr) ⇒ Object
- #on_var(sexpr) ⇒ Object
Instance Method Details
#on_and(sexpr) ⇒ Object
28 29 30 31 32 |
# File 'lib/predicate/processors/to_s.rb', line 28 def on_and(sexpr) sexpr.sexpr_body.map{|term| apply(term, sexpr) }.join(" AND ") end |
#on_contradiction(sexpr) ⇒ Object
8 9 10 |
# File 'lib/predicate/processors/to_s.rb', line 8 def on_contradiction(sexpr) "false" end |
#on_dyadic(sexpr) ⇒ Object Also known as: on_eq, on_neq, on_lt, on_lte, on_gt, on_gte
40 41 42 43 44 |
# File 'lib/predicate/processors/to_s.rb', line 40 def on_dyadic(sexpr) sexpr.sexpr_body.map{|term| apply(term, sexpr) }.join(" #{sexpr.operator_symbol} ") end |
#on_empty(sexpr) ⇒ Object
80 81 82 |
# File 'lib/predicate/processors/to_s.rb', line 80 def on_empty(sexpr) "EMPTY(#{commalist(sexpr.body)})" end |
#on_identifier(sexpr) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/predicate/processors/to_s.rb', line 16 def on_identifier(sexpr) if s = [:scope] "#{s}.#{sexpr.last.to_s}" else "@#{sexpr.last.to_s}" end end |
#on_in(sexpr) ⇒ Object
52 53 54 |
# File 'lib/predicate/processors/to_s.rb', line 52 def on_in(sexpr) "#{apply(sexpr.identifier)} IN #{apply(sexpr.right)}" end |
#on_intersect(sexpr) ⇒ Object
56 57 58 |
# File 'lib/predicate/processors/to_s.rb', line 56 def on_intersect(sexpr) "#{apply(sexpr.identifier)} INTERSECTS #{to_literal(sexpr.values)}" end |
#on_literal(sexpr) ⇒ Object
68 69 70 |
# File 'lib/predicate/processors/to_s.rb', line 68 def on_literal(sexpr) to_literal(sexpr.last) end |
#on_match(sexpr) ⇒ Object
76 77 78 |
# File 'lib/predicate/processors/to_s.rb', line 76 def on_match(sexpr) "#{apply(sexpr.left)} =~ #{apply(sexpr.right)}" end |
#on_missing(sexpr) ⇒ Object
100 101 102 |
# File 'lib/predicate/processors/to_s.rb', line 100 def on_missing(sexpr) raise "Unimplemented: #{sexpr.first}" end |
#on_native(sexpr) ⇒ Object
jeny(predicate) def on_$op_name(sexpr) jeny(predicate) “$OP_NAME(#Predicate::ToS.commalist(sexprcommalist(sexpr.body))” jeny(predicate) end
92 93 94 |
# File 'lib/predicate/processors/to_s.rb', line 92 def on_native(sexpr) sexpr.last.inspect end |
#on_not(sexpr) ⇒ Object
24 25 26 |
# File 'lib/predicate/processors/to_s.rb', line 24 def on_not(sexpr) "not(" << apply(sexpr.last, sexpr) << ")" end |
#on_opaque(sexpr) ⇒ Object
72 73 74 |
# File 'lib/predicate/processors/to_s.rb', line 72 def on_opaque(sexpr) "OPAQUE #{sexpr.last}" end |
#on_or(sexpr) ⇒ Object
34 35 36 37 38 |
# File 'lib/predicate/processors/to_s.rb', line 34 def on_or(sexpr) sexpr.sexpr_body.map{|term| apply(term, sexpr) }.join(" OR ") end |
#on_qualified_identifier(sexpr) ⇒ Object
12 13 14 |
# File 'lib/predicate/processors/to_s.rb', line 12 def on_qualified_identifier(sexpr) "#{sexpr.qualifier}.#{sexpr.name}" end |
#on_size(sexpr) ⇒ Object
84 85 86 |
# File 'lib/predicate/processors/to_s.rb', line 84 def on_size(sexpr) "SIZE(#{commalist(sexpr.body)})" end |
#on_subset(sexpr) ⇒ Object
60 61 62 |
# File 'lib/predicate/processors/to_s.rb', line 60 def on_subset(sexpr) "#{apply(sexpr.identifier)} IS SUBSET OF #{to_literal(sexpr.values)}" end |
#on_superset(sexpr) ⇒ Object
64 65 66 |
# File 'lib/predicate/processors/to_s.rb', line 64 def on_superset(sexpr) "#{apply(sexpr.identifier)} IS SUPERSET OF #{to_literal(sexpr.values)}" end |
#on_tautology(sexpr) ⇒ Object
4 5 6 |
# File 'lib/predicate/processors/to_s.rb', line 4 def on_tautology(sexpr) "true" end |
#on_var(sexpr) ⇒ Object
96 97 98 |
# File 'lib/predicate/processors/to_s.rb', line 96 def on_var(sexpr) "#{sexpr.semantics}(#{sexpr.formaldef})" end |