Changeset 577

Show
Ignore:
Timestamp:
07/20/08 22:46:47 (2 months ago)
Author:
athomas
Message:

Use "graft" attribute of <grammar> root element if available.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cly/trunk/cly/builder.py

    r576 r577  
    837837    @classmethod 
    838838    def attribute_aliases(cls): 
    839         return {'exec': 'callback'} 
     839        aliases = {'exec': 'callback'} 
     840        aliases.update(super(Action, cls).attribute_aliases()) 
     841        return aliases 
    840842 
    841843    @classmethod 
     
    11371139            data = {} 
    11381140            vars = {} 
     1141 
    11391142        def defined(vars, any=False): 
     1143            """Test if all (or any) of vars are defined.""" 
    11401144            for var in vars.split(): 
    11411145                defined = var in locals 
  • cly/trunk/cly/parser.py

    r576 r577  
    348348        return context 
    349349 
    350     def merge(self, where, grammar): 
     350    def merge(self, grammar, where=None): 
    351351        """Merge another grammar into this one. 
    352352 
     
    355355            :grammar: Grammar to merge. 
    356356        """ 
     357        if where is None: 
     358            assert hasattr(grammar, 'graft'), \ 
     359                'need either an explicit "where" or a "graft" attribute on ' 
     360                'the <grammar> root' 
     361            where = grammar.graft 
    357362        where = self.find(where) 
    358363        where.update(grammar)