#NEWLINE# def accum_append( self , val , raw = False ) : #NEWLINE# #INDENT# "Add one element to an EvalPropContext. The value must be a\n        string or a static GenNodeClass. This relies on, and modifies,\n        the ctx state (textstate).\n        The upshot is to (probably) add a new string to self.accum, or\n        perhaps a paragraph break marker.\n\n        This algorithm is occult, and I'm sorry for that. It's not logically\n        *that* complicated; but it has a lot of interacting cases.\n        " #NEWLINE# raw = ( raw or ( not self . cooked ) ) #NEWLINE# if isinstance ( val , GenNodeClass ) : #NEWLINE# #INDENT# nodtyp = type ( val ) #NEWLINE# if ( nodtyp in ( RunOnNode , RunOnExplicitNode , CommaNode , SemiNode , StopNode , ParaNode ) ) : #NEWLINE# #INDENT# if ( self . textstate . precedence < nodtyp . precedence ) : #NEWLINE# #INDENT# self . textstate = nodtyp #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# assert ( type ( val ) is str ) #NEWLINE# if ( not val ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# nodtyp = WordNode #NEWLINE# #UNINDENT# docap = False #NEWLINE# if ( self . textstate in ( RunOnNode , RunOnExplicitNode ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . textstate in ( BeginNode , StopNode , ParaNode ) ) : #NEWLINE# #INDENT# if ( self . textstate is StopNode ) : #NEWLINE# #INDENT# self . accum . append ( '. ' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . textstate is ParaNode ) : #NEWLINE# #INDENT# self . accum . append ( '.' ) #NEWLINE# self . accum . append ( [ 'para' ] ) #NEWLINE# #UNINDENT# #UNINDENT# docap = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . textstate is SemiNode ) : #NEWLINE# #INDENT# self . accum . append ( '; ' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . textstate is CommaNode ) : #NEWLINE# #INDENT# self . accum . append ( ', ' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . textstate is RunOnCapNode ) : #NEWLINE# #INDENT# docap = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . textstate is ANode ) : #NEWLINE# #INDENT# if ( nodtyp is AFormNode ) : #NEWLINE# #INDENT# self . accum . append ( ' ' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( nodtyp is AnFormNode ) : #NEWLINE# #INDENT# self . accum . append ( 'n ' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( nodtyp is WordNode ) and re_vowelstart . match ( val ) ) : #NEWLINE# #INDENT# self . accum . append ( 'n ' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . accum . append ( ' ' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . accum . append ( ' ' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( nodtyp is WordNode ) : #NEWLINE# #INDENT# if docap : #NEWLINE# #INDENT# self . accum . append ( val [ 0 ] . upper ( ) ) #NEWLINE# self . accum . append ( val [ 1 : ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . accum . append ( val ) #NEWLINE# #UNINDENT# if raw : #NEWLINE# #INDENT# self . textstate = RunOnNode #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . textstate = WordNode #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( nodtyp is ANode ) : #NEWLINE# #INDENT# if docap : #NEWLINE# #INDENT# self . accum . append ( 'A' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . accum . append ( 'a' ) #NEWLINE# #UNINDENT# self . textstate = ANode #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( nodtyp in ( AFormNode , AnFormNode ) ) : #NEWLINE# #INDENT# if docap : #NEWLINE# #INDENT# self . textstate = RunOnCapNode #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . textstate = RunOnNode #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . accum . append ( ( '[Unsupported GenNodeClass: %s]' % ( nodtyp . __name__ , ) ) )