This is an archive copy of the IUCr web site dating from 2008. For current content please visit https://www.iucr.org.
[IUCr Home Page] [CIF Home Page] [mmCIF Home Page]

Regular expressions

Peter Keller (bsspak@bath.ac.uk)
Tue, 30 Jan 1996 10:44:30 +0000 (GMT)


Hi - the _item_type_list.construct values for code and ucode are 
incorrect, as shown by OSF1's POSIX-conforming regcomp(3) function's 
refusal to compile them. The offending part is:

     loop_
    _item_type_list.code
    _item_type_list.primitive_code
    _item_type_list.construct
    _item_type_list.detail
               code      char
               '[_,.;:"&<>/\{}'`~!@#$%-A-Za-z0-9*|+-]*'
;              code item types/single words ...
;
               ucode      uchar
               '[_,.;:"&<>/\{}'`~!@#$%-A-Za-z0-9*|+-]*'
;              code item types/single words  (case insensitive) ...
;

The error which is given is "Invalid range expression" (POSIX's
REG_ERANGE), which refers to the '...%-A-Z...' bit. Since '%-A' would
include the digits, and other characters which are already explicitly
included, and the expressions contain '...-]' which matches a literal '-',
I assume that what is meant is: 

                '[_,.;:"&<>/\{}'`~!@#$%A-Za-z0-9*|+-]*'

Also, could I make a plea for an explanation of '\n' and '\t' to be put in
_item_description.description for save__item_type_list.construct in the
DDL? These escape sequences are NOT in the POSIX standard for regular
expressions - they only have meaning in the lexical analysis of character
constants and string constants in C/C++ source code! There is no reason to
assume that the contents of _item_type_list.construct are going to be fed
through a C compiler in a general implementation (and even if they were, 
they would still not produce the correct results, for other reasons).

Regards,
Peter.

========================================================================
Peter Keller.            \  "Having beguiled with fiction until I had
Dept. of Biology and      \    none left I resorted to facts, which
    Biochemistry,          \     also ran out."
University of Bath,         \          - Alisdair Gray
Bath, BA2 7AY, UK.           \ 
------------------------------\-----------------------------------------
Tel. (+44/0)1225 826826 x 4302 | Email: P.A.Keller@bath.ac.uk (Internet)
Fax. (+44/0)1225 826449        |   P.A.Keller%bath.ac.uk@UKACRL (BITNET)
========================================================================