diff -ur v6/inc_ut.py v7/inc_ut.py --- v6/inc_ut.py 2020-09-24 21:32:53.000000000 +0900 +++ v7/inc_ut.py 2020-09-26 02:54:32.000000000 +0900 @@ -11,20 +11,34 @@ dic = {} ks = [] + e = empty.new() + e.last = '' + + def anon_k(): + id = 0 + get = lambda : 'tMp_{}'.format( id ) + while get() in dic: + id += 1 + return get() + def set(s): - get_k = lambda : s[ 2 : ] + def get_k(): + k = s[ 2 : ] + return k if k else anon_k() if s.startswith( '@>' ): ks.append( get_k() ) return True if s.startswith( '@<' ): if ks: - ks.pop() + e.last = ks.pop() return True if s.startswith( '@!' ): k = get_k() if k in dic: dic.pop( k ) + if k == e.last: + e.last = '' return True if ks: k = ks[ -1 ] @@ -37,7 +51,9 @@ get = dic.get - return empty.new( locals() ) + to_last_key = lambda s, k='$$': s.replace( k, e.last ) + + return empty.add( e, locals() ) def read_str(path): r = False @@ -96,6 +112,9 @@ if path == None: return None + path = buf.to_last_key( path ) + opts = list( map( buf.to_last_key, opts ) ) + r = buf.get( path ) if r != None: paths.append( path )