Thomas Beale wrote:
archetype_id: qualified_rm_entity ‘.’ domain_concept ‘.’ version_id
qualified_rm_entity: rm_originator ‘-’ rm_name ‘-’ rm_entity
rm_originator: V_NAME
rm_name: V_NAME
rm_entity: V_NAME
domain_concept: concept_name { ‘-’ specialisation }
concept_name: V_NAME
specialisation: V_NAME
version_id: ‘v’ V_NONZERO_DIGIT [ V_NUMBER ] [ ‘.’ V_NUMBER [ ‘.’
V_NUMBER ] ]
V_NONZERO_DIGIT: [1-9]
V_DIGIT: [0-9]
V_NUMBER: [0-9]*
V_NAME: [a-zA-Z][a-zA-Z0-9_]+
The PERL regular expression equivalent of the above is as follows:
[a-zA-Z]\w+(-[a-zA-Z]\w+){2}\.[a-zA-Z]\w+(-[a-zA-Z]\w+)*\.v[1-9]\d*(\.\d+){0,2}
This all looks correct to me now, Thomas, except for the version_id
production rule:
‘v’ V_NONZERO_DIGIT [ V_NUMBER ] [ ‘.’ V_NUMBER [ ‘.’ V_NUMBER ] ]
I considered but rejected this idea, because it permits amputated version
numbers such as these:
v1.
v1..
v1..1
v1.1.
I abandoned the "V_NUMBER" idea because it allows the two optional suffixes
to have no digits! You could of course fix that by redefining V_NUMBER like
so:
V_NUMBER: [0-9]+
But then it would force you to start with a two-digit version number. v1, v2
through to v9 would all be illegal versions. Not good!
My solution is a bit tedious, but at least it is (I believe) correct:
'v' V_NONZERO_DIGIT { V_DIGIT } [ '.' V_DIGIT { V_DIGIT } ] [ '.' V_DIGIT
{ V_DIGIT } ]
V_DIGIT: [0-9]
V_NONZERO_DIGIT: [1-9]
Or, if you prefer to nest the second optional part, you could do this:
'v' V_NONZERO_DIGIT { V_DIGIT } [ '.' V_DIGIT { V_DIGIT } [ '.' V_DIGIT {
V_DIGIT } ] ]
Both are correct, but I personally find the flattened out rule a bit easier
to read.
Can someone think of something simpler that is still correct?
- Peter