alf-core 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -8
- data/Gemfile.lock +9 -17
- data/examples/operators/frame.alf +2 -0
- data/lib/alf-core.rb +24 -22
- data/lib/{alf-adapter/alf → alf}/adapter.rb +0 -0
- data/lib/{alf-adapter/alf → alf}/adapter/connection.rb +4 -10
- data/lib/{alf-adapter/alf → alf}/adapter/connection/schema_cached.rb +0 -0
- data/lib/{alf-adapter-fs/alf → alf}/adapter/folder.rb +0 -0
- data/lib/{alf-adapter-fs/alf → alf}/adapter/folder/connection.rb +3 -2
- data/lib/{alf-adapter-fs/alf → alf}/adapter/fs.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator.rb +12 -9
- data/lib/{alf-aggregator/alf → alf}/aggregator/avg.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/collect.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/concat.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/count.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/max.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/min.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/stddev.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/sum.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/variance.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra.rb +1 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operand.rb +13 -6
- data/lib/{alf-algebra/alf → alf}/algebra/operand/fake.rb +18 -4
- data/lib/alf/algebra/operand/named.rb +65 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operand/proxy.rb +7 -3
- data/lib/{alf-algebra/alf → alf}/algebra/operator.rb +40 -12
- data/lib/{alf-algebra/alf → alf}/algebra/operator/autonum.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/clip.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/coerce.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/compact.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/defaults.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/extend.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/frame.rb +12 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/generator.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/group.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/hierarchize.rb +8 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operator/intersect.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/join.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/matching.rb +10 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/minus.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/not_matching.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/page.rb +11 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/project.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/quota.rb +12 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/rank.rb +11 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/rename.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/restrict.rb +12 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/sort.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/summarize.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/ungroup.rb +11 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/union.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/unwrap.rb +13 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/wrap.rb +10 -1
- data/lib/alf/algebra/shortcut.rb +40 -0
- data/lib/alf/algebra/shortcut/allbut.rb +25 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support.rb +2 -1
- data/lib/{alf-algebra/alf → alf}/algebra/support/binary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/classification.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/compiler.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/experimental.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/non_relational.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/nullary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/relational.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/rewriter.rb +4 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/signature.rb +7 -8
- data/lib/alf/algebra/support/type_check.rb +51 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/unary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/visitor.rb +2 -1
- data/lib/{alf-algebra/alf → alf}/algebra/support/with_ordering.rb +0 -0
- data/lib/alf/compiler.rb +57 -0
- data/lib/alf/compiler/cog.rb +39 -0
- data/lib/alf/compiler/default.rb +168 -0
- data/lib/alf/compiler/plan.rb +77 -0
- data/lib/{alf-core → alf/core}/loader.rb +0 -0
- data/lib/{alf-core → alf/core}/version.rb +1 -1
- data/lib/{alf-database/alf → alf}/database.rb +0 -0
- data/lib/{alf-database/alf → alf}/database/connection.rb +10 -52
- data/lib/{alf-database/alf → alf}/database/options.rb +2 -5
- data/lib/{alf-core → alf}/dsl.rb +4 -4
- data/lib/{alf-engine/alf → alf}/engine.rb +0 -2
- data/lib/{alf-engine/alf → alf}/engine/aggregate.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/autonum.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/clip.rb +10 -2
- data/lib/{alf-engine/alf → alf}/engine/coerce.rb +6 -2
- data/lib/alf/engine/cog.rb +58 -0
- data/lib/{alf-engine/alf → alf}/engine/compact.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/compact/set.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/compact/uniq.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/concat.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/defaults.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/filter.rb +8 -4
- data/lib/{alf-engine/alf → alf}/engine/generator.rb +6 -2
- data/lib/alf/engine/group.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/group/hash.rb +11 -2
- data/lib/{alf-engine/alf → alf}/engine/hierarchize.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/infer_heading.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/join.rb +0 -0
- data/lib/{alf-engine/alf → alf}/engine/join/hash.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/leaf.rb +7 -3
- data/lib/{alf-engine/alf → alf}/engine/materialize.rb +5 -1
- data/lib/{alf-engine/alf → alf}/engine/materialize/array.rb +3 -2
- data/lib/{alf-engine/alf → alf}/engine/materialize/hash.rb +3 -2
- data/lib/alf/engine/quota.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/quota/cesure.rb +8 -3
- data/lib/alf/engine/rank.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/rank/cesure.rb +8 -3
- data/lib/{alf-engine/alf → alf}/engine/rename.rb +6 -2
- data/lib/alf/engine/semi.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/semi/hash.rb +7 -2
- data/lib/{alf-engine/alf → alf}/engine/set_attr.rb +8 -4
- data/lib/alf/engine/sort.rb +13 -0
- data/lib/{alf-engine/alf → alf}/engine/sort/in_memory.rb +12 -2
- data/lib/alf/engine/summarize.rb +13 -0
- data/lib/{alf-engine/alf → alf}/engine/summarize/cesure.rb +5 -4
- data/lib/{alf-engine/alf → alf}/engine/summarize/hash.rb +3 -2
- data/lib/{alf-engine/alf → alf}/engine/support/cesure.rb +0 -0
- data/lib/{alf-engine/alf → alf}/engine/take.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/to_array.rb +13 -5
- data/lib/{alf-engine/alf → alf}/engine/type_safe.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/ungroup.rb +7 -2
- data/lib/{alf-engine/alf → alf}/engine/unwrap.rb +11 -5
- data/lib/{alf-engine/alf → alf}/engine/wrap.rb +6 -2
- data/lib/{alf-core → alf}/errors.rb +2 -3
- data/lib/{alf-core → alf}/ext.rb +0 -0
- data/lib/{alf-core → alf}/ext/domain/heading_based.rb +5 -0
- data/lib/alf/facade.rb +53 -0
- data/lib/{alf-lang/alf → alf}/lang.rb +1 -1
- data/lib/{alf-lang/alf → alf}/lang/functional.rb +0 -4
- data/lib/{alf-lang/alf → alf}/lang/object_oriented.rb +0 -0
- data/lib/{alf-lang/alf → alf}/lang/oo/aggregation_methods.rb +1 -1
- data/lib/{alf-lang/alf → alf}/lang/oo/algebra_methods.rb +0 -12
- data/lib/{alf-lang/alf → alf}/lang/oo/rendering_methods.rb +1 -1
- data/lib/alf/lang/parser.rb +9 -0
- data/lib/alf/lang/parser/lispy.rb +63 -0
- data/lib/alf/lang/parser/safer.rb +69 -0
- data/lib/{alf-lang/alf → alf}/lang/predicates.rb +1 -1
- data/lib/{alf-optimizer/alf → alf}/optimizer.rb +15 -7
- data/lib/alf/optimizer/project.rb +182 -0
- data/lib/{alf-optimizer/alf → alf}/optimizer/restrict.rb +48 -50
- data/lib/{alf-predicate/alf → alf}/predicate.rb +16 -12
- data/lib/{alf-predicate/alf → alf}/predicate/factory.rb +13 -8
- data/lib/{alf-predicate/alf → alf}/predicate/grammar.rb +2 -5
- data/lib/{alf-predicate/alf → alf}/predicate/grammar.sexp.yml +11 -7
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/and.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/contradiction.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/dyadic_comp.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/eq.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/expr.rb +10 -5
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/gt.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/gte.rb +0 -0
- data/lib/{alf-predicate/alf/predicate/nodes/var_ref.rb → alf/predicate/nodes/identifier.rb} +3 -3
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/in.rb +2 -2
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/literal.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/lt.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/lte.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/nadic_bool.rb +0 -0
- data/lib/alf/predicate/nodes/native.rb +32 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/neq.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/not.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/or.rb +0 -0
- data/lib/{alf-predicate/alf/predicate/nodes/native.rb → alf/predicate/nodes/qualified_identifier.rb} +8 -4
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/tautology.rb +0 -0
- data/lib/alf/predicate/processors.rb +3 -0
- data/lib/alf/predicate/processors/qualifier.rb +25 -0
- data/lib/alf/predicate/processors/renamer.rb +27 -0
- data/lib/{alf-predicate/alf → alf}/predicate/processors/to_ruby_code.rb +6 -11
- data/lib/{alf-io/alf → alf}/reader.rb +11 -2
- data/lib/{alf-io/alf → alf}/reader/csv.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/json.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/rash.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/ruby.rb +0 -0
- data/lib/alf/reader/yaml.rb +25 -0
- data/lib/{alf-relation/alf → alf}/relation.rb +12 -2
- data/lib/{alf-relvar/alf → alf}/relvar.rb +14 -21
- data/lib/alf/relvar/base.rb +35 -0
- data/lib/{alf-relvar/alf → alf}/relvar/fake.rb +3 -2
- data/lib/{alf-relvar/alf → alf}/relvar/read_only.rb +6 -30
- data/lib/{alf-relvar/alf → alf}/relvar/virtual.rb +0 -31
- data/lib/{alf-io/alf → alf}/renderer.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/csv.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/json.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/rash.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/text.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/yaml.rb +2 -2
- data/lib/{alf-support/alf → alf}/support.rb +2 -1
- data/lib/{alf-support/alf → alf}/support/coerce.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/config.rb +0 -0
- data/lib/{alf-io/alf → alf}/support/csv_utils.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/dot_utils.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/miscellaneous.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/ordered_set.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/registry.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/scope.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/to_lispy.rb +6 -1
- data/lib/{alf-support/alf → alf}/support/to_ruby_literal.rb +0 -0
- data/lib/alf/support/tree.rb +51 -0
- data/lib/{alf-support/alf → alf}/support/tuple_scope.rb +9 -1
- data/lib/{alf-relation/alf → alf}/tuple.rb +1 -1
- data/lib/{alf-types/alf → alf}/types.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/attr_list.rb +2 -2
- data/lib/{alf-types/alf → alf}/types/attr_name.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/boolean.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/heading.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/keys.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/ordering.rb +7 -1
- data/lib/{alf-types/alf → alf}/types/renaming.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/selection.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/selector.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/size.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/summarization.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/tuple_computation.rb +13 -4
- data/lib/{alf-types/alf → alf}/types/tuple_expression.rb +6 -19
- data/lib/{alf-types/alf → alf}/types/type_check.rb +1 -0
- data/lib/{alf-update/alf → alf}/update.rb +0 -0
- data/lib/{alf-update/alf → alf}/update/deleter.rb +0 -3
- data/lib/{alf-update/alf → alf}/update/inserter.rb +1 -7
- data/lib/{alf-update/alf → alf}/update/updater.rb +0 -2
- data/lib/{alf-viewpoint/alf → alf}/viewpoint.rb +9 -7
- data/lib/{alf-viewpoint/alf → alf}/viewpoint/metadata.rb +5 -2
- data/spec/compiler_helper.rb +20 -0
- data/spec/integration/relation/test_to_array.rb +6 -6
- data/spec/integration/test_examples.rb +14 -6
- data/spec/shared/a_cog.rb +8 -4
- data/spec/shared/a_valid_type_implementation.rb +4 -7
- data/spec/spec_helper.rb +9 -5
- data/spec/type_check_helper.rb +1 -0
- data/spec/unit/alf-adapter/shared_examples/an_adapter_with_readable_cogs.rb +1 -1
- data/spec/unit/alf-aggregator/test_concat.rb +8 -0
- data/spec/unit/alf-algebra/operand/named/test_hash_and_equal.rb +53 -0
- data/spec/unit/alf-algebra/operand/named/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operand/named/test_to_ascii_tree.rb +18 -0
- data/spec/unit/alf-algebra/operand/named/test_to_cog.rb +24 -0
- data/spec/unit/alf-algebra/operand/named/test_to_relvar.rb +1 -1
- data/spec/unit/alf-algebra/operand/named/test_type_check.rb +38 -0
- data/spec/unit/alf-algebra/operand/proxy/test_to_cog.rb +42 -0
- data/spec/unit/alf-algebra/operand/test_coerce.rb +0 -6
- data/spec/unit/alf-algebra/operand/test_proxy.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_key_preserving.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/autonum/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/clip/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/coerce/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/commons/test_resulting_type.rb +20 -0
- data/spec/unit/alf-algebra/operator/commons/test_to_ascii_tree.rb +40 -0
- data/spec/unit/alf-algebra/operator/extend/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/frame/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/group/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/operator/hierarchize/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/intersect/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/join/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/matching/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operator/matching/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/minus/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/not_matching/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/page/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/operator/project/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/quota/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/rank/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/rename/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/restrict/test_type_check.rb +46 -0
- data/spec/unit/alf-algebra/operator/shared/test_to_cog.rb +34 -0
- data/spec/unit/alf-algebra/operator/sort/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/summarize/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/test_hash_and_equal.rb +59 -0
- data/spec/unit/alf-algebra/operator/ungroup/test_type_check.rb +44 -0
- data/spec/unit/alf-algebra/operator/union/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/unwrap/test_type_check.rb +44 -0
- data/spec/unit/alf-algebra/operator/wrap/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/support/signature/test_to_lispy.rb +24 -9
- data/spec/unit/alf-algebra/support/test_non_relational.rb +1 -2
- data/spec/unit/alf-algebra/support/test_relational.rb +1 -1
- data/spec/unit/alf-compiler/default/test_allbut.rb +65 -0
- data/spec/unit/alf-compiler/default/test_autonum.rb +30 -0
- data/spec/unit/alf-compiler/default/test_clip.rb +30 -0
- data/spec/unit/alf-compiler/default/test_coerce.rb +30 -0
- data/spec/unit/alf-compiler/default/test_compact.rb +26 -0
- data/spec/unit/alf-compiler/default/test_completude.rb +16 -0
- data/spec/unit/alf-compiler/default/test_defaults.rb +50 -0
- data/spec/unit/alf-compiler/default/test_extend.rb +34 -0
- data/spec/unit/alf-compiler/default/test_frame.rb +77 -0
- data/spec/unit/alf-compiler/default/test_generator.rb +30 -0
- data/spec/unit/alf-compiler/default/test_group.rb +38 -0
- data/spec/unit/alf-compiler/default/test_hierarchize.rb +40 -0
- data/spec/unit/alf-compiler/default/test_intersect.rb +34 -0
- data/spec/unit/alf-compiler/default/test_join.rb +34 -0
- data/spec/unit/alf-compiler/default/test_matching.rb +38 -0
- data/spec/unit/alf-compiler/default/test_minus.rb +38 -0
- data/spec/unit/alf-compiler/default/test_not_matching.rb +38 -0
- data/spec/unit/alf-compiler/default/test_page.rb +91 -0
- data/spec/unit/alf-compiler/default/test_project.rb +76 -0
- data/spec/unit/alf-compiler/default/test_quota.rb +88 -0
- data/spec/unit/alf-compiler/default/test_rank.rb +71 -0
- data/spec/unit/alf-compiler/default/test_rename.rb +30 -0
- data/spec/unit/alf-compiler/default/test_restrict.rb +34 -0
- data/spec/unit/alf-compiler/default/test_sort.rb +81 -0
- data/spec/unit/alf-compiler/default/test_summarize.rb +85 -0
- data/spec/unit/alf-compiler/default/test_ungroup.rb +30 -0
- data/spec/unit/alf-compiler/default/test_union.rb +36 -0
- data/spec/unit/alf-compiler/default/test_unwrap.rb +30 -0
- data/spec/unit/alf-compiler/default/test_wrap.rb +38 -0
- data/spec/unit/alf-compiler/shared/compiled_examples.rb +111 -0
- data/spec/unit/alf-compiler/test_principle.rb +332 -0
- data/spec/unit/alf-core/test_aggregator.rb +0 -24
- data/spec/unit/alf-database/connection/test_parse.rb +0 -49
- data/spec/unit/alf-database/connection/test_relvar.rb +1 -9
- data/spec/unit/alf-database/options/test_parser.rb +23 -0
- data/spec/unit/alf-engine/cog/test_to_ascii_tree.rb +14 -0
- data/spec/unit/alf-engine/test_aggregate.rb +2 -2
- data/spec/unit/alf-engine/test_filter.rb +1 -1
- data/spec/unit/alf-engine/test_to_array.rb +16 -2
- data/spec/unit/alf-io/reader/test_yaml.rb +30 -0
- data/spec/unit/alf-io/renderer/test_yaml.rb +11 -0
- data/spec/unit/alf-lang/functional/test_aggregation.rb +18 -4
- data/spec/unit/alf-lang/parser/lispy/test_connection_bang.rb +28 -0
- data/spec/unit/alf-lang/parser/lispy/test_parse.rb +38 -0
- data/spec/unit/alf-lang/parser/lispy/test_to_s.rb +16 -0
- data/spec/unit/alf-lang/parser/safer/safe.txt +5 -0
- data/spec/unit/alf-lang/parser/safer/test_parse.rb +82 -0
- data/spec/unit/alf-lang/parser/safer/unsafe.txt +14 -0
- data/spec/unit/alf-optimizer/restrict/test_on_autonum.rb +1 -1
- data/spec/unit/alf-optimizer/test_quota.rb +1 -1
- data/spec/unit/alf-optimizer/test_rename.rb +7 -0
- data/spec/unit/alf-optimizer/test_summarize.rb +1 -1
- data/spec/unit/alf-predicate/expr/test_to_proc.rb +4 -6
- data/spec/unit/alf-predicate/expr/test_to_ruby_code.rb +23 -23
- data/spec/unit/alf-predicate/factory/shared/a_comparison_factory_method.rb +3 -3
- data/spec/unit/alf-predicate/factory/test_between.rb +1 -1
- data/spec/unit/alf-predicate/factory/test_comp.rb +3 -3
- data/spec/unit/alf-predicate/factory/test_factor_predicate.rb +3 -3
- data/spec/unit/alf-predicate/factory/{test_var_ref.rb → test_identifier.rb} +4 -4
- data/spec/unit/alf-predicate/factory/test_in.rb +1 -1
- data/spec/unit/alf-predicate/factory/test_native.rb +9 -4
- data/spec/unit/alf-predicate/factory/test_qualified_identifier.rb +17 -0
- data/spec/unit/alf-predicate/grammar/test_match.rb +9 -9
- data/spec/unit/alf-predicate/grammar/test_sexpr.rb +11 -11
- data/spec/unit/alf-predicate/nodes/{var_ref → identifier}/test_and_split.rb +2 -2
- data/spec/unit/alf-predicate/nodes/{var_ref → identifier}/test_free_variables.rb +2 -2
- data/spec/unit/alf-predicate/nodes/identifier/test_name.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_and_split.rb +25 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_free_variables.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_name.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_qualifier.rb +14 -0
- data/spec/unit/alf-predicate/predicate/test_and_split.rb +4 -4
- data/spec/unit/alf-predicate/predicate/test_bool_and.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_bool_not.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_bool_or.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_coerce.rb +9 -8
- data/spec/unit/alf-predicate/predicate/test_contradiction.rb +2 -2
- data/spec/unit/alf-predicate/predicate/test_factory_methods.rb +12 -12
- data/spec/unit/alf-predicate/predicate/test_qualify.rb +36 -0
- data/spec/unit/alf-predicate/predicate/test_rename.rb +58 -15
- data/spec/unit/alf-predicate/predicate/test_tautology.rb +2 -2
- data/spec/unit/alf-predicate/predicate/test_to_ruby_code.rb +8 -2
- data/spec/unit/alf-predicate/predicate/test_to_ruby_literal.rb +1 -1
- data/spec/unit/alf-predicate/test_predicate.rb +7 -8
- data/spec/unit/alf-relation/relation/class/test_dum.rb +19 -0
- data/spec/unit/alf-relation/relation/test_heading.rb +1 -1
- data/spec/unit/alf-relation/relation/test_keys.rb +17 -0
- data/spec/unit/alf-relation/relation/test_relation.rb +1 -1
- data/spec/unit/alf-relation/relation/test_to_a.rb +10 -10
- data/spec/unit/alf-relvar/base/test_oo_lang.rb +26 -10
- data/spec/unit/alf-relvar/base/test_to_cog.rb +2 -2
- data/spec/unit/alf-relvar/read_only/test_to_relation.rb +17 -0
- data/spec/unit/alf-relvar/read_only/test_type.rb +0 -4
- data/spec/unit/alf-relvar/virtual/test_oo_lang.rb +0 -4
- data/spec/unit/alf-relvar/virtual/test_to_cog.rb +4 -4
- data/spec/unit/alf-relvar/virtual/test_to_s.rb +1 -1
- data/spec/unit/alf-support/test_to_lispy.rb +13 -31
- data/spec/unit/alf-support/test_tuple_scope.rb +11 -0
- data/spec/unit/alf-types/ordering/test_coerce.rb +13 -0
- data/spec/unit/alf-types/ordering/test_lte.rb +43 -0
- data/spec/unit/alf-types/summarization/test_coerce.rb +2 -2
- data/spec/unit/alf-types/summarization/test_least.rb +1 -1
- data/spec/unit/alf-types/summarization/test_summarize.rb +1 -1
- data/spec/unit/alf-types/test_summarization.rb +2 -2
- data/spec/unit/alf-types/test_tuple_expression.rb +2 -2
- data/spec/unit/alf-types/tuple_computation/test_coerce.rb +4 -13
- data/spec/unit/alf-types/tuple_computation/test_empty.rb +24 -0
- data/spec/unit/alf-types/tuple_computation/test_project.rb +46 -0
- data/spec/unit/alf-types/tuple_expression/test_coerce.rb +1 -10
- data/spec/unit/alf-types/tuple_expression/test_evaluate.rb +0 -8
- data/spec/unit/alf-types/tuple_expression/test_to_ruby_literal.rb +0 -5
- data/spec/unit/alf-update/deleter/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-update/inserter/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-update/updater/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-viewpoint/test_native_const.rb +1 -1
- data/spec/update_helper.rb +18 -2
- metadata +417 -313
- data/lib/alf-algebra/alf/algebra/operand/named.rb +0 -36
- data/lib/alf-algebra/alf/algebra/operator/infer_heading.rb +0 -19
- data/lib/alf-algebra/alf/algebra/operator/type_safe.rb +0 -21
- data/lib/alf-algebra/alf/algebra/support/to_dot.rb +0 -196
- data/lib/alf-core/facade.rb +0 -39
- data/lib/alf-engine/alf/engine/cog.rb +0 -50
- data/lib/alf-engine/alf/engine/compiler.rb +0 -171
- data/lib/alf-engine/alf/engine/group.rb +0 -3
- data/lib/alf-engine/alf/engine/quota.rb +0 -3
- data/lib/alf-engine/alf/engine/rank.rb +0 -3
- data/lib/alf-engine/alf/engine/semi.rb +0 -3
- data/lib/alf-engine/alf/engine/sort.rb +0 -30
- data/lib/alf-engine/alf/engine/summarize.rb +0 -4
- data/lib/alf-engine/alf/engine/to_dot.rb +0 -60
- data/lib/alf-io/alf/io.rb +0 -6
- data/lib/alf-lang/alf/lang/lispy.rb +0 -65
- data/lib/alf-predicate/alf/predicate/parser.rb +0 -12
- data/lib/alf-predicate/alf/predicate/processors.rb +0 -3
- data/lib/alf-predicate/alf/predicate/processors/renamer.rb +0 -19
- data/lib/alf-predicate/alf/predicate/processors/to_proc.rb +0 -35
- data/lib/alf-relvar/alf/relvar/base.rb +0 -69
- data/lib/alf-support/alf/support/bindable.rb +0 -26
- data/spec/integration/algebra/test_to_dot.rb +0 -14
- data/spec/integration/relvar/test_type_safe.rb +0 -22
- data/spec/unit/alf-algebra/operator/infer_heading/test_keys.rb +0 -23
- data/spec/unit/alf-algebra/operator/test_infer_heading.rb +0 -16
- data/spec/unit/alf-algebra/operator/type_safe/test_heading.rb +0 -26
- data/spec/unit/alf-algebra/operator/type_safe/test_keys.rb +0 -26
- data/spec/unit/alf-engine/compiler/test_on_frame.rb +0 -70
- data/spec/unit/alf-engine/compiler/test_on_hierarchize.rb +0 -33
- data/spec/unit/alf-engine/compiler/test_on_page.rb +0 -128
- data/spec/unit/alf-engine/compiler/test_unsupported.rb +0 -48
- data/spec/unit/alf-lang/lispy/test_connection_bang.rb +0 -26
- data/spec/unit/alf-lang/lispy/test_parse.rb +0 -38
- data/spec/unit/alf-lang/lispy/test_to_s.rb +0 -14
- data/spec/unit/alf-optimizer/optimizer/test_optimizer.rb +0 -37
- data/spec/unit/alf-optimizer/test_infer_heading.rb +0 -9
- data/spec/unit/alf-predicate/grammar/test_parse.rb +0 -23
- data/spec/unit/alf-predicate/nodes/var_ref/test_var_name.rb +0 -14
- data/spec/unit/alf-relvar/base/test_name.rb +0 -15
- data/spec/unit/alf-relvar/virtual/test_connection.rb +0 -15
- data/spec/unit/alf-support/bindable/test_bind.rb +0 -60
- data/spec/unit/alf-support/bindable/test_bound.rb +0 -31
- data/spec/unit/alf-support/bindable/test_connection.rb +0 -31
- data/spec/unit/alf-support/bindable/test_connection_bang.rb +0 -35
- data/spec/unit/alf-update/inserter/test_type_safe.rb +0 -72
@@ -1,55 +1,57 @@
|
|
1
1
|
module Alf
|
2
2
|
class Optimizer
|
3
|
-
class Restrict <
|
4
|
-
include Lang::Functional
|
3
|
+
class Restrict < Optimizer::Base
|
5
4
|
|
6
5
|
### overridings
|
7
6
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
def search_predicate
|
8
|
+
Algebra::Restrict
|
9
|
+
end
|
10
|
+
|
11
|
+
def _call(restrict, search)
|
12
|
+
apply(restrict.operand, restrict.predicate, search)
|
12
13
|
end
|
13
14
|
|
14
15
|
def restrict(operand, predicate)
|
15
16
|
check_constant(operand, predicate){ super }
|
16
17
|
end
|
17
18
|
|
18
|
-
def apply(operand, predicate)
|
19
|
+
def apply(operand, predicate, search)
|
19
20
|
check_constant(operand, predicate){ super }
|
21
|
+
rescue NotSupportedError
|
22
|
+
restrict(operand, predicate)
|
20
23
|
end
|
21
24
|
|
22
25
|
# leaf Operand, recursion end :-)
|
23
26
|
|
24
|
-
def on_leaf_operand(expr, predicate)
|
27
|
+
def on_leaf_operand(expr, predicate, search)
|
25
28
|
restrict(expr, predicate)
|
26
29
|
end
|
27
30
|
alias :on_missing :on_leaf_operand
|
28
31
|
|
29
32
|
### pass through, unoptimizable, binary optimizable
|
30
33
|
|
31
|
-
def on_pass_through(expr, predicate)
|
32
|
-
expr.with_operands(*expr.operands.map{|op| apply(op, predicate)})
|
34
|
+
def on_pass_through(expr, predicate, search)
|
35
|
+
expr.with_operands(*expr.operands.map{|op| apply(op, predicate, search) })
|
33
36
|
end
|
37
|
+
alias :on_allbut :on_pass_through
|
34
38
|
alias :on_clip :on_pass_through
|
35
39
|
alias :on_compact :on_pass_through
|
36
40
|
alias :on_sort :on_pass_through
|
37
|
-
alias :on_type_safe :on_pass_through
|
38
41
|
alias :on_project :on_pass_through
|
39
42
|
alias :on_intersect :on_pass_through
|
40
43
|
alias :on_minus :on_pass_through
|
41
44
|
alias :on_union :on_pass_through
|
42
45
|
|
43
|
-
def on_unoptimizable(expr, predicate)
|
44
|
-
restrict(expr, predicate)
|
46
|
+
def on_unoptimizable(expr, predicate, search)
|
47
|
+
restrict(search.call(expr), predicate)
|
45
48
|
end
|
46
49
|
alias :on_generator :on_unoptimizable
|
47
|
-
alias :on_infer_heading :on_unoptimizable
|
48
50
|
alias :on_page :on_unoptimizable
|
49
51
|
alias :on_frame :on_unoptimizable
|
50
52
|
|
51
|
-
def on_binary_optimizable(expr, predicate)
|
52
|
-
binary_split(expr, predicate)
|
53
|
+
def on_binary_optimizable(expr, predicate, search)
|
54
|
+
binary_split(expr, predicate, search)
|
53
55
|
end
|
54
56
|
alias :on_join :on_binary_optimizable
|
55
57
|
alias :on_matching :on_binary_optimizable
|
@@ -57,69 +59,65 @@ module Alf
|
|
57
59
|
|
58
60
|
### non relational
|
59
61
|
|
60
|
-
def on_autonum(expr, predicate)
|
61
|
-
unary_split(expr, predicate, AttrList[expr.as])
|
62
|
+
def on_autonum(expr, predicate, search)
|
63
|
+
unary_split(expr, predicate, AttrList[expr.as], search)
|
62
64
|
end
|
63
65
|
|
64
|
-
def on_coerce(expr, predicate)
|
65
|
-
unary_split(expr, predicate, expr.coercions.to_attr_list)
|
66
|
+
def on_coerce(expr, predicate, search)
|
67
|
+
unary_split(expr, predicate, expr.coercions.to_attr_list, search)
|
66
68
|
end
|
67
69
|
|
68
|
-
def on_defaults(expr, predicate)
|
69
|
-
unary_split(expr, predicate, expr.defaults.to_attr_list)
|
70
|
+
def on_defaults(expr, predicate, search)
|
71
|
+
unary_split(expr, predicate, expr.defaults.to_attr_list, search)
|
70
72
|
end
|
71
73
|
|
72
74
|
### relational
|
73
75
|
|
74
|
-
def on_extend(expr, predicate)
|
75
|
-
unary_split(expr, predicate, expr.ext.to_attr_list)
|
76
|
+
def on_extend(expr, predicate, search)
|
77
|
+
unary_split(expr, predicate, expr.ext.to_attr_list, search)
|
76
78
|
end
|
77
79
|
|
78
|
-
def on_group(expr, predicate)
|
79
|
-
unary_split(expr, predicate, AttrList[expr.as])
|
80
|
+
def on_group(expr, predicate, search)
|
81
|
+
unary_split(expr, predicate, AttrList[expr.as], search)
|
80
82
|
end
|
81
83
|
|
82
|
-
def on_quota(expr, predicate)
|
83
|
-
unary_split(expr, predicate, expr.summarization.to_attr_list)
|
84
|
+
def on_quota(expr, predicate, search)
|
85
|
+
unary_split(expr, predicate, expr.summarization.to_attr_list, search)
|
84
86
|
end
|
85
87
|
|
86
|
-
def on_rank(expr, predicate)
|
87
|
-
unary_split(expr, predicate, AttrList[expr.as])
|
88
|
+
def on_rank(expr, predicate, search)
|
89
|
+
unary_split(expr, predicate, AttrList[expr.as], search)
|
88
90
|
end
|
89
91
|
|
90
|
-
def on_rename(expr, predicate)
|
91
|
-
|
92
|
-
|
93
|
-
rescue NotSupportedError
|
94
|
-
return restrict(expr, predicate)
|
95
|
-
end
|
96
|
-
on_pass_through(expr, predicate)
|
92
|
+
def on_rename(expr, predicate, search)
|
93
|
+
predicate = predicate.rename(expr.renaming.invert)
|
94
|
+
on_pass_through(expr, predicate, search)
|
97
95
|
end
|
98
96
|
|
99
|
-
def on_restrict(expr, predicate)
|
97
|
+
def on_restrict(expr, predicate, search)
|
100
98
|
if predicate.native? or expr.predicate.native?
|
101
99
|
restrict(expr, predicate)
|
102
100
|
else
|
103
|
-
apply(expr.operand, predicate & expr.predicate)
|
101
|
+
apply(expr.operand, predicate & expr.predicate, search)
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
107
|
-
def on_summarize(expr, predicate)
|
108
|
-
unary_split(expr, predicate, expr.summarization.to_attr_list)
|
105
|
+
def on_summarize(expr, predicate, search)
|
106
|
+
unary_split(expr, predicate, expr.summarization.to_attr_list, search)
|
109
107
|
end
|
110
108
|
|
111
|
-
def on_ungroup(expr, predicate)
|
109
|
+
def on_ungroup(expr, predicate, search)
|
112
110
|
# TODO:
|
113
111
|
restrict(expr, predicate)
|
114
112
|
end
|
115
113
|
|
116
|
-
def on_unwrap(expr, predicate)
|
114
|
+
def on_unwrap(expr, predicate, search)
|
117
115
|
# TODO:
|
118
116
|
restrict(expr, predicate)
|
119
117
|
end
|
120
118
|
|
121
|
-
def on_wrap(expr, predicate)
|
122
|
-
unary_split(expr, predicate, AttrList[expr.as])
|
119
|
+
def on_wrap(expr, predicate, search)
|
120
|
+
unary_split(expr, predicate, AttrList[expr.as], search)
|
123
121
|
end
|
124
122
|
|
125
123
|
### Splitting rules
|
@@ -135,12 +133,12 @@ module Alf
|
|
135
133
|
end
|
136
134
|
end
|
137
135
|
|
138
|
-
def unary_split(expr, predicate, attr_list)
|
136
|
+
def unary_split(expr, predicate, attr_list, search)
|
139
137
|
top, down = predicate.and_split(attr_list)
|
140
|
-
restrict(expr.with_operand(apply(expr.operand, down)), top)
|
138
|
+
restrict(expr.with_operand(apply(expr.operand, down, search)), top)
|
141
139
|
end
|
142
140
|
|
143
|
-
def binary_split(expr, predicate)
|
141
|
+
def binary_split(expr, predicate, search)
|
144
142
|
left_attrs, right_attrs = expr.operands.map{|op| op.heading.to_attr_list }
|
145
143
|
left_only, right_only = left_attrs - right_attrs, right_attrs - left_attrs
|
146
144
|
|
@@ -156,8 +154,8 @@ module Alf
|
|
156
154
|
|
157
155
|
# basic join with restricted operands
|
158
156
|
join = expr.with_operands(
|
159
|
-
apply(expr.left, left_pred),
|
160
|
-
apply(expr.right, right_pred))
|
157
|
+
apply(expr.left, left_pred, search),
|
158
|
+
apply(expr.right, right_pred, search))
|
161
159
|
|
162
160
|
if left_top.tautology? || right_top.tautology?
|
163
161
|
# everything is already covered by one restriction pushed
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require_relative 'predicate/parser'
|
2
1
|
require_relative 'predicate/factory'
|
3
2
|
require_relative 'predicate/grammar'
|
4
3
|
require_relative 'predicate/processors'
|
5
4
|
module Alf
|
6
5
|
class Predicate
|
7
6
|
|
8
|
-
def initialize(
|
9
|
-
@
|
7
|
+
def initialize(sexpr)
|
8
|
+
@sexpr = sexpr
|
10
9
|
end
|
11
|
-
attr_reader :
|
10
|
+
attr_reader :sexpr
|
11
|
+
alias :expr :sexpr
|
12
12
|
|
13
13
|
class << self
|
14
14
|
include Factory
|
@@ -18,10 +18,9 @@ module Alf
|
|
18
18
|
when Predicate then arg
|
19
19
|
when TrueClass then tautology
|
20
20
|
when FalseClass then contradiction
|
21
|
-
when Symbol then
|
21
|
+
when Symbol then identifier(arg)
|
22
22
|
when Proc then native(arg)
|
23
23
|
when Hash, Tuple then eq(arg)
|
24
|
-
when String then Predicate.new(Grammar.parse(arg))
|
25
24
|
when Relation then relation(arg)
|
26
25
|
else
|
27
26
|
raise ArgumentError, "Unable to coerce `#{arg}` to a predicate"
|
@@ -73,11 +72,15 @@ module Alf
|
|
73
72
|
Predicate.new(!expr)
|
74
73
|
end
|
75
74
|
|
75
|
+
def qualify(qualifier)
|
76
|
+
Predicate.new(expr.qualify(qualifier))
|
77
|
+
end
|
78
|
+
|
76
79
|
def rename(renaming)
|
77
80
|
Predicate.new(expr.rename(renaming))
|
78
81
|
end
|
79
82
|
|
80
|
-
def evaluate(scope
|
83
|
+
def evaluate(scope)
|
81
84
|
proc = to_proc
|
82
85
|
if proc.arity == 1
|
83
86
|
proc.call(scope)
|
@@ -93,26 +96,27 @@ module Alf
|
|
93
96
|
def ==(other)
|
94
97
|
other.is_a?(Predicate) && (other.expr==expr)
|
95
98
|
end
|
99
|
+
alias :eql? :==
|
96
100
|
|
97
101
|
def hash
|
98
102
|
expr.hash
|
99
103
|
end
|
100
104
|
|
101
|
-
def to_ruby_code
|
102
|
-
|
105
|
+
def to_ruby_code(scope = "t")
|
106
|
+
expr.to_ruby_code(scope)
|
103
107
|
end
|
104
108
|
alias :to_s :to_ruby_code
|
105
109
|
|
106
110
|
def to_proc
|
107
|
-
@proc ||= expr.to_proc(
|
111
|
+
@proc ||= expr.to_proc("t")
|
108
112
|
end
|
109
113
|
|
110
114
|
def to_lispy
|
111
|
-
|
115
|
+
to_ruby_code
|
112
116
|
end
|
113
117
|
|
114
118
|
def to_ruby_literal
|
115
|
-
|
119
|
+
to_lispy
|
116
120
|
end
|
117
121
|
|
118
122
|
end # class Predicate
|
@@ -10,8 +10,12 @@ module Alf
|
|
10
10
|
_factor_predicate([:contradiction, false])
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
_factor_predicate([:
|
13
|
+
def identifier(name)
|
14
|
+
_factor_predicate([:identifier, name])
|
15
|
+
end
|
16
|
+
|
17
|
+
def qualified_identifier(qualifier, name)
|
18
|
+
_factor_predicate([:qualified_identifier, qualifier, name])
|
15
19
|
end
|
16
20
|
|
17
21
|
def and(left, right = nil)
|
@@ -41,10 +45,11 @@ module Alf
|
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
44
|
-
def in(
|
45
|
-
|
46
|
-
_factor_predicate([:in,
|
48
|
+
def in(identifier, values)
|
49
|
+
identifier = sexpr(identifier) if identifier.is_a?(Symbol)
|
50
|
+
_factor_predicate([:in, identifier, values])
|
47
51
|
end
|
52
|
+
alias :among :in
|
48
53
|
|
49
54
|
def comp(op, h)
|
50
55
|
h = h.to_hash
|
@@ -76,8 +81,8 @@ module Alf
|
|
76
81
|
_factor_predicate([:literal, literal])
|
77
82
|
end
|
78
83
|
|
79
|
-
def native(
|
80
|
-
_factor_predicate([:native,
|
84
|
+
def native(arg)
|
85
|
+
_factor_predicate([:native, arg])
|
81
86
|
end
|
82
87
|
|
83
88
|
def sexpr(expr)
|
@@ -86,7 +91,7 @@ module Alf
|
|
86
91
|
when Predicate then expr.expr
|
87
92
|
when TrueClass then Grammar.sexpr([:tautology, true])
|
88
93
|
when FalseClass then Grammar.sexpr([:contradiction, false])
|
89
|
-
when Symbol then Grammar.sexpr([:
|
94
|
+
when Symbol then Grammar.sexpr([:identifier, expr])
|
90
95
|
when Proc then Grammar.sexpr([:native, expr])
|
91
96
|
when Array then Grammar.sexpr(expr)
|
92
97
|
else
|
@@ -11,10 +11,6 @@ module Alf
|
|
11
11
|
Expr
|
12
12
|
end
|
13
13
|
|
14
|
-
def parser
|
15
|
-
Parser.new
|
16
|
-
end
|
17
|
-
|
18
14
|
end
|
19
15
|
end # class Predicate
|
20
16
|
end # module Alf
|
@@ -23,7 +19,8 @@ require_relative 'nodes/dyadic_comp'
|
|
23
19
|
require_relative 'nodes/nadic_bool'
|
24
20
|
require_relative 'nodes/tautology'
|
25
21
|
require_relative 'nodes/contradiction'
|
26
|
-
require_relative 'nodes/
|
22
|
+
require_relative 'nodes/identifier'
|
23
|
+
require_relative 'nodes/qualified_identifier'
|
27
24
|
require_relative 'nodes/and'
|
28
25
|
require_relative 'nodes/or'
|
29
26
|
require_relative 'nodes/not'
|
@@ -2,7 +2,7 @@ rules:
|
|
2
2
|
predicate:
|
3
3
|
- tautology
|
4
4
|
- contradiction
|
5
|
-
-
|
5
|
+
- identifier
|
6
6
|
- not
|
7
7
|
- and
|
8
8
|
- or
|
@@ -18,8 +18,10 @@ rules:
|
|
18
18
|
- [ true ]
|
19
19
|
contradiction:
|
20
20
|
- [ false ]
|
21
|
-
|
22
|
-
- [
|
21
|
+
identifier:
|
22
|
+
- [ name ]
|
23
|
+
qualified_identifier:
|
24
|
+
- [ name, name ]
|
23
25
|
not:
|
24
26
|
- [ predicate ]
|
25
27
|
and:
|
@@ -39,16 +41,18 @@ rules:
|
|
39
41
|
gte:
|
40
42
|
- [ term, term ]
|
41
43
|
in:
|
42
|
-
- [
|
44
|
+
- [ varref, values ]
|
43
45
|
term:
|
44
|
-
-
|
46
|
+
- varref
|
45
47
|
- literal
|
48
|
+
varref:
|
49
|
+
- qualified_identifier
|
50
|
+
- identifier
|
46
51
|
native:
|
47
52
|
- [ "::Proc" ]
|
48
53
|
literal:
|
49
54
|
- "::Object"
|
50
55
|
values:
|
51
56
|
- "::Object"
|
52
|
-
|
57
|
+
name:
|
53
58
|
!ruby/regexp /^[a-zA-Z0-9_]+[?!]?$/
|
54
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -41,19 +41,24 @@ module Alf
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def rename(renaming)
|
44
|
-
Renamer.call(self, :renaming => renaming
|
44
|
+
Renamer.call(self, :renaming => renaming)
|
45
|
+
end
|
46
|
+
|
47
|
+
def qualify(qualifier)
|
48
|
+
Qualifier.new(qualifier).call(self)
|
45
49
|
end
|
46
50
|
|
47
51
|
def constant_variables
|
48
52
|
AttrList::EMPTY
|
49
53
|
end
|
50
54
|
|
51
|
-
def to_ruby_code(
|
52
|
-
ToRubyCode.call(self,
|
55
|
+
def to_ruby_code(scope = 't')
|
56
|
+
code = ToRubyCode.call(self, scope: scope)
|
57
|
+
"->(t){ #{code} }"
|
53
58
|
end
|
54
59
|
|
55
|
-
def to_proc(
|
56
|
-
|
60
|
+
def to_proc(scope = 't')
|
61
|
+
Kernel.eval(to_ruby_code(scope))
|
57
62
|
end
|
58
63
|
|
59
64
|
def sexpr(arg)
|
File without changes
|
File without changes
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Alf
|
2
2
|
class Predicate
|
3
|
-
module
|
3
|
+
module Identifier
|
4
4
|
include Expr
|
5
5
|
|
6
6
|
def priority
|
7
7
|
100
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def name
|
11
11
|
self[1]
|
12
12
|
end
|
13
13
|
|
14
14
|
def free_variables
|
15
|
-
@free_variables ||= AttrList[
|
15
|
+
@free_variables ||= AttrList[ name ]
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|