Changeset 17046

Show
Ignore:
Timestamp:
07/14/07 04:31:49 (17 months ago)
Author:
Darren_Duncan
Message:

ext/Muldis-DB/ : in Core.pm, fleshed out the list of Text, Blob, Int operators

Location:
ext/Muldis-DB
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • ext/Muldis-DB/Changes

    r17019 r17046  
    1414    Validator.pm and Example.pm 0.2.0. 
    1515 
    16     * Updated Core.pod to replace the pseudo-type 'Any' with the 
    17     pseudo-type 'Some.Universal', and added 'Some.Ordinal'. 
     16    * Updated Core.pod to add the scalar type 'PInt2_36', and to replace 
     17    the pseudo-type 'Any' with the pseudo-type 'Some.Universal', and added 
     18    'Some.Ordinal'. 
     19 
     20    * Updated Grammar.pod concerning integer literals; they can be 
     21    represented with any of base-2 thru base-36 now. 
    1822 
    1923    * Updated Core.pod to add definitions for the generic operators common 
    2024    to all ordinal types: compare, reverse_compare, is_inc, is_dec, min, 
    21     max.  Added 'reverse' operator for the Order type. 
     25    max.  Added 'reverse' operator for the Order type.  Added or replaced 
     26    a bunch of operators for the Int|Blob|Text types.  Other small changes. 
    2227 
    23282007-07-11   Darren Duncan <perl@DarrenDuncan.net> 
  • ext/Muldis-DB/lib/Muldis/DB/Language/Core.pod

    r17019 r17046  
    6969                    sys.type.UInt 
    7070                        sys.type.PInt 
     71                            sys.type.PInt2_36 
    7172                sys.type.Blob 
    7273                    sys.type.NEBlob 
     
    217218member values are positive / greater than or equal to one.  Its default 
    218219value is one. 
     220 
     221=item C<sys.type.PInt2_36> 
     222 
     223A C<PInt2_36> is a proper subtype of C<PInt> where all member values are 
     224between 2 and 36.  (The significance of the number 36 is 10 digits plus 26 
     225letters.)  The cardinality of this type is 35. 
    219226 
    220227=item C<sys.type.Blob> 
     
    495502is both commutative and associative) until just one is left, a C<Maybe> 
    496503whose single element is which is the function's result.  If C<$v> has zero 
    497 values, then C<min> returns a same-typed C<Maybe> with zero elements.  Note 
    498 that, while C<min> could conceivably have been defined instead to not 
    499 return a C<Maybe>, but rather to return the appropriate ordinal type's 
    500 concept of negative infinity, this option is avoided for now citing 
    501 practical concerns in the face of infinite (especially non-numeric) types. 
     504values, then C<min> results in a same-typed C<Maybe> with zero elements. 
     505I<Note that, while C<min> could conceivably have been defined instead to 
     506not result in a C<Maybe>, but rather to result in the appropriate ordinal 
     507type's concept of negative infinity, this option is avoided for now citing 
     508practical concerns in the face of infinite (especially non-numeric) types.> 
    502509 
    503510=item C<sys.rtn.Ordinal.max of Maybe{Some.Ordinal} (RO: Set{Some.Ordinal} 
     
    514521core scalar data type. 
    515522 
    516 =head2 Functions for sys.rtn.Bool 
     523=head2 Functions for sys.type.Bool 
    517524 
    518525These functions select values of the C<Bool> enumeration. 
     
    543550its N input element values and does a logical I<and> (which is both 
    544551commutative and associative) on them until just one is left, which is the 
    545 function's result.  If C<$v> has zero values, then C<and> returns 
     552function's result.  If C<$v> has zero values, then C<and> results in 
    546553C<Bool.True>, which is the identity value for logical I<and>. 
    547554 
     
    551558its N input element values and does a logical inclusive-or (which is both 
    552559commutative and associative) on them until just one is left, which is the 
    553 function's result.  If C<$v> has zero values, then C<and> returns 
     560function's result.  If C<$v> has zero values, then C<or> results in 
    554561C<Bool.False>, which is the identity value for logical inclusive-or. 
    555562 
    556 =item C<sys.rtn.Bool.xor (RO: Bool $v1, Bool $v2)> 
    557  
    558 This function results in the logical exclusive-or of its 2 arguments.  This 
    559 function is commutative. 
    560  
    561 =back 
    562  
    563 =head2 Functions for sys.rtn.Order 
     563=item C<sys.rtn.Bool.xor of Bool (RO: Bag{Bool} $v)> 
     564 
     565This function is a reduction operator that recursively takes each pair of 
     566its N input element values and does a logical exclusive-or (which is both 
     567commutative and associative) on them until just one is left, which is the 
     568function's result.  If C<$v> has zero values, then C<xor> results in 
     569C<Bool.False>, which is the identity value for logical exclusive-or. 
     570 
     571=back 
     572 
     573=head2 Functions for sys.type.Order 
    564574 
    565575These functions select values of the C<Order> enumeration. 
     
    593603=back 
    594604 
    595 =head2 Functions for sys.rtn.Int 
     605=head2 Functions for sys.type.Int 
    596606 
    597607These functions implement commonly used integer operations. 
     
    605615and adds (which is both commutative and associative) them together until 
    606616just one is left, which is the result.  If C<$addends> has zero values, 
    607 then C<sum> returns the integer zero, which is the identity value for 
     617then C<sum> results in the integer zero, which is the identity value for 
    608618addition. 
    609619 
     
    619629input values and multiplies (which is both commutative and associative) 
    620630them together until just one is left, which is the result.  If C<$factors> 
    621 has zero values, then C<product> returns the integer 1, which is the 
     631has zero values, then C<product> results in the integer 1, which is the 
    622632identity value for multiplication. 
    623633 
     
    628638throws an exception if C<$divisor> is zero. 
    629639 
    630 =item C<sys.rtn.Int.remainder of Int (RO: Int $dividend, Int $divisor)> 
     640=item C<sys.rtn.Int.remainder of UInt (RO: Int $dividend, Int $divisor)> 
    631641 
    632642This function results in the remainder when its C<$dividend> argument is 
     
    634644throws an exception if C<$divisor> is zero. 
    635645 
    636 =item C<sys.rtn.Int.abs of Int (RO: Int $v)> 
     646=item C<sys.rtn.Int.abs of UInt (RO: Int $v)> 
    637647 
    638648This function results in the absolute value of its argument. 
     
    650660=over 
    651661 
    652 =item C<sys.rtn.Int.Int_from_Text.2 of Int (RO: Text $text)> 
    653  
    654 This selector function results in the C<Int> value that its argument maps 
    655 to when the whole character string is evaluated as a base-2 integer. 
    656  
    657 =item C<sys.rtn.Int.Text_from_Int.2 of Text (RO: Int $int)> 
    658  
    659 This selector function results in the C<Text> value where its argument is 
    660 formatted as a base-2 integer. 
    661  
    662 =item C<sys.rtn.Int.Int_from_Text.8 of Int (RO: Text $text)> 
    663  
    664 Same as C<Int.Int_from_Text.2> but for base-8. 
    665  
    666 =item C<sys.rtn.Int.Text_from_Int.8 of Text (RO: Int $int)> 
    667  
    668 Same as C<Int.Text_from_Int.2> but for base-8. 
    669  
    670 =item C<sys.rtn.Int.Int_from_Text.10 of Int (RO: Text $text)> 
    671  
    672 Same as C<Int.Int_from_Text.2> but for base-10. 
    673  
    674 =item C<sys.rtn.Int.Text_from_Int.10 of Text (RO: Int $int)> 
    675  
    676 Same as C<Int.Text_from_Int.2> but for base-10. 
    677  
    678 =item C<sys.rtn.Int.Int_from_Text.16 of Int (RO: Text $text)> 
    679  
    680 Same as C<Int.Int_from_Text.2> but for base-16. 
    681  
    682 =item C<sys.rtn.Int.Text_from_Int.16 of Text (RO: Int $int)> 
    683  
    684 Same as C<Int.Text_from_Int.2> but for base-16. 
    685  
    686 =back 
    687  
    688 =head2 Functions for sys.rtn.Blob 
     662=item C<sys.rtn.Int.Int_from_Text of Int (RO: NEText $text, PInt2_36 
     663$radix)> 
     664 
     665This selector function results in the C<Int> value that its C<$text> 
     666argument maps to when the whole character string is evaluated as a 
     667base-C<$radix> integer.  Extending the typical formats of [base-2, base-8, 
     668base-10, base-16], this function supports base-2 through base-36; to get 
     669the latter, the characters 0-9 and A-Z represent values in 0-35.  This 
     670function throws an exception if C<$text> can't be mapped as specified. 
     671 
     672=item C<sys.rtn.Int.Text_from_Int of NEText (RO: Int $int, PInt2_36 
     673$radix)> 
     674 
     675This selector function results in the C<Text> value where its C<$int> 
     676argument is formatted as a base-C<$radix> integer. 
     677 
     678=back 
     679 
     680These functions convert between C<Int> values and canonically formatted 
     681representations of integers as binary strings.  I<Conjecture: These may not 
     682actually be useful, and perhaps only operators that take an argument 
     683specifying a fixed-length field size, with big and little endian versions, 
     684would be appropriate instead.  Or maybe both kinds are necessary.> 
     685 
     686=over 
     687 
     688=item C<sys.rtn.Int.Int_from_Blob_S_VBE of Int (RO: NEBlob $blob)> 
     689 
     690This selector function results in the C<Int> value that its C<$blob> 
     691argument maps to when the whole bit string is treated literally as a 
     692variable-length binary (two's complement) signed integer of 1 or more bits 
     693in length.  The first bit is taken as the sign bit, and any other bits 
     694provide greater precision than the -1 thru 0 range.  The bit string is 
     695assumed to be big-endian, since it may not be possible to use little-endian 
     696in situations where the bit length isn't a multiple of 8. 
     697 
     698=item C<sys.rtn.Int.Blob_S_VBE_from_Int of NEBlob (RO: Int $int)> 
     699 
     700This selector function results in the C<Blob> value where its C<$int> 
     701argument is formatted as a variable-length binary (two's complement) signed 
     702integer of 1 or more bits in length; the smallest number of bits necessary 
     703to store C<$int> is used. 
     704 
     705=item C<sys.rtn.Int.Int_from_Blob_U_VBE of UInt (RO: NEBlob $blob)> 
     706 
     707This function is the same as C<sys.rtn.Int.Int_from_Blob_S_VBE> but that it 
     708does unsigned integers. 
     709 
     710=item C<sys.rtn.Int.Blob_U_VBE_from_Int of UInt (RO: NEBlob $blob)> 
     711 
     712This function is the same as C<sys.rtn.Int.Blob_S_VBE_from_Int> but that it 
     713does unsigned integers. 
     714 
     715=back 
     716 
     717=head2 Functions for sys.type.Blob 
    689718 
    690719These functions implement commonly used binary string operations. 
    691720 
    692721=over 
     722 
     723=item C<sys.rtn.Blob.catenate of Blob (RO: Seq{Blob} $v)> 
     724 
     725This function results in the catenation of the N element values of its 
     726argument; it is a reduction operator that recursively takes each 
     727consecutive pair of input values and catenates (which is associative) them 
     728together until just one is left, which is the result.  If C<$v> has zero 
     729values, then C<catenate> results in the empty string value, which is the 
     730identity value for catenate. 
     731 
     732=item C<sys.rtn.Blob.repeat of Blob (RO: Blob $v, UInt $count)> 
     733 
     734This function results in the catenation of C<$count> instances of C<$v>. 
     735 
     736=item C<sys.rtn.Blob.length_in_bits of UInt (RO: Blob $v)> 
     737 
     738This function results in the length of its argument in bits. 
     739 
     740=item C<sys.rtn.Blob.contains of Bool (RO: Blob $look_in, Blob $look_for, 
     741Bool $fixed_start, Bool $fixed_end)> 
     742 
     743This function results in C<Bool.True> iff its C<$look_for> argument is a 
     744substring of its C<$look_in> argument as per the optional C<$fixed_start> 
     745and C<$fixed_end> constraints, and C<Bool.False> otherwise.  If 
     746C<$fixed_start> or C<$fixed_end> are C<Bool.True>, then C<$look_for> must 
     747occur right at the start or end, respectively, of C<$look_in> in order for 
     748C<contains> to results in C<Bool.True>; if either flag is C<Bool.False>, its 
     749additional constraint doesn't apply. 
     750 
     751=item C<sys.rtn.Blob.not of Blob (RO: Blob $v)> 
     752 
     753This function results in the bitwise I<not> of its argument. 
     754 
     755=item C<sys.rtn.Blob.and of Maybe{Blob} (RO: Set{Blob} $v)> 
     756 
     757This function is a reduction operator that recursively takes each pair of 
     758its N input element values and does a bitwise I<and> (which is both 
     759commutative and associative) on them until just one is left, a C<Maybe> 
     760whose single element is which is the function's result.  This function 
     761throws an exception if not all input values are of the same length in bits. 
     762If C<$v> has zero values, then C<and> results in a same-typed C<Maybe> with 
     763zero elements.  I<Note that, while C<and> could conceivably have been 
     764defined instead to not result in a C<Maybe>, but rather to result in the 
     765appropriate string of identity-valued bits, this option is avoided for now 
     766citing practical concerns in the face of infinite blob types; also, a 
     767default empty string result is being avoided.> 
     768 
     769=item C<sys.rtn.Blob.or of Maybe{Blob} (RO: Set{Blob} $v)> 
     770 
     771This function is a reduction operator that recursively takes each pair of 
     772its N input element values and does a bitwise inclusive-or (which is both 
     773commutative and associative) on them until just one is left, a C<Maybe> 
     774whose single element is which is the function's result.  This function 
     775throws an exception if not all input values are of the same length in bits. 
     776If C<$v> has zero values, then C<or> results in a same-typed C<Maybe> with 
     777zero elements.  I<The note for C<and> applies to C<or> too.> 
     778 
     779=item C<sys.rtn.Blob.xor of Maybe{Blob} (RO: Bag{Blob} $v)> 
     780 
     781This function is a reduction operator that recursively takes each pair of 
     782its N input element values and does a bitwise exclusive-or (which is both 
     783commutative and associative) on them until just one is left, a C<Maybe> 
     784whose single element is which is the function's result.  This function 
     785throws an exception if not all input values are of the same length in bits. 
     786If C<$v> has zero values, then C<xor> results in a same-typed C<Maybe> with 
     787zero elements.  I<The note for C<and> applies to C<xor> too.> 
    693788 
    694789=back 
     
    699794=over 
    700795 
    701 =item C<sys.rtn.Blob.Blob_from_Text.2 of Blob (RO: Text $text)> 
     796=item C<sys.rtn.Blob.Blob_from_Text_2 of Blob (RO: Text $text)> 
    702797 
    703798This selector function results in the C<Blob> value that its argument maps 
    704799to when each input character is a [0-1] and represents a bit. 
    705800 
    706 =item C<sys.rtn.Blob.Text_from_Blob.2 of Text (RO: Blob $blob)> 
     801=item C<sys.rtn.Blob.Text_from_Blob_2 of Text (RO: Blob $blob)> 
    707802 
    708803This selector function results in the C<Text> value where its argument is 
    709804encoded using a [0-1] character for each bit. 
    710805 
    711 =item C<sys.rtn.Blob.Blob_from_Text.16 of Blob (RO: Text $text)> 
     806=item C<sys.rtn.Blob.Blob_from_Text_16 of Blob (RO: Text $text)> 
    712807 
    713808This selector function results in the C<Blob> value that its argument maps 
    714 to when each input character is a [0-9A-Fa-f] and represents a hex digit. 
    715  
    716 =item C<sys.rtn.Blob.Text_from_Blob.16uc of Text (RO: Blob $blob)> 
     809to when each input character is a [0-9A-F] and represents a hex digit. 
     810 
     811=item C<sys.rtn.Blob.Text_from_Blob_16 of Text (RO: Blob $blob)> 
    717812 
    718813This selector function results in the C<Text> value where its argument is 
    719814encoded using a [0-9A-F] character for each bit. 
    720815 
    721 =item C<sys.rtn.Blob.Text_from_Blob.16lc of Text (RO: Blob $blob)> 
    722  
    723 This selector function results in the C<Text> value where its argument is 
    724 encoded using a [0-9a-f] character for each bit. 
    725  
    726 =back 
    727  
    728 =head2 Functions for sys.rtn.Text 
     816=back 
     817 
     818=head2 Functions for sys.type.Text 
    729819 
    730820These functions implement commonly used character string operations. 
    731821 
    732822=over 
     823 
     824=item C<sys.rtn.Text.catenate of Text (RO: Seq{Text} $v)> 
     825 
     826This function results in the catenation of the N element values of its 
     827argument; it is a reduction operator that recursively takes each 
     828consecutive pair of input values and catenates (which is associative) them 
     829together until just one is left, which is the result.  If C<$v> has zero 
     830values, then C<catenate> results in the empty string value, which is the 
     831identity value for catenate. 
     832 
     833=item C<sys.rtn.Text.repeat of Text (RO: Text $v, UInt $count)> 
     834 
     835This function results in the catenation of C<$count> instances of C<$v>. 
     836 
     837=item C<sys.rtn.Text.length_in_nfd_graphs of UInt (RO: Text $v)> 
     838 
     839This function results in the length of its argument in Unicode 
     840Normalization Form D graphemes. 
     841 
     842=item C<sys.rtn.Text.length_in_nfc_graphs of UInt (RO: Text $v)> 
     843 
     844This function results in the length of its argument in Unicode 
     845Normalization Form C graphemes. 
     846 
     847=item C<sys.rtn.Text.length_in_nfd_codes of UInt (RO: Text $v)> 
     848 
     849This function results in the length of its argument in Unicode 
     850Normalization Form D code points. 
     851 
     852=item C<sys.rtn.Text.length_in_nfc_codes of UInt (RO: Text $v)> 
     853 
     854This function results in the length of its argument in Unicode 
     855Normalization Form C code points. 
     856 
     857=item C<sys.rtn.Text.contains of Bool (RO: Text $look_in, Text $look_for, 
     858Bool $fixed_start, Bool $fixed_end)> 
     859 
     860This function results in C<Bool.True> iff its C<$look_for> argument is a 
     861substring of its C<$look_in> argument as per the optional C<$fixed_start> 
     862and C<$fixed_end> constraints, and C<Bool.False> otherwise.  If 
     863C<$fixed_start> or C<$fixed_end> are C<Bool.True>, then C<$look_for> must 
     864occur right at the start or end, respectively, of C<$look_in> in order for 
     865C<contains> to result in C<Bool.True>; if either flag is C<Bool.False>, its 
     866additional constraint doesn't apply. 
     867 
     868=item C<sys.rtn.Text.fold_case_to_upper (RO: Text $v)> 
     869 
     870This function results in the transformation of its argument where any Latin 
     871letters are folded to (capital) uppercase. 
     872 
     873=item C<sys.rtn.Text.fold_case_to_lower (RO: Text $v)> 
     874 
     875This function results in the transformation of its argument where any Latin 
     876letters are folded to (small) lowercase. 
     877 
     878=item C<sys.rtn.Text.trim_whitespace (RO: Text $v)> 
     879 
     880This function results in the value of its argument but that any leading or 
     881trailing whitespace characters are trimmed. 
    733882 
    734883=back 
  • ext/Muldis-DB/lib/Muldis/DB/Language/Grammar.pod

    r16955 r17046  
    6969    int 
    7070        = q(Int:Default) 
    71         | q(Int:2:') /(0|-?1[0-1]*)/ q(') 
    72         | q(Int:8:') /(0|-?[1-7][0-7]*)/ q(') 
    73         | q(Int:10:') /(0|-?[1-9][0-9]*)/ q(') 
    74         | q(Int:16:') /(0|-?[1-9A-F][0-9A-F]*)/ q(') 
     71        | q(Int:) (q(2)..q(36)) q(:') /(0|-?[1-9A-Z][0-9A-Z]*)/ q(') 
    7572        ; 
    7673