OPTIMADE-Filter-0.11.0/0000775000200400020040000000000014776215332014110 5ustar andriusandriusOPTIMADE-Filter-0.11.0/dist.ini0000644000200400020040000000154714776215332015561 0ustar andriusandriusname = OPTIMADE-Filter author = Andrius Merkys license = LGPL_3_0 copyright_holder = Andrius Merkys copyright_year = 2016-2025 version = 0.11.0 [@Filter] -bundle = @Basic -remove = MakeMaker -remove = License [AutoMetaResources] homepage = https://search.cpan.org/dist/%{dist} repository.github = user:Materials-Consortia bugtracker.github = user:Materials-Consortia [MetaJSON] [ModuleBuild] mb_class = Module::Build::Parse::Yapp build_element = yp [OurPkgVersion] [Prereqs] List::Util = 0 Parse::Yapp = 0 Scalar::Util = 0 [Prereqs / Build] -phase = build Module::Build::Parse::Yapp = 0 [Prereqs / Configure] -phase = configure Module::Build::Parse::Yapp = 0 [Prereqs / Test] -phase = test Data::Compare = 0 Data::Dumper = 0 File::Spec = 0 List::Util = 0 Math::BigInt = 0 Parse::Yapp = 0 Scalar::Util = 0 Test::More = 0 OPTIMADE-Filter-0.11.0/Changes0000644000200400020040000000674214776215332015412 0ustar andriusandrius0.11.0 2025-04-11 - Declare conformance to OPTIMADE specification v1.2.0. - Implement boolean value support. - Implement support for fuzzy comparisons on lists. 0.10.2 2021-01-23 - Fixing repository and issue tracker URLs. 0.10.1 2021-01-22 - Acknowledging conformance to OPTiMaDe specification v1.0.0. - Adding version numbers to all modules. - Correcting copyright years. - Adding homepage and pointers to GitHub. 0.10.0 2020-06-09 - Reducing the number of parentheses in produced SQL statements. Introducing an option to flatten homogeneous AND/OR subtrees. 0.9.0 2020-05-05 - Introducing interface OPTIMADE::Filter::Modifiable which is used to detect objects that could be modified using modify(). - Overriding equality operators for OPTIMADE::Filter::Property. 0.8.0 2020-03-25 - Renaming package from OPTiMaDe::Filter to OPTIMADE::Filter. - Allowing uppercase characters in properties, however, they are lowercased prior to filter string generation. 0.7.3 2020-03-09 - Implementing the validation of property's syntax. 0.7.2 2020-03-01 - Readding tests. 0.7.1 2020-02-25 - Switching from ExtUtils::MakeMaker to Module::Build-based build system thus making the build process more portable. 0.7.0 2020-01-12 - Acknowledging conformance to OPTiMaDe specification v1.0.0-rc.1. - Validating objects prior to generating their representations in order not to produce erroneous representations. - Fixing the build system as it did not build the Yapp parser properly. - Adding repository metadata (thanks Mohammad S Anwar). 0.6.1 2020-01-30 - Fixing the build system to create source-only tarballs, and to build the parser via 'perl Makefile.PL && make'. 0.6.0 2019-12-12 - Changing the syntax of 'LENGTH' comparison as per Materials-Consortia/OPTiMaDe#221. 0.5.0 2019-12-09 - Renaming package from OPTiMaDe::FilterParser to OPTiMaDe::Filter. - Implementing right-hand side properties as per Materials-Consortia/OPTiMaDe#178. - Properties of three or more identifiers have no SQL representation. - Replacing OPTiMaDe::Filter::Comparison::set_operator() with operator(). - Replacing OPTiMaDe::Filter::ListComparison::set_() with (). - Replacing OPTiMaDe::Filter::Zip::set_() with (). 0.4.1 2019-12-05 - Fixing SQL placeholders for fuzzy search of strings. 0.4.0 2019-12-05 - Adding overloads for OPTiMaDe::FilterParser::Property. Replacing push_identifier() via direct push to object. - Adding convenience methods left() and right() for OPTiMaDe::FilterParser::Comparison. - Introducing classes OPTiMaDe::FilterParser::Negation, OPTiMaDe::FilterParser::AndOr and OPTiMaDe::FilterParser::Known. - Changing the way the delimiter is passed to to_SQL() methods. - Implementing SQL output with placeholders instead of values. 0.3.0 2019-08-19 - Introducing method modify(), which traverses and modifies the built filter tree. - Modifying the constructor for OPTiMaDe::FilterParser::Property. - Adding 'Changes' (this file) to MANIFEST. 0.2.0 2019-08-12 - Combining 'IS' and 'KNOWN'/'UNKNOWN' lexems together. - Fixing 'IS KNOWN'/'IS UNKNOWN' translation to SQL. - Implementing backwards translation to the string representation. - Unifying layout of parsed lists. - Adding roundtrip tests. 0.1.0 2019-07-20 - Initial release. OPTIMADE-Filter-0.11.0/README0000644000200400020040000000054014776215332014765 0ustar andriusandriusThis archive contains the distribution OPTIMADE-Filter, version 0.11.0: OPTIMADE filter language parser/composer This software is Copyright (c) 2016-2025 by Andrius Merkys. This is free software, licensed under: The GNU Lesser General Public License, Version 3, June 2007 This README file was generated by Dist::Zilla::Plugin::Readme v6.012. OPTIMADE-Filter-0.11.0/tests/0000775000200400020040000000000014776215332015252 5ustar andriusandriusOPTIMADE-Filter-0.11.0/tests/cases/0000775000200400020040000000000014776215332016350 5ustar andriusandriusOPTIMADE-Filter-0.11.0/tests/cases/parse_017.inp0000644000200400020040000000003214776215332020552 0ustar andriusandrius((NOT (a>b)) NOT ((x>0))) OPTIMADE-Filter-0.11.0/tests/cases/parse_035.inp0000644000200400020040000000003014776215332020550 0ustar andriusandriusauthors LIKE "%Darwin%" OPTIMADE-Filter-0.11.0/tests/cases/parse_014.inp0000644000200400020040000000005114776215332020550 0ustar andriusandriusfield = "!#$%&'()*+,-./:;<=>?@[]^`{|}~%" OPTIMADE-Filter-0.11.0/tests/cases/parse_008.inp0000644000200400020040000000001314776215332020551 0ustar andriusandrius key=value OPTIMADE-Filter-0.11.0/tests/cases/parse_003.inp0000644000200400020040000000002714776215332020551 0ustar andriusandrius_cod_cell_volume<100.0 OPTIMADE-Filter-0.11.0/tests/cases/parse_010.inp0000644000200400020040000000001314776215332020542 0ustar andriusandriusNOTice=val OPTIMADE-Filter-0.11.0/tests/cases/parse_037.inp0000644000200400020040000000010714776215332020557 0ustar andriusandriusprototype_formula CONTAINS "C2" AND prototype_formula STARTS WITH "A2" OPTIMADE-Filter-0.11.0/tests/cases/parse_026.inp0000644000200400020040000000021514776215332020555 0ustar andriusandriuselements HAS "H" AND elements HAS ALL "H","He","Ga","Ta" AND elements HAS ONLY "H","He","Ga","Ta" AND elements HAS ANY "H", "He", "Ga", "Ta" OPTIMADE-Filter-0.11.0/tests/cases/parse_028.inp0000644000200400020040000000040414776215332020557 0ustar andriusandriuselements:_exmpl_element_counts HAS "H":6 AND elements:_exmpl_element_counts HAS ALL "H":6,"He":7 AND elements:_exmpl_element_counts HAS ONLY "H":6 AND elements:_exmpl_element_counts HAS ANY "H":6,"He":7 AND elements:_exmpl_element_counts HAS ONLY "H":6,"He":7 OPTIMADE-Filter-0.11.0/tests/cases/parse_002.inp0000644000200400020040000000002014776215332020541 0ustar andriusandriusspacegroup="P2" OPTIMADE-Filter-0.11.0/tests/cases/parse_031.inp0000644000200400020040000000011514776215332020550 0ustar andriusandriuschemical_formula_hill IS KNOWN AND NOT chemical_formula_anonymous IS UNKNOWN OPTIMADE-Filter-0.11.0/tests/cases/parse_004.inp0000644000200400020040000000006214776215332020551 0ustar andriusandrius_mp_bandgap > 5.0 AND _cod_molecular_weight < 350 OPTIMADE-Filter-0.11.0/tests/cases/parse_045.inp0000644000200400020040000000003414776215332020555 0ustar andriusandriusNOT boolean_valued_property OPTIMADE-Filter-0.11.0/tests/cases/parse_048.inp0000644000200400020040000000003214776215332020556 0ustar andriusandriustitle HAS ENDS WITH "MOF" OPTIMADE-Filter-0.11.0/tests/cases/parse_047.inp0000644000200400020040000000006014776215332020556 0ustar andriusandriusname:surname HAS STARTS WITH "J":CONTAINS "Doe" OPTIMADE-Filter-0.11.0/tests/cases/parse_016.inp0000644000200400020040000000002714776215332020555 0ustar andriusandrius ((NOT (a>b)) AND x>0) OPTIMADE-Filter-0.11.0/tests/cases/parse_049.inp0000644000200400020040000000004114776215332020557 0ustar andriusandriuselements HAS ALL STARTS WITH "S" OPTIMADE-Filter-0.11.0/tests/cases/parse_013.inp0000644000200400020040000000031014776215332020545 0ustar andriusandrius a = 12345 AND b = +12 AND c = -34 AND d = 1.2 AND e = .2E7 AND f = -.2E+7 AND g = +10.01E-10 AND h = 6.03e23 AND i = .1E1 AND j = -.1e1 AND k = 1.e-12 AND l = -.1e-12 AND m = 1000000000.E1000000000 OPTIMADE-Filter-0.11.0/tests/cases/parse_023.inp0000644000200400020040000000000614776215332020550 0ustar andriusandrius5 < 7 OPTIMADE-Filter-0.11.0/tests/cases/parse_043.inp0000644000200400020040000000004114776215332020551 0ustar andriusandriusTRUE = property AND TRUE = FALSE OPTIMADE-Filter-0.11.0/tests/cases/parse_041.inp0000644000200400020040000000001514776215332020550 0ustar andriusandriustrue > FALSE OPTIMADE-Filter-0.11.0/tests/cases/parse_006.inp0000644000200400020040000000015114776215332020552 0ustar andriusandriusnumber=0.ANDnumber=.0ANDnumber=0.0ANDnumber=+0ANDn_u_m_b_e_r=-0ANDnumber=0e1ANDnumber=0e-1ANDnumber=0e+1 OPTIMADE-Filter-0.11.0/tests/cases/parse_036.opt0000644000200400020040000000002114776215332020565 0ustar andriusandriususe_placeholders OPTIMADE-Filter-0.11.0/tests/cases/parse_044.inp0000644000200400020040000000001014776215332020546 0ustar andriusandriusa AND b OPTIMADE-Filter-0.11.0/tests/cases/parse_029.inp0000644000200400020040000000012214776215332020555 0ustar andriusandrius_exmpl_element_counts HAS < 3 AND _exmpl_element_counts HAS ANY > 3, = 6, 4, != 8 OPTIMADE-Filter-0.11.0/tests/cases/parse_015.inp0000644000200400020040000000003614776215332020554 0ustar andriusandrius((NOT (a>b)) AND NOT ((x>0))) OPTIMADE-Filter-0.11.0/tests/cases/parse_033.inp0000644000200400020040000000012314776215332020551 0ustar andriusandriuslist LENGTH < 5 AND list LENGTH = "four" AND list LENGTH >= max_length_of_the_list OPTIMADE-Filter-0.11.0/tests/cases/parse_038.inp0000644000200400020040000000004614776215332020562 0ustar andriusandriusproperty STARTS WITH another_property OPTIMADE-Filter-0.11.0/tests/cases/parse_030.inp0000644000200400020040000000015314776215332020551 0ustar andriusandriuselements:_exmpl_element_counts:_exmpl_element_weights HAS ANY > 3:"He":>55.3 , = 6:>"Ti":<37.6 , 8:<"Ga":0 OPTIMADE-Filter-0.11.0/tests/cases/parse_036.inp0000644000200400020040000000031014776215332020552 0ustar andriusandrius a = 12345 AND b = +12 AND c = -34 AND d = 1.2 AND e = .2E7 AND f = -.2E+7 AND g = +10.01E-10 AND h = 6.03e23 AND i = .1E1 AND j = -.1e1 AND k = 1.e-12 AND l = -.1e-12 AND m = 1000000000.E1000000000 OPTIMADE-Filter-0.11.0/tests/cases/parse_027.inp0000644000200400020040000000004514776215332020557 0ustar andriusandriuselements HAS ONLY "H","He","Ga","Ta" OPTIMADE-Filter-0.11.0/tests/cases/parse_024.inp0000644000200400020040000000010714776215332020553 0ustar andriusandriusprototype_formula CONTAINS "C2" AND prototype_formula STARTS WITH "A2" OPTIMADE-Filter-0.11.0/tests/cases/parse_042.inp0000644000200400020040000000011114776215332020546 0ustar andriusandriusstatements HAS ALL TRUE, = TRUE AND number:is_prime HAS ALL < 100 : TRUE OPTIMADE-Filter-0.11.0/tests/cases/parse_011.inp0000644000200400020040000000003514776215332020547 0ustar andriusandriusauthor="Sąžininga Žąsis" OPTIMADE-Filter-0.11.0/tests/cases/parse_046.inp0000644000200400020040000000003014776215332020552 0ustar andriusandriusboolean_valued_property OPTIMADE-Filter-0.11.0/tests/cases/parse_039.opt0000644000200400020040000000001014776215332020566 0ustar andriusandriusflatten OPTIMADE-Filter-0.11.0/tests/cases/parse_019.inp0000644000200400020040000000014014776215332020554 0ustar andriusandrius_exmpl_aax <= +.1e8 OR nelements >= 10 AND NOT ( _exmpl_x != "Some string" OR NOT _exmpl_a = 7) OPTIMADE-Filter-0.11.0/tests/cases/parse_034.inp0000644000200400020040000000004014776215332020550 0ustar andriusandriusspecies.chemical_symbols = "Ti" OPTIMADE-Filter-0.11.0/tests/cases/parse_020.inp0000644000200400020040000000004114776215332020544 0ustar andriusandrius_exmpl_some_string_property = 42 OPTIMADE-Filter-0.11.0/tests/cases/parse_032.inp0000644000200400020040000000004514776215332020553 0ustar andriusandriuslist CONTAINS "string\"with\"quotes" OPTIMADE-Filter-0.11.0/tests/cases/parse_022.inp0000644000200400020040000000005314776215332020551 0ustar andriusandrius((NOT (_exmpl_a>_exmpl_b)) AND _exmpl_x>0) OPTIMADE-Filter-0.11.0/tests/cases/parse_012.inp0000644000200400020040000000003614776215332020551 0ustar andriusandriusauthor="Sąžininga Žąs is" OPTIMADE-Filter-0.11.0/tests/cases/parse_009.inp0000644000200400020040000000002314776215332020553 0ustar andriusandriusauthor=" someone " OPTIMADE-Filter-0.11.0/tests/cases/parse_001.inp0000644000200400020040000000001014776215332020537 0ustar andriusandriuste < st OPTIMADE-Filter-0.11.0/tests/cases/parse_040.inp0000644000200400020040000000011514776215332020550 0ustar andriusandrius((true = TRUE) AND (false = FALSE)) OR ((true != TRUE) AND (false != FALSE)) OPTIMADE-Filter-0.11.0/tests/cases/parse_037.opt0000644000200400020040000000002114776215332020566 0ustar andriusandriususe_placeholders OPTIMADE-Filter-0.11.0/tests/cases/parse_005.inp0000644000200400020040000000007414776215332020555 0ustar andriusandrius_cod_melting_point<300 AND nelements=4 AND elements="Si,O2" OPTIMADE-Filter-0.11.0/tests/cases/parse_035.opt0000644000200400020040000000002414776215332020567 0ustar andriusandriusallow_LIKE_operator OPTIMADE-Filter-0.11.0/tests/cases/parse_018.inp0000644000200400020040000000017114776215332020557 0ustar andriusandriusNOT ( chemical_formula = "Al" AND prototype_formula = "A" OR prototype_formula = "H2O" AND NOT chemical_formula = "Ti" ) OPTIMADE-Filter-0.11.0/tests/cases/parse_007.inp0000644000200400020040000000001514776215332020552 0ustar andriusandriusnumber=0.0.1 OPTIMADE-Filter-0.11.0/tests/cases/parse_039.inp0000644000200400020040000000011514776215332020560 0ustar andriusandrius(a = 1 AND b = 2 AND c = 3) OR d = 4 OR e = 5 OR (f = 6) OR (g = 7 OR h = 8) OPTIMADE-Filter-0.11.0/tests/cases/parse_025.inp0000644000200400020040000000010314776215332020550 0ustar andriusandriusprototype_formula STARTS "B2" AND prototype_formula ENDS WITH "D2" OPTIMADE-Filter-0.11.0/tests/cases/parse_021.inp0000644000200400020040000000001514776215332020546 0ustar andriusandrius5 < _exmpl_a OPTIMADE-Filter-0.11.0/tests/outputs/0000775000200400020040000000000014776215332016775 5ustar andriusandriusOPTIMADE-Filter-0.11.0/tests/outputs/modify_003.out0000644000200400020040000000175214776215332021402 0ustar andriusandrius$VAR1 = [ bless( { 'name' => [ 'value', 'list' ] }, 'OPTIMADE::Filter::Property' ), '=', 'a', '=', 'b', '=', 'c', bless( { 'operator' => 'HAS ALL', 'property' => $VAR1->[0], 'values' => [ [ '=', 'a' ], [ '=', 'b' ], [ '=', 'c' ] ] }, 'OPTIMADE::Filter::ListComparison' ) ]; OPTIMADE-Filter-0.11.0/tests/outputs/parse_028.out0000644000200400020040000005106714776215332021240 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operator' => 'HAS', 'properties' => [ bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ '_exmpl_element_counts' ] }, 'OPTIMADE::Filter::Property' ) ], 'values' => [ [ [ '=', 'H' ], [ '=', '6' ] ] ] }, 'OPTIMADE::Filter::Zip' ), bless( { 'operands' => [ bless( { 'operator' => 'HAS ALL', 'properties' => [ bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ '_exmpl_element_counts' ] }, 'OPTIMADE::Filter::Property' ) ], 'values' => [ [ [ '=', 'H' ], [ '=', '6' ] ], [ [ '=', 'He' ], [ '=', '7' ] ] ] }, 'OPTIMADE::Filter::Zip' ), bless( { 'operands' => [ bless( { 'operator' => 'HAS ONLY', 'properties' => [ bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ '_exmpl_element_counts' ] }, 'OPTIMADE::Filter::Property' ) ], 'values' => [ [ [ '=', 'H' ], [ '=', '6' ] ] ] }, 'OPTIMADE::Filter::Zip' ), bless( { 'operands' => [ bless( { 'operator' => 'HAS ANY', 'properties' => [ bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ '_exmpl_element_counts' ] }, 'OPTIMADE::Filter::Property' ) ], 'values' => [ [ [ '=', 'H' ], [ '=', '6' ] ], [ [ '=', 'He' ], [ '=', '7' ] ] ] }, 'OPTIMADE::Filter::Zip' ), bless( { 'operator' => 'HAS ONLY', 'properties' => [ bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ '_exmpl_element_counts' ] }, 'OPTIMADE::Filter::Property' ) ], 'values' => [ [ [ '=', 'H' ], [ '=', '6' ] ], [ [ '=', 'He' ], [ '=', '7' ] ] ] }, 'OPTIMADE::Filter::Zip' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((elements:_exmpl_element_counts HAS = "H" : = "6") AND ((elements:_exmpl_element_counts HAS ALL = "H" : = "6", = "He" : = "7") AND ((elements:_exmpl_element_counts HAS ONLY = "H" : = "6") AND ((elements:_exmpl_element_counts HAS ANY = "H" : = "6", = "He" : = "7") AND (elements:_exmpl_element_counts HAS ONLY = "H" : = "6", = "He" : = "7"))))) == SQL == AND ( AND ( AND ( AND ))) OPTIMADE-Filter-0.11.0/tests/outputs/parse_019.out0000644000200400020040000001521514776215332021233 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ '_exmpl_aax' ] }, 'OPTIMADE::Filter::Property' ), '+.1e8' ], 'operator' => '<=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'nelements' ] }, 'OPTIMADE::Filter::Property' ), '10' ], 'operator' => '>=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'inner' => bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ '_exmpl_x' ] }, 'OPTIMADE::Filter::Property' ), 'Some string' ], 'operator' => '!=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'inner' => bless( { 'operands' => [ bless( { 'name' => [ '_exmpl_a' ] }, 'OPTIMADE::Filter::Property' ), '7' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) }, 'OPTIMADE::Filter::Negation' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ) }, 'OPTIMADE::Filter::Negation' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((_exmpl_aax <= "+.1e8") OR ((nelements >= "10") AND (NOT ((_exmpl_x != "Some string") OR (NOT (_exmpl_a = "7")))))) == SQL == '_exmpl_aax' <= "+.1e8" OR ('nelements' >= "10" AND NOT ('_exmpl_x' != "Some string" OR NOT ('_exmpl_a' = "7"))) OPTIMADE-Filter-0.11.0/tests/outputs/modify_002.out0000644000200400020040000000241214776215332021373 0ustar andriusandrius$VAR1 = [ [ bless( { 'operands' => [ bless( { 'name' => [ 'value', 'list' ] }, 'OPTIMADE::Filter::Property' ), 'a' ], 'operator' => 'CONTAINS' }, 'OPTIMADE::Filter::Comparison' ), 'AND', bless( { 'operands' => [ $VAR1->[0][0]{'operands'}[0], 'b' ], 'operator' => 'CONTAINS' }, 'OPTIMADE::Filter::Comparison' ) ], 'AND', bless( { 'operands' => [ $VAR1->[0][0]{'operands'}[0], 'c' ], 'operator' => 'CONTAINS' }, 'OPTIMADE::Filter::Comparison' ) ]; OPTIMADE-Filter-0.11.0/tests/outputs/parse_004.out0000644000200400020040000000352214776215332021223 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ '_mp_bandgap' ] }, 'OPTIMADE::Filter::Property' ), '5.0' ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ '_cod_molecular_weight' ] }, 'OPTIMADE::Filter::Property' ), '350' ], 'operator' => '<' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((_mp_bandgap > "5.0") AND (_cod_molecular_weight < "350")) == SQL == '_mp_bandgap' > "5.0" AND '_cod_molecular_weight' < "350" OPTIMADE-Filter-0.11.0/tests/outputs/parse_047.out0000644000200400020040000000243414776215332021233 0ustar andriusandriusno SQL representation $VAR1 = bless( { 'operator' => 'HAS', 'properties' => [ bless( { 'name' => [ 'name' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ 'surname' ] }, 'OPTIMADE::Filter::Property' ) ], 'values' => [ [ [ 'STARTS WITH', 'J' ], [ 'CONTAINS', 'Doe' ] ] ] }, 'OPTIMADE::Filter::Zip' ); == Filter == (name:surname HAS STARTS WITH "J" : CONTAINS "Doe") == SQL == OPTIMADE-Filter-0.11.0/tests/outputs/parse_014.out0000644000200400020040000000117214776215332021223 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'field' ] }, 'OPTIMADE::Filter::Property' ), '!#$%&\'()*+,-./:;<=>?@[]^`{|}~%' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (field = "!#$%&'()*+,-./:;<=>?@[]^`{|}~%") == SQL == 'field' = "!#$%&'()*+,-./:;<=>?@[]^`{|}~%" OPTIMADE-Filter-0.11.0/tests/outputs/parse_031.out0000644000200400020040000000342714776215332021227 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'is_known' => 1, 'property' => bless( { 'name' => [ 'chemical_formula_hill' ] }, 'OPTIMADE::Filter::Property' ) }, 'OPTIMADE::Filter::Known' ), bless( { 'inner' => bless( { 'is_known' => 0, 'property' => bless( { 'name' => [ 'chemical_formula_anonymous' ] }, 'OPTIMADE::Filter::Property' ) }, 'OPTIMADE::Filter::Known' ) }, 'OPTIMADE::Filter::Negation' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == (chemical_formula_hill IS KNOWN AND (NOT chemical_formula_anonymous IS UNKNOWN)) == SQL == 'chemical_formula_hill' IS NOT NULL AND NOT ('chemical_formula_anonymous' IS NULL) OPTIMADE-Filter-0.11.0/tests/outputs/parse_012.out0000644000200400020040000000006614776215332021222 0ustar andriusandriust/02parse.t: syntax error at line 0, position 52: ''. OPTIMADE-Filter-0.11.0/tests/outputs/parse_045.out0000644000200400020040000000204014776215332021222 0ustar andriusandriusno SQL representation $VAR1 = bless( { 'inner' => bless( { 'operands' => [ bless( { 'name' => [ 'boolean_valued_property' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) }, 'OPTIMADE::Filter::Negation' ); == Filter == (NOT (boolean_valued_property = TRUE)) == SQL == OPTIMADE-Filter-0.11.0/tests/outputs/parse_013.out0000644000200400020040000012205414776215332021225 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'a' ] }, 'OPTIMADE::Filter::Property' ), '12345' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'b' ] }, 'OPTIMADE::Filter::Property' ), '+12' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'c' ] }, 'OPTIMADE::Filter::Property' ), '-34' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'd' ] }, 'OPTIMADE::Filter::Property' ), '1.2' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'e' ] }, 'OPTIMADE::Filter::Property' ), '.2E7' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'f' ] }, 'OPTIMADE::Filter::Property' ), '-.2E+7' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'g' ] }, 'OPTIMADE::Filter::Property' ), '+10.01E-10' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'h' ] }, 'OPTIMADE::Filter::Property' ), '6.03e23' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'i' ] }, 'OPTIMADE::Filter::Property' ), '.1E1' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'j' ] }, 'OPTIMADE::Filter::Property' ), '-.1e1' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'k' ] }, 'OPTIMADE::Filter::Property' ), '1.e-12' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'l' ] }, 'OPTIMADE::Filter::Property' ), '-.1e-12' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'm' ] }, 'OPTIMADE::Filter::Property' ), '1000000000.E1000000000' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((a = "12345") AND ((b = "+12") AND ((c = "-34") AND ((d = "1.2") AND ((e = ".2E7") AND ((f = "-.2E+7") AND ((g = "+10.01E-10") AND ((h = "6.03e23") AND ((i = ".1E1") AND ((j = "-.1e1") AND ((k = "1.e-12") AND ((l = "-.1e-12") AND (m = "1000000000.E1000000000"))))))))))))) == SQL == 'a' = "12345" AND ('b' = "+12" AND ('c' = "-34" AND ('d' = "1.2" AND ('e' = ".2E7" AND ('f' = "-.2E+7" AND ('g' = "+10.01E-10" AND ('h' = "6.03e23" AND ('i' = ".1E1" AND ('j' = "-.1e1" AND ('k' = "1.e-12" AND ('l' = "-.1e-12" AND 'm' = "1000000000.E1000000000"))))))))))) OPTIMADE-Filter-0.11.0/tests/outputs/parse_011.out0000644000200400020040000000113314776215332021215 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'author' ] }, 'OPTIMADE::Filter::Property' ), 'Sąžininga Žąsis' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (author = "Sąžininga Žąsis") == SQL == 'author' = "Sąžininga Žąsis" OPTIMADE-Filter-0.11.0/tests/outputs/parse_030.out0000644000200400020040000000553114776215332021224 0ustar andriusandriusno SQL representation $VAR1 = bless( { 'operator' => 'HAS ANY', 'properties' => [ bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ '_exmpl_element_counts' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ '_exmpl_element_weights' ] }, 'OPTIMADE::Filter::Property' ) ], 'values' => [ [ [ '>', '3' ], [ '=', 'He' ], [ '>', '55.3' ] ], [ [ '=', '6' ], [ '>', 'Ti' ], [ '<', '37.6' ] ], [ [ '=', '8' ], [ '<', 'Ga' ], [ '=', '0' ] ] ] }, 'OPTIMADE::Filter::Zip' ); == Filter == (elements:_exmpl_element_counts:_exmpl_element_weights HAS ANY > "3" : = "He" : > "55.3", = "6" : > "Ti" : < "37.6", = "8" : < "Ga" : = "0") == SQL == OPTIMADE-Filter-0.11.0/tests/outputs/parse_027.out0000644000200400020040000000214314776215332021226 0ustar andriusandriusno SQL representation $VAR1 = bless( { 'operator' => 'HAS ONLY', 'property' => bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '=', 'H' ], [ '=', 'He' ], [ '=', 'Ga' ], [ '=', 'Ta' ] ] }, 'OPTIMADE::Filter::ListComparison' ); == Filter == (elements HAS ONLY = "H", = "He", = "Ga", = "Ta") == SQL == OPTIMADE-Filter-0.11.0/tests/outputs/parse_018.out0000644000200400020040000001543714776215332021240 0ustar andriusandrius$VAR1 = bless( { 'inner' => bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'chemical_formula' ] }, 'OPTIMADE::Filter::Property' ), 'Al' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'prototype_formula' ] }, 'OPTIMADE::Filter::Property' ), 'A' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'prototype_formula' ] }, 'OPTIMADE::Filter::Property' ), 'H2O' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'inner' => bless( { 'operands' => [ bless( { 'name' => [ 'chemical_formula' ] }, 'OPTIMADE::Filter::Property' ), 'Ti' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) }, 'OPTIMADE::Filter::Negation' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ) }, 'OPTIMADE::Filter::Negation' ); == Filter == (NOT (((chemical_formula = "Al") AND (prototype_formula = "A")) OR ((prototype_formula = "H2O") AND (NOT (chemical_formula = "Ti"))))) == SQL == NOT (('chemical_formula' = "Al" AND 'prototype_formula' = "A") OR ('prototype_formula' = "H2O" AND NOT ('chemical_formula' = "Ti"))) OPTIMADE-Filter-0.11.0/tests/outputs/parse_035.out0000644000200400020040000000110614776215332021223 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'authors' ] }, 'OPTIMADE::Filter::Property' ), '%Darwin%' ], 'operator' => 'LIKE' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (authors LIKE "%Darwin%") == SQL == 'authors' LIKE "%Darwin%" OPTIMADE-Filter-0.11.0/tests/outputs/parse_038.out0000644000200400020040000000154214776215332021232 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'property' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ 'another_property' ] }, 'OPTIMADE::Filter::Property' ) ], 'operator' => 'STARTS WITH' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (property STARTS WITH another_property) == SQL == 'property' LIKE 'another_property' OPTIMADE-Filter-0.11.0/tests/outputs/parse_006.out0000644000200400020040000004257514776215332021240 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'number' ] }, 'OPTIMADE::Filter::Property' ), '0.' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'number' ] }, 'OPTIMADE::Filter::Property' ), '.0' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'number' ] }, 'OPTIMADE::Filter::Property' ), '0.0' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'number' ] }, 'OPTIMADE::Filter::Property' ), '+0' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'n_u_m_b_e_r' ] }, 'OPTIMADE::Filter::Property' ), '-0' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'number' ] }, 'OPTIMADE::Filter::Property' ), '0e1' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'number' ] }, 'OPTIMADE::Filter::Property' ), '0e-1' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'number' ] }, 'OPTIMADE::Filter::Property' ), '0e+1' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((number = "0.") AND ((number = ".0") AND ((number = "0.0") AND ((number = "+0") AND ((n_u_m_b_e_r = "-0") AND ((number = "0e1") AND ((number = "0e-1") AND (number = "0e+1")))))))) == SQL == 'number' = "0." AND ('number' = ".0" AND ('number' = "0.0" AND ('number' = "+0" AND ('n_u_m_b_e_r' = "-0" AND ('number' = "0e1" AND ('number' = "0e-1" AND 'number' = "0e+1")))))) OPTIMADE-Filter-0.11.0/tests/outputs/parse_049.out0000644000200400020040000000126014776215332021231 0ustar andriusandriusno SQL representation $VAR1 = bless( { 'operator' => 'HAS ALL', 'property' => bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ 'STARTS WITH', 'S' ] ] }, 'OPTIMADE::Filter::ListComparison' ); == Filter == (elements HAS ALL STARTS WITH "S") == SQL == OPTIMADE-Filter-0.11.0/tests/outputs/parse_033.out0000644000200400020040000001106214776215332021223 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operator' => 'LENGTH', 'property' => bless( { 'name' => [ 'list' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '<', '5' ] ] }, 'OPTIMADE::Filter::ListComparison' ), bless( { 'operands' => [ bless( { 'operator' => 'LENGTH', 'property' => bless( { 'name' => [ 'list' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '=', 'four' ] ] }, 'OPTIMADE::Filter::ListComparison' ), bless( { 'operator' => 'LENGTH', 'property' => bless( { 'name' => [ 'list' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '>=', bless( { 'name' => [ 'max_length_of_the_list' ] }, 'OPTIMADE::Filter::Property' ) ] ] }, 'OPTIMADE::Filter::ListComparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((list LENGTH < "5") AND ((list LENGTH = "four") AND (list LENGTH >= max_length_of_the_list))) == SQL == AND ( AND ) OPTIMADE-Filter-0.11.0/tests/outputs/modify_001.out0000644000200400020040000000635314776215332021402 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'a' ] }, 'OPTIMADE::Filter::Property' ), '5' ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'b' ] }, 'OPTIMADE::Filter::Property' ), '2' ], 'operator' => '<' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'c' ] }, 'OPTIMADE::Filter::Property' ), '10' ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ); OPTIMADE-Filter-0.11.0/tests/outputs/parse_002.out0000644000200400020040000000106414776215332021220 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'spacegroup' ] }, 'OPTIMADE::Filter::Property' ), 'P2' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (spacegroup = "P2") == SQL == 'spacegroup' = "P2" OPTIMADE-Filter-0.11.0/tests/outputs/parse_034.out0000644000200400020040000000123114776215332021221 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'species', 'chemical_symbols' ] }, 'OPTIMADE::Filter::Property' ), 'Ti' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (species.chemical_symbols = "Ti") == SQL == 'species'.'chemical_symbols' = "Ti" OPTIMADE-Filter-0.11.0/tests/outputs/parse_010.out0000644000200400020040000000221714776215332021220 0ustar andriusandrius$VAR1 = bless( { 'inner' => bless( { 'operands' => [ bless( { 'name' => [ 'ice' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ 'val' ] }, 'OPTIMADE::Filter::Property' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) }, 'OPTIMADE::Filter::Negation' ); == Filter == (NOT (ice = val)) == SQL == NOT ('ice' = 'val') OPTIMADE-Filter-0.11.0/tests/outputs/parse_023.out0000644000200400020040000000044314776215332021223 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ '5', '7' ], 'operator' => '<' }, 'OPTIMADE::Filter::Comparison' ); == Filter == ("5" < "7") == SQL == "5" < "7" OPTIMADE-Filter-0.11.0/tests/outputs/parse_036.out0000644000200400020040000012237014776215332021233 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'a' ] }, 'OPTIMADE::Filter::Property' ), '12345' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'b' ] }, 'OPTIMADE::Filter::Property' ), '+12' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'c' ] }, 'OPTIMADE::Filter::Property' ), '-34' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'd' ] }, 'OPTIMADE::Filter::Property' ), '1.2' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'e' ] }, 'OPTIMADE::Filter::Property' ), '.2E7' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'f' ] }, 'OPTIMADE::Filter::Property' ), '-.2E+7' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'g' ] }, 'OPTIMADE::Filter::Property' ), '+10.01E-10' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'h' ] }, 'OPTIMADE::Filter::Property' ), '6.03e23' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'i' ] }, 'OPTIMADE::Filter::Property' ), '.1E1' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'j' ] }, 'OPTIMADE::Filter::Property' ), '-.1e1' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'k' ] }, 'OPTIMADE::Filter::Property' ), '1.e-12' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'l' ] }, 'OPTIMADE::Filter::Property' ), '-.1e-12' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'm' ] }, 'OPTIMADE::Filter::Property' ), '1000000000.E1000000000' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((a = "12345") AND ((b = "+12") AND ((c = "-34") AND ((d = "1.2") AND ((e = ".2E7") AND ((f = "-.2E+7") AND ((g = "+10.01E-10") AND ((h = "6.03e23") AND ((i = ".1E1") AND ((j = "-.1e1") AND ((k = "1.e-12") AND ((l = "-.1e-12") AND (m = "1000000000.E1000000000"))))))))))))) == SQL == 'a' = ? AND ('b' = ? AND ('c' = ? AND ('d' = ? AND ('e' = ? AND ('f' = ? AND ('g' = ? AND ('h' = ? AND ('i' = ? AND ('j' = ? AND ('k' = ? AND ('l' = ? AND 'm' = ?))))))))))) === Values === $VAR1 = [ '12345', '+12', '-34', '1.2', '.2E7', '-.2E+7', '+10.01E-10', '6.03e23', '.1E1', '-.1e1', '1.e-12', '-.1e-12', '1000000000.E1000000000' ]; OPTIMADE-Filter-0.11.0/tests/outputs/parse_017.out0000644000200400020040000000007714776215332021231 0ustar andriusandriust/02parse.t: syntax error at line 0, position 88: ' ((x>0)))'. OPTIMADE-Filter-0.11.0/tests/outputs/parse_022.out0000644000200400020040000000505614776215332021227 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'inner' => bless( { 'operands' => [ bless( { 'name' => [ '_exmpl_a' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ '_exmpl_b' ] }, 'OPTIMADE::Filter::Property' ) ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ) }, 'OPTIMADE::Filter::Negation' ), bless( { 'operands' => [ bless( { 'name' => [ '_exmpl_x' ] }, 'OPTIMADE::Filter::Property' ), '0' ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((NOT (_exmpl_a > _exmpl_b)) AND (_exmpl_x > "0")) == SQL == NOT ('_exmpl_a' > '_exmpl_b') AND '_exmpl_x' > "0" OPTIMADE-Filter-0.11.0/tests/outputs/parse_040.out0000644000200400020040000001367514776215332021235 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'true' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'false' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'value' => '' }, 'OPTIMADE::Filter::Boolean' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'true' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ) ], 'operator' => '!=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'false' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'value' => '' }, 'OPTIMADE::Filter::Boolean' ) ], 'operator' => '!=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ); == Filter == (((true = TRUE) AND (false = FALSE)) OR ((true != TRUE) AND (false != FALSE))) == SQL == ( AND ) OR ( AND ) OPTIMADE-Filter-0.11.0/tests/outputs/parse_041.out0000644000200400020040000000006614776215332021224 0ustar andriusandriust/02parse.t: syntax error at line 0, position 21: ''. OPTIMADE-Filter-0.11.0/tests/outputs/parse_021.out0000644000200400020040000000105314776215332021217 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ '5', bless( { 'name' => [ '_exmpl_a' ] }, 'OPTIMADE::Filter::Property' ) ], 'operator' => '<' }, 'OPTIMADE::Filter::Comparison' ); == Filter == ("5" < _exmpl_a) == SQL == "5" < '_exmpl_a' OPTIMADE-Filter-0.11.0/tests/outputs/parse_009.out0000644000200400020040000000107514776215332021231 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'author' ] }, 'OPTIMADE::Filter::Property' ), ' someone ' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (author = " someone ") == SQL == 'author' = " someone " OPTIMADE-Filter-0.11.0/tests/outputs/parse_048.out0000644000200400020040000000124214776215332021230 0ustar andriusandriusno SQL representation $VAR1 = bless( { 'operator' => 'HAS', 'property' => bless( { 'name' => [ 'title' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ 'ENDS WITH', 'MOF' ] ] }, 'OPTIMADE::Filter::ListComparison' ); == Filter == (title HAS ENDS WITH "MOF") == SQL == OPTIMADE-Filter-0.11.0/tests/outputs/parse_046.out0000644000200400020040000000132414776215332021227 0ustar andriusandriusno SQL representation $VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'boolean_valued_property' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (boolean_valued_property = TRUE) == SQL == OPTIMADE-Filter-0.11.0/tests/outputs/parse_005.out0000644000200400020040000000670614776215332021233 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ '_cod_melting_point' ] }, 'OPTIMADE::Filter::Property' ), '300' ], 'operator' => '<' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'nelements' ] }, 'OPTIMADE::Filter::Property' ), '4' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), 'Si,O2' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((_cod_melting_point < "300") AND ((nelements = "4") AND (elements = "Si,O2"))) == SQL == '_cod_melting_point' < "300" AND ('nelements' = "4" AND 'elements' = "Si,O2") OPTIMADE-Filter-0.11.0/tests/outputs/parse_015.out0000644000200400020040000000551314776215332021227 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'inner' => bless( { 'operands' => [ bless( { 'name' => [ 'a' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ 'b' ] }, 'OPTIMADE::Filter::Property' ) ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ) }, 'OPTIMADE::Filter::Negation' ), bless( { 'inner' => bless( { 'operands' => [ bless( { 'name' => [ 'x' ] }, 'OPTIMADE::Filter::Property' ), '0' ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ) }, 'OPTIMADE::Filter::Negation' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((NOT (a > b)) AND (NOT (x > "0"))) == SQL == NOT ('a' > 'b') AND NOT ('x' > "0") OPTIMADE-Filter-0.11.0/tests/outputs/parse_001.out0000644000200400020040000000141714776215332021221 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'te' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ 'st' ] }, 'OPTIMADE::Filter::Property' ) ], 'operator' => '<' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (te < st) == SQL == 'te' < 'st' OPTIMADE-Filter-0.11.0/tests/outputs/parse_024.out0000644000200400020040000000357514776215332021235 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'prototype_formula' ] }, 'OPTIMADE::Filter::Property' ), 'C2' ], 'operator' => 'CONTAINS' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'prototype_formula' ] }, 'OPTIMADE::Filter::Property' ), 'A2' ], 'operator' => 'STARTS WITH' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((prototype_formula CONTAINS "C2") AND (prototype_formula STARTS WITH "A2")) == SQL == 'prototype_formula' LIKE "%C2%" AND 'prototype_formula' LIKE "A2%" OPTIMADE-Filter-0.11.0/tests/outputs/parse_037.out0000644000200400020040000000367214776215332021237 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'prototype_formula' ] }, 'OPTIMADE::Filter::Property' ), 'C2' ], 'operator' => 'CONTAINS' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'prototype_formula' ] }, 'OPTIMADE::Filter::Property' ), 'A2' ], 'operator' => 'STARTS WITH' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((prototype_formula CONTAINS "C2") AND (prototype_formula STARTS WITH "A2")) == SQL == 'prototype_formula' LIKE ? AND 'prototype_formula' LIKE ? === Values === $VAR1 = [ '%C2%', 'A2%' ]; OPTIMADE-Filter-0.11.0/tests/outputs/parse_026.out0000644000200400020040000002427014776215332021232 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operator' => 'HAS', 'property' => bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '=', 'H' ] ] }, 'OPTIMADE::Filter::ListComparison' ), bless( { 'operands' => [ bless( { 'operator' => 'HAS ALL', 'property' => bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '=', 'H' ], [ '=', 'He' ], [ '=', 'Ga' ], [ '=', 'Ta' ] ] }, 'OPTIMADE::Filter::ListComparison' ), bless( { 'operands' => [ bless( { 'operator' => 'HAS ONLY', 'property' => bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '=', 'H' ], [ '=', 'He' ], [ '=', 'Ga' ], [ '=', 'Ta' ] ] }, 'OPTIMADE::Filter::ListComparison' ), bless( { 'operator' => 'HAS ANY', 'property' => bless( { 'name' => [ 'elements' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '=', 'H' ], [ '=', 'He' ], [ '=', 'Ga' ], [ '=', 'Ta' ] ] }, 'OPTIMADE::Filter::ListComparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((elements HAS = "H") AND ((elements HAS ALL = "H", = "He", = "Ga", = "Ta") AND ((elements HAS ONLY = "H", = "He", = "Ga", = "Ta") AND (elements HAS ANY = "H", = "He", = "Ga", = "Ta")))) == SQL == AND ( AND ( AND )) OPTIMADE-Filter-0.11.0/tests/outputs/parse_007.out0000644000200400020040000000006614776215332021226 0ustar andriusandriust/02parse.t: syntax error at line 0, position 48: ''. OPTIMADE-Filter-0.11.0/tests/outputs/parse_042.out0000644000200400020040000000755414776215332021236 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operator' => 'HAS ALL', 'property' => bless( { 'name' => [ 'statements' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '=', bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ) ], [ '=', bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ) ] ] }, 'OPTIMADE::Filter::ListComparison' ), bless( { 'operator' => 'HAS ALL', 'properties' => [ bless( { 'name' => [ 'number' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ 'is_prime' ] }, 'OPTIMADE::Filter::Property' ) ], 'values' => [ [ [ '<', '100' ], [ '=', bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ) ] ] ] }, 'OPTIMADE::Filter::Zip' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((statements HAS ALL = TRUE, = TRUE) AND (number:is_prime HAS ALL < "100" : = TRUE)) == SQL == AND OPTIMADE-Filter-0.11.0/tests/outputs/parse_029.out0000644000200400020040000000565314776215332021241 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operator' => 'HAS', 'property' => bless( { 'name' => [ '_exmpl_element_counts' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '<', '3' ] ] }, 'OPTIMADE::Filter::ListComparison' ), bless( { 'operator' => 'HAS ANY', 'property' => bless( { 'name' => [ '_exmpl_element_counts' ] }, 'OPTIMADE::Filter::Property' ), 'values' => [ [ '>', '3' ], [ '=', '6' ], [ '=', '4' ], [ '!=', '8' ] ] }, 'OPTIMADE::Filter::ListComparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((_exmpl_element_counts HAS < "3") AND (_exmpl_element_counts HAS ANY > "3", = "6", = "4", != "8")) == SQL == AND OPTIMADE-Filter-0.11.0/tests/outputs/parse_039.out0000644000200400020040000003406314776215332021237 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'a' ] }, 'OPTIMADE::Filter::Property' ), '1' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'b' ] }, 'OPTIMADE::Filter::Property' ), '2' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'c' ] }, 'OPTIMADE::Filter::Property' ), '3' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'd' ] }, 'OPTIMADE::Filter::Property' ), '4' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'e' ] }, 'OPTIMADE::Filter::Property' ), '5' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'f' ] }, 'OPTIMADE::Filter::Property' ), '6' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'g' ] }, 'OPTIMADE::Filter::Property' ), '7' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'h' ] }, 'OPTIMADE::Filter::Property' ), '8' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ); == Filter == (((a = "1") AND ((b = "2") AND (c = "3"))) OR ((d = "4") OR ((e = "5") OR ((f = "6") OR ((g = "7") OR (h = "8")))))) == SQL == ('a' = "1" AND 'b' = "2" AND 'c' = "3") OR 'd' = "4" OR 'e' = "5" OR 'f' = "6" OR 'g' = "7" OR 'h' = "8" OPTIMADE-Filter-0.11.0/tests/outputs/parse_025.out0000644000200400020040000000356414776215332021234 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'prototype_formula' ] }, 'OPTIMADE::Filter::Property' ), 'B2' ], 'operator' => 'STARTS' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'prototype_formula' ] }, 'OPTIMADE::Filter::Property' ), 'D2' ], 'operator' => 'ENDS WITH' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((prototype_formula STARTS "B2") AND (prototype_formula ENDS WITH "D2")) == SQL == 'prototype_formula' LIKE "B2%" AND 'prototype_formula' LIKE "%D2" OPTIMADE-Filter-0.11.0/tests/outputs/parse_003.out0000644000200400020040000000111714776215332021220 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ '_cod_cell_volume' ] }, 'OPTIMADE::Filter::Property' ), '100.0' ], 'operator' => '<' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (_cod_cell_volume < "100.0") == SQL == '_cod_cell_volume' < "100.0" OPTIMADE-Filter-0.11.0/tests/outputs/parse_032.out0000644000200400020040000000115114776215332021220 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'list' ] }, 'OPTIMADE::Filter::Property' ), 'string"with"quotes' ], 'operator' => 'CONTAINS' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (list CONTAINS "string\"with\"quotes") == SQL == 'list' LIKE "%string""with""quotes%" OPTIMADE-Filter-0.11.0/tests/outputs/parse_016.out0000644000200400020040000000475714776215332021241 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'inner' => bless( { 'operands' => [ bless( { 'name' => [ 'a' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ 'b' ] }, 'OPTIMADE::Filter::Property' ) ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ) }, 'OPTIMADE::Filter::Negation' ), bless( { 'operands' => [ bless( { 'name' => [ 'x' ] }, 'OPTIMADE::Filter::Property' ), '0' ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((NOT (a > b)) AND (x > "0")) == SQL == NOT ('a' > 'b') AND 'x' > "0" OPTIMADE-Filter-0.11.0/tests/outputs/parse_043.out0000644000200400020040000000375114776215332021232 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ), bless( { 'name' => [ 'property' ] }, 'OPTIMADE::Filter::Property' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ), bless( { 'value' => '' }, 'OPTIMADE::Filter::Boolean' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((TRUE = property) AND (TRUE = FALSE)) == SQL == AND OPTIMADE-Filter-0.11.0/tests/outputs/parse_044.out0000644000200400020040000000417014776215332021227 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'a' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'b' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'value' => 1 }, 'OPTIMADE::Filter::Boolean' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ); == Filter == ((a = TRUE) AND (b = TRUE)) == SQL == AND OPTIMADE-Filter-0.11.0/tests/outputs/parse_020.out0000644000200400020040000000114714776215332021222 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ '_exmpl_some_string_property' ] }, 'OPTIMADE::Filter::Property' ), '42' ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (_exmpl_some_string_property = "42") == SQL == '_exmpl_some_string_property' = "42" OPTIMADE-Filter-0.11.0/tests/outputs/parse_008.out0000644000200400020040000000143314776215332021226 0ustar andriusandrius$VAR1 = bless( { 'operands' => [ bless( { 'name' => [ 'key' ] }, 'OPTIMADE::Filter::Property' ), bless( { 'name' => [ 'value' ] }, 'OPTIMADE::Filter::Property' ) ], 'operator' => '=' }, 'OPTIMADE::Filter::Comparison' ); == Filter == (key = value) == SQL == 'key' = 'value' OPTIMADE-Filter-0.11.0/Build.PL0000644000200400020040000000310414776215332015400 0ustar andriusandrius # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.012. use strict; use warnings; use Module::Build 0.28; use lib qw{inc}; use Module::Build::Parse::Yapp; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.28", "Module::Build::Parse::Yapp" => 0 }, "configure_requires" => { "Module::Build" => "0.28", "Module::Build::Parse::Yapp" => 0 }, "dist_abstract" => "OPTIMADE filter language parser/composer", "dist_author" => [ "Andrius Merkys " ], "dist_name" => "OPTIMADE-Filter", "dist_version" => "0.11.0", "license" => "lgpl", "module_name" => "OPTIMADE::Filter", "recursive_test_files" => 1, "requires" => { "List::Util" => 0, "Parse::Yapp" => 0, "Scalar::Util" => 0 }, "test_requires" => { "Data::Compare" => 0, "Data::Dumper" => 0, "File::Spec" => 0, "List::Util" => 0, "Math::BigInt" => 0, "Parse::Yapp" => 0, "Scalar::Util" => 0, "Test::More" => 0 } ); my %fallback_build_requires = ( "Data::Compare" => 0, "Data::Dumper" => 0, "File::Spec" => 0, "List::Util" => 0, "Math::BigInt" => 0, "Module::Build" => "0.28", "Module::Build::Parse::Yapp" => 0, "Parse::Yapp" => 0, "Scalar::Util" => 0, "Test::More" => 0 ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build::Parse::Yapp->new(%module_build_args); $build->add_build_element($_) for qw(yp); $build->create_build_script; OPTIMADE-Filter-0.11.0/MANIFEST0000644000200400020040000000652714776215332015251 0ustar andriusandrius# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012. Build.PL COPYING Changes MANIFEST META.json META.yml README dist.ini lib/OPTIMADE/Filter.pm lib/OPTIMADE/Filter/AndOr.pm lib/OPTIMADE/Filter/Boolean.pm lib/OPTIMADE/Filter/Comparison.pm lib/OPTIMADE/Filter/Known.pm lib/OPTIMADE/Filter/ListComparison.pm lib/OPTIMADE/Filter/Modifiable.pm lib/OPTIMADE/Filter/Negation.pm lib/OPTIMADE/Filter/Parser.yp lib/OPTIMADE/Filter/Property.pm lib/OPTIMADE/Filter/Zip.pm t/01use.t t/02parse.t t/03modify.t t/04modify.t t/05modify.t t/06property.t t/07bigint.t tests/cases/parse_001.inp tests/cases/parse_002.inp tests/cases/parse_003.inp tests/cases/parse_004.inp tests/cases/parse_005.inp tests/cases/parse_006.inp tests/cases/parse_007.inp tests/cases/parse_008.inp tests/cases/parse_009.inp tests/cases/parse_010.inp tests/cases/parse_011.inp tests/cases/parse_012.inp tests/cases/parse_013.inp tests/cases/parse_014.inp tests/cases/parse_015.inp tests/cases/parse_016.inp tests/cases/parse_017.inp tests/cases/parse_018.inp tests/cases/parse_019.inp tests/cases/parse_020.inp tests/cases/parse_021.inp tests/cases/parse_022.inp tests/cases/parse_023.inp tests/cases/parse_024.inp tests/cases/parse_025.inp tests/cases/parse_026.inp tests/cases/parse_027.inp tests/cases/parse_028.inp tests/cases/parse_029.inp tests/cases/parse_030.inp tests/cases/parse_031.inp tests/cases/parse_032.inp tests/cases/parse_033.inp tests/cases/parse_034.inp tests/cases/parse_035.inp tests/cases/parse_035.opt tests/cases/parse_036.inp tests/cases/parse_036.opt tests/cases/parse_037.inp tests/cases/parse_037.opt tests/cases/parse_038.inp tests/cases/parse_039.inp tests/cases/parse_039.opt tests/cases/parse_040.inp tests/cases/parse_041.inp tests/cases/parse_042.inp tests/cases/parse_043.inp tests/cases/parse_044.inp tests/cases/parse_045.inp tests/cases/parse_046.inp tests/cases/parse_047.inp tests/cases/parse_048.inp tests/cases/parse_049.inp tests/outputs/modify_001.out tests/outputs/modify_002.out tests/outputs/modify_003.out tests/outputs/parse_001.out tests/outputs/parse_002.out tests/outputs/parse_003.out tests/outputs/parse_004.out tests/outputs/parse_005.out tests/outputs/parse_006.out tests/outputs/parse_007.out tests/outputs/parse_008.out tests/outputs/parse_009.out tests/outputs/parse_010.out tests/outputs/parse_011.out tests/outputs/parse_012.out tests/outputs/parse_013.out tests/outputs/parse_014.out tests/outputs/parse_015.out tests/outputs/parse_016.out tests/outputs/parse_017.out tests/outputs/parse_018.out tests/outputs/parse_019.out tests/outputs/parse_020.out tests/outputs/parse_021.out tests/outputs/parse_022.out tests/outputs/parse_023.out tests/outputs/parse_024.out tests/outputs/parse_025.out tests/outputs/parse_026.out tests/outputs/parse_027.out tests/outputs/parse_028.out tests/outputs/parse_029.out tests/outputs/parse_030.out tests/outputs/parse_031.out tests/outputs/parse_032.out tests/outputs/parse_033.out tests/outputs/parse_034.out tests/outputs/parse_035.out tests/outputs/parse_036.out tests/outputs/parse_037.out tests/outputs/parse_038.out tests/outputs/parse_039.out tests/outputs/parse_040.out tests/outputs/parse_041.out tests/outputs/parse_042.out tests/outputs/parse_043.out tests/outputs/parse_044.out tests/outputs/parse_045.out tests/outputs/parse_046.out tests/outputs/parse_047.out tests/outputs/parse_048.out tests/outputs/parse_049.out OPTIMADE-Filter-0.11.0/META.yml0000644000200400020040000000176714776215332015372 0ustar andriusandrius--- abstract: 'OPTIMADE filter language parser/composer' author: - 'Andrius Merkys ' build_requires: Data::Compare: '0' Data::Dumper: '0' File::Spec: '0' List::Util: '0' Math::BigInt: '0' Module::Build: '0.28' Module::Build::Parse::Yapp: '0' Parse::Yapp: '0' Scalar::Util: '0' Test::More: '0' configure_requires: Module::Build: '0.28' Module::Build::Parse::Yapp: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010' license: lgpl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: OPTIMADE-Filter requires: List::Util: '0' Parse::Yapp: '0' Scalar::Util: '0' resources: bugtracker: https://github.com/Materials-Consortia/optimade-filter/issues homepage: https://search.cpan.org/dist/OPTIMADE-Filter repository: git://github.com/Materials-Consortia/optimade-filter.git version: 0.11.0 x_generated_by_perl: v5.30.0 x_serialization_backend: 'YAML::Tiny version 1.73' OPTIMADE-Filter-0.11.0/COPYING0000644000200400020040000001674314776215332015154 0ustar andriusandrius GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. OPTIMADE-Filter-0.11.0/t/0000775000200400020040000000000014776215332014353 5ustar andriusandriusOPTIMADE-Filter-0.11.0/t/04modify.t0000644000200400020040000000473014776215332016175 0ustar andriusandrius#!/usr/bin/env perl use strict; use warnings; use Data::Compare; use Data::Dumper; use OPTIMADE::Filter::Modifiable; use OPTIMADE::Filter::Parser; use Scalar::Util qw(blessed); use Test::More tests => 1; $Data::Dumper::Sortkeys = 1; my $parser = new OPTIMADE::Filter::Parser; my $tree = $parser->parse_string( 'value.list HAS ALL "a", "b", "c"' ); my $tree_now = OPTIMADE::Filter::Modifiable::modify( $tree, sub { my( $node ) = @_; if( blessed $node && $node->isa( OPTIMADE::Filter::ListComparison:: ) ) { my @values = @{$node->{values}}; my $node_now; while( @values ) { my( undef, $value ) = @{shift @values}; my $comparison = OPTIMADE::Filter::Comparison->new( 'CONTAINS' ); $comparison->push_operand( $node->{property} ); $comparison->push_operand( $value ); if( $node_now ) { $node_now = [ $node_now, 'AND', $comparison ]; } else { $node_now = $comparison; } } $node = $node_now; } return $node; } ); my $expected = <<'END'; $VAR1 = [ [ bless( { 'operands' => [ bless( { 'name' => [ 'value', 'list' ] }, 'OPTIMADE::Filter::Property' ), 'a' ], 'operator' => 'CONTAINS' }, 'OPTIMADE::Filter::Comparison' ), 'AND', bless( { 'operands' => [ $VAR1->[0][0]{'operands'}[0], 'b' ], 'operator' => 'CONTAINS' }, 'OPTIMADE::Filter::Comparison' ) ], 'AND', bless( { 'operands' => [ $VAR1->[0][0]{'operands'}[0], 'c' ], 'operator' => 'CONTAINS' }, 'OPTIMADE::Filter::Comparison' ) ]; END is( Dumper( $tree_now ), $expected ); OPTIMADE-Filter-0.11.0/t/05modify.t0000644000200400020040000000315014776215332016171 0ustar andriusandrius#!/usr/bin/env perl use strict; use warnings; use Data::Compare; use Data::Dumper; use OPTIMADE::Filter::Modifiable; use OPTIMADE::Filter::Parser; use Scalar::Util qw(blessed); use Test::More tests => 1; $Data::Dumper::Sortkeys = 1; my $parser = new OPTIMADE::Filter::Parser; my $tree = $parser->parse_string( 'value.list HAS ALL "a", "b", "c"' ); my @traverse_order; OPTIMADE::Filter::Modifiable::modify( $tree, sub { my( $node, $traverse_order ) = @_; push @$traverse_order, $node; return $node; }, \@traverse_order ); my $expected = <<'END'; $VAR1 = [ bless( { 'name' => [ 'value', 'list' ] }, 'OPTIMADE::Filter::Property' ), '=', 'a', '=', 'b', '=', 'c', bless( { 'operator' => 'HAS ALL', 'property' => $VAR1->[0], 'values' => [ [ '=', 'a' ], [ '=', 'b' ], [ '=', 'c' ] ] }, 'OPTIMADE::Filter::ListComparison' ) ]; END is( Dumper( \@traverse_order ), $expected ); OPTIMADE-Filter-0.11.0/t/06property.t0000644000200400020040000000075314776215332016575 0ustar andriusandrius#!/usr/bin/perl use strict; use warnings; use OPTIMADE::Filter::Property; use Test::More tests => 4; my $property = OPTIMADE::Filter::Property->new( "Some", "Property" ); is( $property->to_filter, 'some.property' ); is( $property->to_SQL, "'Some'.'Property'" ); is( $property, $property ); my $error = ''; eval { push @$property, 'HAS SPACES'; my $filter = $property->to_filter; print STDERR $filter; }; $error = $@ if $@; ok( $error =~ /^name 'has spaces' does not match/ ); OPTIMADE-Filter-0.11.0/t/07bigint.t0000644000200400020040000000176414776215332016171 0ustar andriusandrius#!/usr/bin/perl use Math::BigInt; use OPTIMADE::Filter::Comparison; use OPTIMADE::Filter::Property; use Scalar::Util qw(blessed); use Test::More tests => 7; my $clause = OPTIMADE::Filter::Comparison->new( '=' ); $clause->left( OPTIMADE::Filter::Property->new( 'column' ) ); $clause->right( Math::BigInt->new( '1' ) ); my( $SQL, $values ) = $clause->to_SQL( { placeholder => '?' } ); is( $SQL, '\'column\' = ?' ); ok( $values->[0]->isa( Math::BigInt:: ) ); is( $values->[0] . '', '1' ); # Doing senseless modification $clause = $clause->modify( sub { return $_[0] } ); ok( $clause->right->isa( Math::BigInt:: ) ); is( $clause->right . '', '1' ); # Converting Math::BigInt to string $clause = $clause->modify( sub { return $_[0] unless blessed $_[0]; return $_[0] unless $_[0]->isa( Math::BigInt ); return "$_[0]"; } ); is( ref $clause->right, '' ); is( $clause->right, '1' ); OPTIMADE-Filter-0.11.0/t/02parse.t0000644000200400020040000000441114776215332016012 0ustar andriusandrius#!/usr/bin/perl use strict; use warnings; use Data::Compare; use Data::Dumper; use File::Spec::Functions; use OPTIMADE::Filter::Parser; use Test::More; $Data::Dumper::Sortkeys = 1; my $input_dir = catdir( 'tests', 'cases' ); my $output_dir = catdir( 'tests', 'outputs' ); opendir my $dir, $input_dir || die "Cannot open directory: $!"; my @inputs = sort grep { /\.inp$/ } readdir $dir; closedir $dir; my $ntests = @inputs; plan tests => $ntests; for my $case (@inputs) { $case =~ /([^\/\\]+)\.inp$/; my $input_file = catdir( $input_dir, $case ); my $options_file = catdir( $input_dir, "$1.opt" ); my $output_file = catdir( $output_dir, "$1.out" ); my $options = {}; if( -e $options_file ) { open( my $inp, '<', $options_file ); while( <$inp> ) { chomp; $options->{$_} = 1; } close $inp; } $OPTIMADE::Filter::Parser::allow_LIKE_operator = defined $options->{allow_LIKE_operator}; my( $tree, $output ); my $parser = new OPTIMADE::Filter::Parser; eval { $tree = $parser->Run( $input_file ); }; $output = $@ if $@; if( $tree ) { $output .= Dumper( $tree ) . "== Filter ==\n" . $tree->to_filter . "\n" . "== SQL ==\n"; } if( $tree ) { my $sql_options = {}; if( exists $options->{flatten} ) { $sql_options->{flatten} = $options->{flatten}; } eval { if( $options->{use_placeholders} ) { $sql_options->{placeholder} = '?'; my( $sql, $values ) = $tree->to_SQL( $sql_options ); $output .= "$sql\n" . "=== Values ===\n" . Dumper $values; } else { $output .= $tree->to_SQL( $sql_options ) . "\n"; } }; $output = $@ . $output if $@; } open( my $out, $output_file ); my $expected = join '', <$out>; close $out; is( $output, $expected, $case ); next unless $tree; my $filter = $tree->to_filter; $parser = new OPTIMADE::Filter::Parser; my $tree_now = $parser->parse_string( $filter ); Compare( $tree, $tree_now ) || print "Roundtrip NOT passed\n"; } OPTIMADE-Filter-0.11.0/t/01use.t0000644000200400020040000000011114776215332015464 0ustar andriusandriususe Test::More tests => 1; BEGIN { use_ok('OPTIMADE::Filter::Parser') }; OPTIMADE-Filter-0.11.0/t/03modify.t0000644000200400020040000000762114776215332016176 0ustar andriusandrius#!/usr/bin/env perl use strict; use warnings; use Data::Compare; use Data::Dumper; use OPTIMADE::Filter::Modifiable; use OPTIMADE::Filter::Parser; use Scalar::Util qw(blessed); use Test::More tests => 1; $Data::Dumper::Sortkeys = 1; my $parser = new OPTIMADE::Filter::Parser; my $tree = $parser->parse_string( 'a >= 5 OR b <= 2 AND c > 10' ); my $tree_now = OPTIMADE::Filter::Modifiable::modify( $tree, sub { my( $node ) = @_; if( blessed $node && $node->isa( OPTIMADE::Filter::Comparison:: ) ) { $node->{operator} =~ s/([<>])=/$1/; } return $node; } ); my $expected = <<'END'; $VAR1 = bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'a' ] }, 'OPTIMADE::Filter::Property' ), '5' ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'operands' => [ bless( { 'name' => [ 'b' ] }, 'OPTIMADE::Filter::Property' ), '2' ], 'operator' => '<' }, 'OPTIMADE::Filter::Comparison' ), bless( { 'operands' => [ bless( { 'name' => [ 'c' ] }, 'OPTIMADE::Filter::Property' ), '10' ], 'operator' => '>' }, 'OPTIMADE::Filter::Comparison' ) ], 'operator' => 'AND' }, 'OPTIMADE::Filter::AndOr' ) ], 'operator' => 'OR' }, 'OPTIMADE::Filter::AndOr' ); END is( Dumper( $tree_now ), $expected ); OPTIMADE-Filter-0.11.0/lib/0000775000200400020040000000000014776215332014656 5ustar andriusandriusOPTIMADE-Filter-0.11.0/lib/OPTIMADE/0000775000200400020040000000000014776215332016060 5ustar andriusandriusOPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter.pm0000644000200400020040000000037614776215332017647 0ustar andriusandriuspackage OPTIMADE::Filter; use strict; use warnings; use parent 'OPTIMADE::Filter::Modifiable'; use Scalar::Util qw(blessed); our $VERSION = '0.11.0'; # VERSION our $OPTIMADE_VERSION = '1.2.0'; # ABSTRACT: OPTIMADE filter language parser/composer 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/0000775000200400020040000000000014776215332017305 5ustar andriusandriusOPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/Property.pm0000644000200400020040000000362714776215332021475 0ustar andriusandriuspackage OPTIMADE::Filter::Property; use strict; use warnings; use parent 'OPTIMADE::Filter::Modifiable'; use Scalar::Util qw(blessed); our $VERSION = '0.11.0'; # VERSION use overload '@{}' => sub { return $_[0]->{name} }, '""' => sub { return $_[0]->to_filter }, '==' => sub { return $_[0]->_eq( $_[1] ) }, 'eq' => sub { return $_[0]->_eq( $_[1] ) }; our $identifier_re = q/([a-z_][a-z0-9_]*)/; sub new { my $class = shift; return bless { name => \@_ }, $class; } sub to_filter { my( $self ) = @_; # Validate $self->validate; for my $name (@$self) { my $lc_name = lc $name; next if $lc_name =~ /^$identifier_re$/; die "name '$lc_name' does not match identifier syntax: $identifier_re"; } return join '.', map { lc } @$self; } sub to_SQL { my( $self, $options ) = @_; $options = {} unless $options; my( $delim, $placeholder ) = ( $options->{delim}, $options->{placeholder}, ); $delim = "'" unless $delim; # Validate $self->validate; if( @$self > 2 ) { die 'no SQL representation for properties of more than two ' . "identifiers\n"; } # Construct the SQL my $sql = join '.', map { "${delim}$_${delim}" } @$self; if( wantarray ) { return ( $sql, [] ); } else { return $sql; } } sub modify { my $self = shift; my $code = shift; return $code->( $self, @_ ); } sub validate { my $self = shift; die 'name undefined for OPTIMADE::Filter::Property' if !@$self; } sub _eq { my( $a, $b ) = @_; return '' if !blessed( $b ); return '' if !$b->isa( OPTIMADE::Filter::Property:: ); return '' if @$a != @$b; for my $i (0..$#$a) { return '' if defined $a->[$i] ^ defined $b->[$i]; next if !defined $a->[$i]; return '' if $a->[$i] ne $b->[$i]; } return 1; } 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/AndOr.pm0000644000200400020040000000726614776215332020657 0ustar andriusandriuspackage OPTIMADE::Filter::AndOr; use strict; use warnings; use parent 'OPTIMADE::Filter::Modifiable'; use Scalar::Util qw(blessed); our $VERSION = '0.11.0'; # VERSION sub new { my $class = shift; my $operator; my @operands; if( @_ == 2 ) { @operands = @_; } elsif( @_ == 3 ) { ( $operands[0], $operator, $operands[1] ) = @_; } return bless { operands => \@operands, operator => $operator }, $class; } sub operator { my( $self, $operator ) = @_; my $previous_operator = $self->{operator}; $self->{operator} = $operator if defined $operator; return $previous_operator; } sub push_operand { my( $self, $operand ) = @_; die 'attempt to insert more than two operands' if @{$self->{operands}} >= 2; push @{$self->{operands}}, $operand; } sub unshift_operand { my( $self, $operand ) = @_; die 'attempt to insert more than two operands' if @{$self->{operands}} >= 2; unshift @{$self->{operands}}, $operand; } sub left { my( $self, $operand ) = @_; my $previous_operand = $self->{operands}[0]; $self->{operands}[0] = $operand if defined $operand; return $previous_operand; } sub right { my( $self, $operand ) = @_; my $previous_operand = $self->{operands}[1]; $self->{operands}[1] = $operand if defined $operand; return $previous_operand; } sub to_filter { my( $self ) = @_; $self->validate; my $operator = $self->{operator}; my @operands; for my $i (0..$#{$self->{operands}}) { my $arg = $self->{operands}[$i]; if( blessed $arg && $arg->can( 'to_filter' ) ) { $arg = $arg->to_filter; } else { $arg =~ s/\\/\\\\/g; $arg =~ s/"/\\"/g; $arg = "\"$arg\""; } push @operands, $arg; } return "($operands[0] $operator $operands[1])"; } sub to_SQL { my( $self, $options ) = @_; $self->validate; $options = {} unless $options; my( $delim, $flatten, $placeholder ) = ( $options->{delim}, $options->{flatten}, $options->{placeholder}, ); $delim = "'" unless $delim; my $operator = $self->{operator}; my @operands; my @values; for my $i (0..$#{$self->{operands}}) { my $arg = $self->{operands}[$i]; if( blessed $arg && $arg->can( 'to_SQL' ) ) { my $values = []; eval { ( $arg, $values ) = $arg->to_SQL( $options ) }; if( $@ ) { chomp $@; $arg = "<$@>"; } if( $self->{operands}[$i]->isa( OPTIMADE::Filter::AndOr:: ) && (!$flatten || $self->operator ne $self->{operands}[$i]->operator) ) { $arg = "($arg)"; } push @values, @$values; } else { push @values, $arg; if( $placeholder ) { $arg = $placeholder; } else { $arg =~ s/"/""/g; $arg = "\"$arg\""; } } push @operands, $arg; } if( wantarray ) { return ( "$operands[0] $operator $operands[1]", \@values ); } else { return "$operands[0] $operator $operands[1]"; } } sub modify { my $self = shift; my $code = shift; $self->{operands} = [ map { OPTIMADE::Filter::Modifiable::modify( $_, $code, @_ ) } @{$self->{operands}} ]; return $code->( $self, @_ ); } sub validate { my $self = shift; if( @{$self->{operands}} != 2 ) { die 'number of operands for OPTIMADE::Filter::AndOr must be 2, ' . 'got ' . @{$self->{operands}}; } die 'operator undefined for OPTIMADE::Filter::AndOr' if !$self->operator; } 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/Negation.pm0000644000200400020040000000177214776215332021414 0ustar andriusandriuspackage OPTIMADE::Filter::Negation; use strict; use warnings; use parent 'OPTIMADE::Filter::Modifiable'; our $VERSION = '0.11.0'; # VERSION sub new { my( $class, $inner ) = @_; return bless { inner => $inner }, $class; } sub inner { my( $self, $inner ) = @_; my $previous_inner = $self->{inner}; $self->{inner} = $inner if defined $inner; return $previous_inner; } sub to_filter { my( $self ) = @_; $self->validate; return '(NOT ' . $self->inner->to_filter . ')'; } sub to_SQL { my( $self, $options ) = @_; $self->validate; my( $sql, $values ) = $self->inner->to_SQL( $options ); if( wantarray ) { return ( "NOT ($sql)", $values ); } else { return "NOT ($sql)"; } } sub modify { my $self = shift; my $code = shift; $self->inner( $self->inner->modify( $code, @_ ) ); return $code->( $self, @_ ); } sub validate { my $self = shift; die 'inner undefined for OPTIMADE::Filter::Negation' if !$self->inner; } 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/Parser.yp0000644000200400020040000004016714776215332021121 0ustar andriusandrius# Header section %{ use warnings; use Scalar::Util qw(blessed); use OPTIMADE::Filter::AndOr; use OPTIMADE::Filter::Boolean; use OPTIMADE::Filter::Comparison; use OPTIMADE::Filter::Known; use OPTIMADE::Filter::ListComparison; use OPTIMADE::Filter::Negation; use OPTIMADE::Filter::Property; use OPTIMADE::Filter::Zip; our $allow_LIKE_operator = 0; %} %% # Rules section # The top-level 'filter' rule filter: expression ; # Values ordered_constant: string | number ; unordered_constant: TRUE { return OPTIMADE::Filter::Boolean->new( 1 ); } | FALSE { return OPTIMADE::Filter::Boolean->new( '' ); } ; value: unordered_constant | ordered_value ; ordered_value: ordered_constant | property ; value_list_entry: value { return [ '=', $_[1] ]; } | value_eq_rhs { return [ $_[1]->operator, $_[1]->left ]; } | value_rel_comp_rhs { return [ $_[1]->operator, $_[1]->left ]; } | fuzzy_string_op_rhs { return [ $_[1]->operator, $_[1]->left ]; } ; value_list: value_list_entry { return [ $_[1] ]; } | value_list comma value_list_entry { push @{$_[1]}, $_[3]; return $_[1]; } ; value_zip: value_list_entry colon value_list_entry { return [ $_[1], $_[3] ]; } | value_zip colon value_list_entry { push @{$_[1]}, $_[3]; return $_[1]; } ; value_zip_list: value_zip { return [ $_[1] ]; } | value_zip_list comma value_zip { push @{$_[1]}, $_[3]; return $_[1]; } ; # Expressions expression: expression_clause | expression_clause OR expression { return OPTIMADE::Filter::AndOr->new( @_[1..$#_] ); } ; expression_clause: expression_phrase | expression_phrase AND expression_clause { return OPTIMADE::Filter::AndOr->new( @_[1..$#_] ); } ; expression_phrase: comparison | openingbrace expression closingbrace { return $_[2]; } | NOT comparison { return OPTIMADE::Filter::Negation->new( $_[2] ); } | NOT openingbrace expression closingbrace { return OPTIMADE::Filter::Negation->new( $_[3] ); } ; comparison: constant_first_comparison | property_first_comparison ; constant_first_comparison: ordered_constant value_op_rhs { $_[2]->unshift_operand( $_[1] ); return $_[2]; } | unordered_constant value_eq_rhs { $_[2]->unshift_operand( $_[1] ); return $_[2]; } ; property_first_comparison: property { my $cmp = OPTIMADE::Filter::Comparison->new( '=' ); $cmp->left( $_[1] ); $cmp->right( OPTIMADE::Filter::Boolean->new( 1 ) ); return $cmp; } | property value_op_rhs { $_[2]->unshift_operand( $_[1] ); return $_[2]; } | property known_op_rhs { $_[2]->property( $_[1] ); return $_[2]; } | property fuzzy_string_op_rhs { $_[2]->unshift_operand( $_[1] ); return $_[2]; } | property set_op_rhs { $_[2]->property( $_[1] ); return $_[2]; } | property set_zip_op_rhs { $_[2]->unshift_property( $_[1] ); return $_[2]; } | property length_op_rhs { $_[2]->property( $_[1] ); return $_[2]; } ; value_op_rhs: value_eq_rhs | value_rel_comp_rhs ; value_eq_rhs: equality_operator value { my $cmp = OPTIMADE::Filter::Comparison->new( $_[1] ); $cmp->push_operand( $_[2] ); return $cmp; } ; value_rel_comp_rhs: relative_comparison_operator ordered_value { my $cmp = OPTIMADE::Filter::Comparison->new( $_[1] ); $cmp->push_operand( $_[2] ); return $cmp; } ; known_op_rhs: IS KNOWN { return OPTIMADE::Filter::Known->new( 1 ); } | IS UNKNOWN { return OPTIMADE::Filter::Known->new( 0 ); } ; fuzzy_string_op_rhs: CONTAINS value { my $cmp = OPTIMADE::Filter::Comparison->new( $_[1] ); $cmp->push_operand( $_[2] ); return $cmp; } | STARTS value { my $cmp = OPTIMADE::Filter::Comparison->new( $_[1] ); $cmp->push_operand( $_[2] ); return $cmp; } | STARTS WITH value { my $cmp = OPTIMADE::Filter::Comparison->new( "$_[1] $_[2]" ); $cmp->push_operand( $_[3] ); return $cmp; } | ENDS value { my $cmp = OPTIMADE::Filter::Comparison->new( $_[1] ); $cmp->push_operand( $_[2] ); return $cmp; } | ENDS WITH value { my $cmp = OPTIMADE::Filter::Comparison->new( "$_[1] $_[2]" ); $cmp->push_operand( $_[3] ); return $cmp; } | LIKE value { my $cmp = OPTIMADE::Filter::Comparison->new( $_[1] ); $cmp->push_operand( $_[2] ); return $cmp; } ; set_op_rhs: HAS value { my $lc = OPTIMADE::Filter::ListComparison->new( $_[1] ); $lc->values( [ [ '=', $_[2] ] ] ); return $lc; } | HAS equality_operator value { my $lc = OPTIMADE::Filter::ListComparison->new( $_[1] ); $lc->values( [ [ $_[2], $_[3] ] ] ); return $lc; } | HAS relative_comparison_operator ordered_value { my $lc = OPTIMADE::Filter::ListComparison->new( $_[1] ); $lc->values( [ [ $_[2], $_[3] ] ] ); return $lc; } | HAS fuzzy_string_op_rhs { my $lc = OPTIMADE::Filter::ListComparison->new( $_[1] ); $lc->values( [ [ $_[2]->operator, $_[2]->left ] ] ); return $lc; } | HAS ALL value_list { my $lc = OPTIMADE::Filter::ListComparison->new( "$_[1] $_[2]" ); $lc->values( $_[3] ); return $lc; } | HAS ANY value_list { my $lc = OPTIMADE::Filter::ListComparison->new( "$_[1] $_[2]" ); $lc->values( $_[3] ); return $lc; } | HAS ONLY value_list { my $lc = OPTIMADE::Filter::ListComparison->new( "$_[1] $_[2]" ); $lc->values( $_[3] ); return $lc; } ; set_zip_op_rhs: property_zip_addon HAS value_zip { $_[1]->operator( $_[2] ); $_[1]->values( [ $_[3] ] ); return $_[1]; } | property_zip_addon HAS ONLY value_zip_list { $_[1]->operator( "$_[2] $_[3]" ); $_[1]->values( $_[4] ); return $_[1]; } | property_zip_addon HAS ALL value_zip_list { $_[1]->operator( "$_[2] $_[3]" ); $_[1]->values( $_[4] ); return $_[1]; } | property_zip_addon HAS ANY value_zip_list { $_[1]->operator( "$_[2] $_[3]" ); $_[1]->values( $_[4] ); return $_[1]; } ; property_zip_addon: colon property { my $zip = OPTIMADE::Filter::Zip->new; $zip->push_property( $_[2] ); return $zip; } | property_zip_addon colon property { $_[1]->push_property( $_[3] ); return $_[1]; } ; length_op_rhs: LENGTH value { my $cmp = OPTIMADE::Filter::ListComparison->new( $_[1] ); $cmp->values( [ [ '=', $_[2] ] ] ); return $cmp; } | LENGTH operator value { my $cmp = OPTIMADE::Filter::ListComparison->new( $_[1] ); $cmp->values( [ [ $_[2], $_[3] ] ] ); return $cmp; } ; # Property property: identifier { return OPTIMADE::Filter::Property->new( $_[1] ); } | property dot identifier { push @{$_[1]}, $_[3]; return $_[1]; } ; # Separators openingbrace: '(' ; closingbrace: ')' ; dot: '.' ; comma: ',' ; colon: ':' ; # Comparison operator tokens operator: equality_operator | relative_comparison_operator ; equality_operator: '=' | '!' '=' { return join( '', @_[1..$#_] ); } ; relative_comparison_operator: '<' | '<' '=' { return join( '', @_[1..$#_] ); } | '>' | '>' '=' { return join( '', @_[1..$#_] ); } ; %% # Footer section sub _Error { my( $self ) = @_; close $self->{USER}{FILEIN} if $self->{USER}{FILEIN}; my $msg = "$0: syntax error at line $self->{USER}{LINENO}, " . "position $self->{USER}{CHARNO}"; if( $self->YYData->{INPUT} ) { $self->YYData->{INPUT} =~ s/\n$//; die "$msg: '" . $self->YYData->{INPUT} . "'.\n"; } else { die "$msg.\n"; } } sub _Lexer { my( $self ) = @_; # If the line is empty and the input is originating from the file, # another line is read. if( !$self->YYData->{INPUT} && $self->{USER}{FILEIN} ) { my $filein = $self->{USER}{FILEIN}; $self->YYData->{INPUT} = <$filein>; $self->{USER}{LINENO} = -1 unless exists $self->{USER}{LINENO}; $self->{USER}{LINENO}++; $self->{USER}{CHARNO} = 0; } $self->YYData->{INPUT} =~ s/^(\s+)//; $self->{USER}{CHARNO} += length( $1 ) if defined $1; # Escaped double quote or backslash are detected here and returned # as is to the caller in order to be detected as syntax errors. if( $self->YYData->{INPUT} =~ s/^(\\"|\\\\)// ) { $self->{USER}{CHARNO} += length( $1 ); return( $1, $1 ); } # Handling strings if( $self->YYData->{INPUT} =~ s/^"// ) { $self->{USER}{CHARNO} ++; my $string = ''; while( 1 ) { if( $self->YYData->{INPUT} =~ s/^([A-Za-z_0-9 \t!#\$\%&\'\(\)\*\+,\-\.\/\:;<=>\?@\[\]\^`\{\|\}\~\P{ASCII}]+)// ) { $self->{USER}{CHARNO} += length( $1 ); $string .= $1; } elsif( $self->YYData->{INPUT} =~ s/^\\([\\"])// ) { $self->{USER}{CHARNO} ++; $string .= $1; next; } elsif( $self->YYData->{INPUT} =~ s/^"// ) { $self->{USER}{CHARNO} ++; return( 'string', $string ); } else { return( undef, undef ); } } } # Handling identifiers if( $self->YYData->{INPUT} =~ s/^([a-z_][a-z0-9_]*)// ) { $self->{USER}{CHARNO} += length( $1 ); return( 'identifier', $1 ); } # Handling textual operators and other literals if( $self->YYData->{INPUT} =~ s/^(AND|NOT|OR| IS|UNKNOWN|KNOWN| CONTAINS|STARTS|ENDS|WITH| LENGTH|HAS|ALL|ONLY|ANY| TRUE|FALSE)//x ) { $self->{USER}{CHARNO} += length( $1 ); return( $1, $1 ); } # Handling LIKE operator if allowed if( $allow_LIKE_operator && $self->YYData->{INPUT} =~ s/^(LIKE)// ) { $self->{USER}{CHARNO} += length( $1 ); return( $1, $1 ); } # Handling numbers if( $self->YYData->{INPUT} =~ s/^([+-]? (\d+\.?\d*|\.\d+) ([eE][+-]?\d+)?)//x ) { $self->{USER}{CHARNO} += length( $1 ); return( 'number', $1 ); } my $char = substr( $self->YYData->{INPUT}, 0, 1 ); if( $char ne '' ) { $self->YYData->{INPUT} = substr( $self->YYData->{INPUT}, 1 ); } $self->{USER}{CHARNO}++; return( $char, $char ); } sub Run { my( $self, $filename ) = @_; open $self->{USER}{FILEIN}, $filename; my $result = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error ); close $self->{USER}{FILEIN}; return $result; } sub parse_string { my( $self, $string ) = @_; $self->YYData->{INPUT} = $string; $self->{USER}{LINENO} = 0; $self->{USER}{CHARNO} = 0; return $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error ); } sub modify { my $node = shift; my $code = shift; if( blessed $node && $node->can( 'modify' ) ) { return $node->modify( $code, @_ ); } elsif( ref $node eq 'ARRAY' ) { return [ map { modify( $_, $code, @_ ) } @$node ]; } else { return $code->( $node, @_ ); } } 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/Known.pm0000644000200400020040000000254114776215332020737 0ustar andriusandriuspackage OPTIMADE::Filter::Known; use strict; use warnings; use parent 'OPTIMADE::Filter::Modifiable'; our $VERSION = '0.11.0'; # VERSION sub new { my( $class, $is_known, $property ) = @_; return bless { is_known => $is_known, property => $property }, $class; } sub is_known { my( $self, $is_known ) = @_; my $previous_is_known = $self->{is_known}; $self->{is_known} = $is_known if defined $is_known; return $previous_is_known; } sub property { my( $self, $property ) = @_; my $previous_property = $self->{property}; $self->{property} = $property if defined $property; return $previous_property; } sub to_filter { my( $self ) = @_; $self->validate; return $self->property->to_filter . ' IS ' . ($self->is_known ? 'KNOWN' : 'UNKNOWN'); } sub to_SQL { my( $self, $options ) = @_; $self->validate; my( $sql, $values ) = $self->property->to_SQL( $options ); $sql = "$sql IS " . ($self->is_known ? 'NOT NULL' : 'NULL'); if( wantarray ) { return ( $sql, $values ); } else { return $sql; } } sub modify { my $self = shift; my $code = shift; $self->property( $self->property->modify( $code, @_ ) ); return $code->( $self, @_ ); } sub validate { my $self = shift; die 'property undefined for OPTIMADE::Filter::Known' if !$self->property; } 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/Zip.pm0000644000200400020040000000511014776215332020400 0ustar andriusandriuspackage OPTIMADE::Filter::Zip; use strict; use warnings; use parent 'OPTIMADE::Filter::Modifiable'; use List::Util qw(any); use Scalar::Util qw(blessed); our $VERSION = '0.11.0'; # VERSION sub new { my( $class ) = @_; return bless { properties => [], operator => undef, values => [] }, $class; } sub push_property { my( $self, $property ) = @_; push @{$self->{properties}}, $property; } sub unshift_property { my( $self, $property ) = @_; unshift @{$self->{properties}}, $property; } sub operator { my( $self, $operator ) = @_; my $previous_operator = $self->{operator}; $self->{operator} = $operator if defined $operator; return $previous_operator; } sub values { my( $self, $values ) = @_; my $previous_values = $self->{values}; $self->{values} = $values if defined $values; return $previous_values; } sub to_filter { my( $self ) = @_; $self->validate; my @zip_list; foreach my $zip (@{$self->{values}}) { my @zip; for my $i (0..$#$zip) { my( $operator, $arg ) = @{$zip->[$i]}; if( blessed $arg && $arg->can( 'to_filter' ) ) { $arg = $arg->to_filter; } else { $arg =~ s/\\/\\\\/g; $arg =~ s/"/\\"/g; $arg = "\"$arg\""; } push @zip, "$operator $arg"; } push @zip_list, join( ' : ', @zip ); } return '(' . join( ':', map { $_->to_filter } @{$self->{properties}} ) . ' ' . $self->{operator} . ' ' . join( ', ', @zip_list ) . ')'; } sub to_SQL { die "no SQL representation\n"; } sub modify { my $self = shift; my $code = shift; $self->{properties} = [ map { $_->modify( $code, @_ ) } @{$self->{properties}} ]; $self->{values} = [ map { [ OPTIMADE::Filter::Modifiable::modify( $_->[0], $code, @_ ), OPTIMADE::Filter::Modifiable::modify( $_->[1], $code, @_ ) ] } @{$self->{values}} ]; return $code->( $self, @_ ); } sub validate { my $self = shift; if( !$self->{properties} ) { die 'properties undefined for OPTIMADE::Filter::Zip'; } if( !$self->operator ) { die 'operator undefined for OPTIMADE::Filter::Zip'; } if( !$self->values ) { die 'values undefined for OPTIMADE::Filter::Zip'; } if( any { scalar @$_ != scalar @{$self->{properties}} } @{$self->values} ) { die 'different number of properties and values for OPTIMADE::Filter::Zip'; } } 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/Boolean.pm0000644000200400020040000000072414776215332021223 0ustar andriusandriuspackage OPTIMADE::Filter::Boolean; use strict; use warnings; use parent 'OPTIMADE::Filter::Modifiable'; our $VERSION = '0.11.0'; # VERSION sub new { my( $class, $value ) = @_; return bless { value => $value }, $class; } sub to_filter { my $self = shift; return $self->{value} ? 'TRUE' : 'FALSE'; } sub to_SQL { die "no SQL representation\n"; } sub modify { my $self = shift; my $code = shift; return $code->( $self, @_ ); } 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/Comparison.pm0000644000200400020040000000741614776215332021763 0ustar andriusandriuspackage OPTIMADE::Filter::Comparison; use strict; use warnings; use parent 'OPTIMADE::Filter::Modifiable'; use Scalar::Util qw(blessed); our $VERSION = '0.11.0'; # VERSION sub new { my( $class, $operator ) = @_; return bless { operands => [], operator => $operator }, $class; } sub push_operand { my( $self, $operand ) = @_; die 'attempt to insert more than two operands' if @{$self->{operands}} >= 2; push @{$self->{operands}}, $operand; } sub unshift_operand { my( $self, $operand ) = @_; die 'attempt to insert more than two operands' if @{$self->{operands}} >= 2; unshift @{$self->{operands}}, $operand; } sub operator { my( $self, $operator ) = @_; my $previous_operator = $self->{operator}; $self->{operator} = $operator if defined $operator; return $previous_operator; } sub left { my( $self, $operand ) = @_; my $previous_operand = $self->{operands}[0]; $self->{operands}[0] = $operand if defined $operand; return $previous_operand; } sub right { my( $self, $operand ) = @_; my $previous_operand = $self->{operands}[1]; $self->{operands}[1] = $operand if defined $operand; return $previous_operand; } sub to_filter { my( $self ) = @_; $self->validate; my $operator = $self->{operator}; my @operands; for my $i (0..$#{$self->{operands}}) { my $arg = $self->{operands}[$i]; if( blessed $arg && $arg->can( 'to_filter' ) ) { $arg = $arg->to_filter; } else { $arg =~ s/\\/\\\\/g; $arg =~ s/"/\\"/g; $arg = "\"$arg\""; } push @operands, $arg; } return "($operands[0] $operator $operands[1])"; } sub to_SQL { my( $self, $options ) = @_; $self->validate; $options = {} unless $options; my( $delim, $placeholder ) = ( $options->{delim}, $options->{placeholder}, ); $delim = "'" unless $delim; my $operator = $self->{operator}; my @operands = @{$self->{operands}}; # Handle STARTS/ENDS WITH if( $operator eq 'CONTAINS' ) { $operator = 'LIKE'; $operands[1] = '%' . $operands[1] . '%' if !blessed $operands[1]; } elsif( $operator =~ /^STARTS( WITH)?$/ ) { $operator = 'LIKE'; $operands[1] = $operands[1] . '%' if !blessed $operands[1]; } elsif( $operator =~ /^ENDS( WITH)?$/ ) { $operator = 'LIKE'; $operands[1] = '%' . $operands[1] if !blessed $operands[1]; } my @values; my @operands_now; for my $arg (@operands) { my $sql = $arg; if( blessed $arg && $arg->can( 'to_SQL' ) ) { ( $sql, my $values ) = $arg->to_SQL( $options ); if( $arg->isa( OPTIMADE::Filter::Comparison:: ) ) { $sql = "($sql)"; } push @values, @$values; } else { push @values, $arg; if( $placeholder ) { $sql = $placeholder; } else { $sql =~ s/"/""/g; $sql = "\"$sql\""; } } push @operands_now, $sql; } @operands = @operands_now; if( wantarray ) { return ( "$operands[0] $operator $operands[1]", \@values ); } else { return "$operands[0] $operator $operands[1]"; } } sub modify { my $self = shift; my $code = shift; $self->{operands} = [ map { OPTIMADE::Filter::Modifiable::modify( $_, $code, @_ ) } @{$self->{operands}} ]; return $code->( $self, @_ ); } sub validate { my $self = shift; if( @{$self->{operands}} != 2 ) { die 'number of operands for OPTIMADE::Filter::Comparison must be 2, ' . 'got ' . @{$self->{operands}}; } die 'operator undefined for OPTIMADE::Filter::Comparison' if !$self->operator; } 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/Modifiable.pm0000644000200400020040000000073314776215332021677 0ustar andriusandriuspackage OPTIMADE::Filter::Modifiable; use strict; use warnings; use Scalar::Util qw(blessed); our $VERSION = '0.11.0'; # VERSION sub modify { my $node = shift; my $code = shift; if( blessed $node && $node->isa( OPTIMADE::Filter::Modifiable:: ) ) { return $node->modify( $code, @_ ); } elsif( ref $node eq 'ARRAY' ) { return [ map { modify( $_, $code, @_ ) } @$node ]; } else { return $code->( $node, @_ ); } } 1; OPTIMADE-Filter-0.11.0/lib/OPTIMADE/Filter/ListComparison.pm0000644000200400020040000000436714776215332022621 0ustar andriusandriuspackage OPTIMADE::Filter::ListComparison; use strict; use warnings; use parent 'OPTIMADE::Filter::Modifiable'; use Scalar::Util qw(blessed); our $VERSION = '0.11.0'; # VERSION sub new { my( $class, $operator ) = @_; return bless { property => undef, operator => $operator, values => undef }, $class; } sub property { my( $self, $property ) = @_; my $previous_property = $self->{property}; $self->{property} = $property if defined $property; return $previous_property; } sub operator { my( $self, $operator ) = @_; my $previous_operator = $self->{operator}; $self->{operator} = $operator if defined $operator; return $previous_operator; } sub values { my( $self, $values ) = @_; my $previous_values = $self->{values}; $self->{values} = $values if defined $values; return $previous_values; } sub to_filter { my( $self ) = @_; $self->validate; my @values; for my $i (0..$#{$self->{values}}) { my( $operator, $arg ) = @{$self->{values}[$i]}; if( blessed $arg && $arg->can( 'to_filter' ) ) { $arg = $arg->to_filter; } else { $arg =~ s/\\/\\\\/g; $arg =~ s/"/\\"/g; $arg = "\"$arg\""; } push @values, "$operator $arg"; } return '(' . join( ' ', $self->{property}->to_filter, $self->{operator}, join( ', ', @values ) ) . ')'; } sub to_SQL { die "no SQL representation\n"; } sub modify { my $self = shift; my $code = shift; $self->property( $self->property->modify( $code, @_ ) ); $self->{values} = [ map { [ OPTIMADE::Filter::Modifiable::modify( $_->[0], $code, @_ ), OPTIMADE::Filter::Modifiable::modify( $_->[1], $code, @_ ) ] } @{$self->{values}} ]; return $code->( $self, @_ ); } sub validate { my $self = shift; if( !$self->property ) { die 'property undefined for OPTIMADE::Filter::ListComparison'; } if( !$self->operator ) { die 'operator undefined for OPTIMADE::Filter::ListComparison'; } if( !$self->values ) { die 'values undefined for OPTIMADE::Filter::ListComparison'; } } 1; OPTIMADE-Filter-0.11.0/META.json0000644000200400020040000000341114776215332015526 0ustar andriusandrius{ "abstract" : "OPTIMADE filter language parser/composer", "author" : [ "Andrius Merkys " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010", "license" : [ "lgpl_3_0" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "OPTIMADE-Filter", "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.28", "Module::Build::Parse::Yapp" : "0" } }, "configure" : { "requires" : { "Module::Build" : "0.28", "Module::Build::Parse::Yapp" : "0" } }, "runtime" : { "requires" : { "List::Util" : "0", "Parse::Yapp" : "0", "Scalar::Util" : "0" } }, "test" : { "requires" : { "Data::Compare" : "0", "Data::Dumper" : "0", "File::Spec" : "0", "List::Util" : "0", "Math::BigInt" : "0", "Parse::Yapp" : "0", "Scalar::Util" : "0", "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/Materials-Consortia/optimade-filter/issues" }, "homepage" : "https://search.cpan.org/dist/OPTIMADE-Filter", "repository" : { "type" : "git", "url" : "git://github.com/Materials-Consortia/optimade-filter.git", "web" : "https://github.com/Materials-Consortia/optimade-filter" } }, "version" : "0.11.0", "x_generated_by_perl" : "v5.30.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.19" }