Changeset 1841

Show
Ignore:
Timestamp:
08/06/07 06:21:26 (1 year ago)
Author:
wrobe..@pld-linux.org
Message:

- name should not start with number (still inapropriate name will be set

from garbage re group)

- allow to enter multiplicity as '[1]' not only '1'

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/gaphor/UML/umllex.py

    r1243 r1841  
    2222 
    2323# name (required) ::= name 
    24 name_subpat = r'\s*(?P<name>\w+)' 
     24name_subpat = r'\s*(?P<name>[a-zA-Z_]\w*)' 
    2525 
    2626# Multiplicity (added to type_subpat) ::= '[' [mult_l ..] mult_u ']' 
    2727mult_subpat = r'\s*(\[\s*((?P<mult_l>[0-9]+)\s*\.\.)?\s*(?P<mult_u>([0-9]+|\*))\s*\])?' 
    28 multa_subpat = r'\s*(((?P<mult_l>[0-9]+)\s*\.\.)?\s*(?P<mult_u>([0-9]+|\*)))?' 
     28multa_subpat = r'\s*(\[?((?P<mult_l>[0-9]+)\s*\.\.)?\s*(?P<mult_u>([0-9]+|\*))\]?)?' 
    2929 
    3030# Type and multiplicity (optional) ::= ':' type [mult] 
     
    150150    from uml2 import LiteralSpecification 
    151151    create = self._factory.create 
     152 
     153    # if no name, then clear as there could be some garbage 
     154    # due to previous parsing (i.e. '[1' 
     155    m = association_end_name_pat.match(s) 
     156    if m and not m.group('name'): 
     157        self.name = '' 
     158 
    152159    m = association_end_mult_pat.match(s) 
    153160    if m and m.group('mult_u') or m.group('tags'): 
     
    183190                    self.lowerValue = create(LiteralSpecification) 
    184191                self.lowerValue.value = g('mult_l') 
     192            else: 
     193                self.lowerValue.value = '' 
    185194            if g('mult_u'): 
    186195                if not g('mult_l') and self.lowerValue: 
     
    189198                    self.upperValue = create(LiteralSpecification) 
    190199                self.upperValue.value = g('mult_u') 
     200            else: 
     201                self.upperValue.value = '' 
    191202            tags = g('tags') 
    192203            if tags: