troy d. straszheim wrote:
> 
> def production(s):
>      # create the function that the decorator returns
>      # which gets immediately called with the function
>      # containing the actual evalling/AST-generating code
>      def impl(f):
>          # p_impl is the parser function that just calls to the decorated
>          # function
>          def p_impl(p):
>              s
>              return f(p)
>          # up in the namespace containing the decorator, assign our
>          # p_impl function to a generated name where ply will find it.
>          # It checks that name __name__ attribute of the function
>          # starts with p_... we need to set that.
>          fnname = 'p_' + s.replace(':','').replace(' ', '_')
>          p_impl.__name__ = fnname
> 
>          frameup = sys._getframe(1)
>          frameup.f_locals[fnname] = p_impl
>      return impl
> 

Bad paste, sorry for the noise.  Corrected version:

def production(s):
     # create the function that the decorator returns
     # which gets immediately called with the function
     # containing the actual evalling/AST-generating code
     def impl(f):
         # p_impl is the parser function that just calls to the decorated
         # function
         def p_impl(p):
             return f(p)
         p_impl.__doc__ = s
         # up in the namespace containing the decorator, assign our
         # p_impl function to a generated name where ply will find it.
         # It checks that name __name__ attribute of the function
         # starts with p_... we need to set that.
         fnname = 'p_' + s.replace(':','').replace(' ', '_')
         p_impl.__name__ = fnname

         frameup = sys._getframe(1)
         frameup.f_locals[fnname] = p_impl
     return impl


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ply-hack" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/ply-hack?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to