Commits

ZyX_I committed fc87746

@frawor/fwc/constructor: Renamed some functions so that they have “_” at the start of their names

  • Participants
  • Parent commits ff13536

Comments (0)

Files changed (5)

File doc/frawor.txt

                         reference
 @/fwc/constructor:
     0.1: Added more functions
+    1.0: Renamed some functions so that they now have “_” at the start of 
+         their names
 @/os:
     0.1: Added |frawor-r-os.path.relpath|
          Made |frawor-r-os.path.normpath| also simplify its argument

File plugin/frawor/fwc/compiler.vim

 "▶1 Header
 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@/fwc/parser'       : '0.0',
-            \                '@/fwc/constructor'  : '0.0',
+            \                '@/fwc/constructor'  : '1.0',
             \                '@/fwc/intfuncs'     : '0.0',
             \                '@/fwc/topconstructs': '0.0',
             \                '@/resources'        : '0.0'}, 1)
 function s:compiler.fail()
     let msgstatus=self.msgs.statuses[-1]
     if msgstatus is# 'return'
-        return self[self.failcal[0]](self.failcal[1]).up()
+        return self[self.failcal[0]](self.failcal[1])._up()
     else
         return self.throw(s:cfstr)
     endif
     endif
     return   self.if('len(@$@messages)>'.msglenstr)
                     \.call('remove(@$@messages, '.msglenstr.', -1)')
-                \.up().if('len(@$@pmessages)>'.pmsglenstr)
+                \._up().if('len(@$@pmessages)>'.pmsglenstr)
                     \.call('remove(@$@pmessages, '.pmsglenstr.', -1)')
                 \.endif()
 endfunction
 "▶1 optimizecompf   :: &self(varname)
 " XXX low-level hacks here
 function s:compiler.optimizecompf(vstr)
-    call self.down(self.l[2][-1][1])
+    call self._down(self.l[2][-1][1])
     let conditions=self.optgetconds()
-    call self.up()
+    call self._up()
     if type(conditions)==type([])
-        call self.down(self.l[2])
+        call self._down(self.l[2])
         let argidxstr=self.l[-1][1][-1][1]
         let removestr=self.l[-1][-1][0][1]
         let condition=join(conditions, ' || ')
         let chargstr=a:vstr.'['.argidxstr.']'
         if condition=~#'\v^%([^@]|\V'.chargstr.'\v)+$'
-            call self.up()
-            call self.up()
+            call self._up()
+            call self._up()
             call remove(self.l, -2, -1)
             let condition=substitute(condition, '\V'.chargstr, 'v:val', 'g')
             call self.call('filter('.a:vstr.', '.string('!('.condition.')').')')
             call remove(self.l, -1)
             call self.if(condition)
             call         self.call(removestr)
-            call     self.up()
+            call     self._up()
             call self.addif()
             call         self.increment(argidxstr)
-            call     self.up()
-            call self.up()
-            call self.up()
+            call     self._up()
+            call self._up()
+            call self._up()
         endif
     endif
     return self
             call self.without()
             call self.popms()
             call         self.increment(argidxstr)
-            call     self.up()
+            call     self._up()
             call self.catch(s:cfreg)
             call         self.call('remove('.vstr.', '.argidxstr.')')
-            call self.up()
-            call self.up()
-            call self.up()
+            call self._up()
+            call self._up()
+            call self._up()
             call self.optimizecompf(vstr)
         endif
         call self.popvstr()
                 call self.compilearg(arg, idx, a:type)
                 call self.incsub()
                 if a:type is# 'complete' && !self.o.only
-                    call self.up()
+                    call self._up()
                 endif
                 if self.onlyfirst
                     return self
         call t.let('@$@pmessages', '[]')
         call t.try()
         call t.compadescr(tree, '', t.type)
-        call t.up()
+        call t._up()
         call t.finally()
         call     t.for('@$@targs', '@$@messages')
         call         t.call('call(@%@.F.warn, @$@targs, {})')
-        call     t.up()
+        call     t._up()
         call     t.for('@$@targs', '@$@pmessages')
         call         t.call('call(@%@.p._f.warn, @$@targs, {})')
-        call     t.up()
-        call t.up()
-        call t.up()
+        call     t._up()
+        call t._up()
+        call t._up()
     else
         call t.let('@-@', '[]')
         call t.compadescr(tree, '', t.type)
             call t.return('@-@')
         endif
     endif
-    return [t.o, t.tolist()]
+    return [t.o, t._tolist()]
 endfunction
 "▶1 Register fwc_compile resource
 call s:_f.postresource('fwc_compile', s:F.compstr)

File plugin/frawor/fwc/constructor.vim

 "▶1 Header
 scriptencoding utf-8
-execute frawor#Setup('0.1', {'@/resources': '0.0'}, 1)
+execute frawor#Setup('1.0', {'@/resources': '0.0'}, 1)
 let s:constructor={}
 let s:comp={}
 "▶1 string     :: a → String
     return a:s
 endfunction
 "▶1 _add       :: item, ... + self → self + self
-function s:constructor.add(...)
+function s:constructor._add(...)
     let self.l+=a:000
     return self
 endfunction
 "▶1 _up        :: &self
-function s:constructor.up()
+function s:constructor._up()
     call remove(self.stack, -1)
     let self.l=self.stack[-1]
     return self
 endfunction
 "▶1 _down      :: &self(list)
-function s:constructor.down(list)
+function s:constructor._down(list)
     call add(self.stack, a:list)
     let self.l=a:list
     return self
 endfunction
 "▶1 _deeper    :: ()[, conelement1[, ...]] + self → self + self
-function s:constructor.deeper(...)
+function s:constructor._deeper(...)
     let con=copy(a:000)
-    call self.add(con)
-    return self.down(con)
+    call self._add(con)
+    return self._down(con)
 endfunction
 "▶1 _out       :: &self
-function s:constructor.out()
+function s:constructor._out()
     if type(get(self.l, 0))==type('')
-        return self.up()
+        return self._up()
     endif
     return self
 endfunction
 "▶1 _toblock
-function s:constructor.toblock(block)
+function s:constructor._toblock(block)
     while get(self.l, 0) isnot a:block
-        call self.up()
+        call self._up()
     endwhile
     return self
 endfunction
 endfunction
 "▶2 continue   :: &self
 function s:constructor.continue()
-    return self.out().deeper('do', 'continue').up()
+    return self._out()._deeper('do', 'continue')._up()
 endfunction
 "▶2 break      :: &self
 function s:constructor.break()
-    return self.out().deeper('do', 'break').up()
+    return self._out()._deeper('do', 'break')._up()
 endfunction
 "▶2 do         :: &self(vimLstr)
 function s:constructor.do(str)
-    return self.out().deeper('do', a:str).up()
+    return self._out()._deeper('do', a:str)._up()
 endfunction
 "▶1 if block
 "▶2 comp.if
 endfunction
 "▶2 if         :: &self(expr)
 function s:constructor.if(expr, ...)
-    return self.out().deeper('if', s:F.getexpr(a:expr, a:000)).deeper()
+    return self._out()._deeper('if', s:F.getexpr(a:expr, a:000))._deeper()
 endfunction
 "▶2 elseif     :: &self(expr)
 function s:constructor.elseif(expr, ...)
-    return self.toblock('if').add('elseif', s:F.getexpr(a:expr, a:000)).deeper()
+    return self._toblock('if')._add('elseif', s:F.getexpr(a:expr, a:000))._deeper()
 endfunction
 "▶2 else       :: &self
 function s:constructor.else()
-    return self.toblock('if').add('else').deeper()
+    return self._toblock('if')._add('else')._deeper()
 endfunction
 "▶2 endif      :: &self
 function s:constructor.endif()
-    return self.toblock('if').add('endif').up()
+    return self._toblock('if')._add('endif')._up()
 endfunction
 "▶2 addif      :: &self(expr?)
 function s:constructor.addif(...)
 endfunction
 "▶2 try        :: &self()
 function s:constructor.try()
-    return self.out().deeper('try').deeper()
+    return self._out()._deeper('try')._deeper()
 endfunction
 "▶2 catch      :: &self(regex?)
 function s:constructor.catch(...)
-    return self.toblock('try')
-                \.add('catch', '/'.escape(get(a:000,0,'.*'),'/').'/').deeper()
+    return self._toblock('try')
+                \._add('catch', '/'.escape(get(a:000,0,'.*'),'/').'/')._deeper()
 endfunction
 "▶2 finally    :: &self
 function s:constructor.finally()
-    return self.toblock('try').add('finally').deeper()
+    return self._toblock('try')._add('finally')._deeper()
 endfunction
 "▶1 cycles: while, for; continue, break
 "▶2 comp.while
 endfunction
 "▶2 while      :: &self(expr)
 function s:constructor.while(expr, ...)
-    return self.out().deeper('while', s:F.getexpr(a:expr, a:000)).deeper()
+    return self._out()._deeper('while', s:F.getexpr(a:expr, a:000))._deeper()
 endfunction
 "▶2 comp.for
 function s:comp.for(r, toextend, indent, item)
 endfunction
 "▶2 for        :: &self(vars, expr)
 function s:constructor.for(vars, expr, ...)
-    return self.out().deeper('for', a:vars, s:F.getexpr(a:expr, a:000)).deeper()
+    return self._out()._deeper('for', a:vars, s:F.getexpr(a:expr, a:000))._deeper()
 endfunction
 "▶1 execute: call, throw, return
 "▶2 comp.execute
 "▶2 return, call, execute, echo, echomsg, echon
 for s:type in ['return', 'call', 'execute', 'echo', 'echomsg', 'echon']
     execute      "function s:constructor.".s:type."(expr, ...)\n".
-                \"    return self.out()".
-                \                ".deeper('execute', ".
+                \"    return self._out()".
+                \                "._deeper('execute', ".
                 \                        "'".s:type."', ".
                 \                        "s:F.getexpr(a:expr, a:000))".
-                \                ".up()\n".
+                \                "._up()\n".
                 \"endfunction"
 endfor
 unlet s:type
 "▶2 throw      :: &self(expr)
 function s:constructor.throw(expr, ...)
-    return self.out().deeper('execute', 'throw', s:F.getexpr(a:expr, a:000))
-                \.up().up()
+    return self._out()._deeper('execute', 'throw', s:F.getexpr(a:expr, a:000))
+                \._up()._up()
 endfunction
 "▶1 let: let, strappend, increment, decrement
 "▶2 comp.let
 "▶2 let, strappend
 for [s:type, s:s] in [['let', ''], ['strappend', '.']]
     execute      "function s:constructor.".s:type."(var, expr, ...)\n".
-                \"    return self.out()".
-                \                ".deeper('let', a:var, '".s:s."', ".
+                \"    return self._out()".
+                \                "._deeper('let', a:var, '".s:s."', ".
                 \                        "s:F.getexpr(a:expr, a:000))".
-                \                ".up()\n".
+                \                "._up()\n".
                 \"endfunction"
 endfor
 unlet s:type s:s
 "▶2 increment  :: &self(var[, expr])
 function s:constructor.increment(var, ...)
     let incval=get(a:000, 0, 1)
-    call self.out()
+    call self._out()
     if type(incval)==type(0) && incval<0
-        call self.deeper('let', a:var, '-', ''.(-incval))
+        call self._deeper('let', a:var, '-', ''.(-incval))
     else
-        call self.deeper('let', a:var, '+',  s:F.getexpr(incval, a:000[1:]))
+        call self._deeper('let', a:var, '+',  s:F.getexpr(incval, a:000[1:]))
     endif
-    return self.up()
+    return self._up()
 endfunction
 "▶2 decrement  :: &self(var[, expr])
 function s:constructor.decrement(var, ...)
     let incval=get(a:000, 0, 1)
-    call self.out()
+    call self._out()
     if type(incval)==type(0) && incval<0
-        call self.deeper('let', a:var, '+', ''.(-incval))
+        call self._deeper('let', a:var, '+', ''.(-incval))
     else
-        call self.deeper('let', a:var, '-',  s:F.getexpr(incval, a:000[1:]))
+        call self._deeper('let', a:var, '-',  s:F.getexpr(incval, a:000[1:]))
     endif
-    return self.up()
+    return self._up()
 endfunction
 "▶1 unlet      :: &self(var|[var])
 function s:comp.unlet(r, toextend, indent, item)
     call add(a:r, repeat(' ', &sw*a:indent).'unlet '.join(remove(a:item, 0)))
 endfunction
 function s:constructor.unlet(var)
-    return self.out().deeper('unlet', type(a:var)==type('')?[a:var]:a:var)
-                \.up()
+    return self._out()._deeper('unlet', type(a:var)==type('')?[a:var]:a:var)
+                \._up()
 endfunction
 "▶1 _tolist    :: () + self → [String]
-function s:constructor.tolist()
+function s:constructor._tolist()
     let r=[]
     let items=map(deepcopy(self.tree), '[0, v:val]')
     let toextend=[]

File plugin/frawor/fwc/intfuncs.vim

     call        self.compilearg(a:desc[1], a:idx.'(cond)', 'check')
     call        self.popms()
     call        self.let(condstr, 1)
-    call    self.up()
+    call    self._up()
     call    self.catch(s:cfreg)
     call        self.let(condstr, 0)
-    call    self.up()
+    call    self._up()
     if len(a:desc[2])>1
         call self.addif(condstr)
         call    self.compilearg(a:desc[2], a:idx.'(if)', a:type)
-        call self.up()
+        call self._up()
         if len(a:desc[3])>1
             call self.addif()
             call        self.compilearg(a:desc[3], a:idx.'(else)', a:type)
-            call        self.up()
+            call        self._up()
         endif
     else
         call self.addif('!'.condstr)
         call        self.compilearg(a:desc[3], a:idx.'(else)', a:type)
-        call        self.up()
+        call        self._up()
     endif
-    return self.up()
+    return self._up()
 endfunction
 let s:r.if.complete=s:r.if.pipe
 "▶1 `run'
     call    self.try()
     call        self.let(curargstr, 'call('.curargstr.', '.
                 \                                self.getvar(a:desc[1]).', {})')
-    call    self.up()
+    call    self._up()
     call    self.catch()
     call        self.addthrow('runfail', 1, a:idx, 'v:exception')
     let self.typechanged=1
     call self.addtypecond([type('')], a:idx)
     call self.try()
     call     self.let(curargstr, 'eval('.curargstr.')')
-    call self.up()
+    call self._up()
     call self.catch()
     call     self.addthrow('evalfail', 1, a:idx, 'v:exception')
     let self.typechanged=1
 "▶2 optimize
 " XXX low-level hacks here
 function s:r.not.optimize(idx, type)
-    call self.down(self.l[1])
+    call self._down(self.l[1])
     let conditions=self.optgetconds()
-    call self.up()
+    call self._up()
     if type(conditions)==type([])
         call remove(self.l, 0, -1)
-        call self.add('if', 0, [])
+        call self._add('if', 0, [])
         call self.nextthrow('!('.join(conditions, ' || ').')', 'notfail', a:idx)
         call remove(self.l, 1, 3)
     endif
                 \.compilearg(a:desc[1], a:idx.'(not)', 'check')
                 \.popms()
                 \.throw("'NOTFAIL'")
-            \.catch(s:cfreg).up()
+            \.catch(s:cfreg)._up()
             \.catch('\v^NOTFAIL$')
                 \.addthrow('notfail', 1, a:idx)
 endfunction
     if !empty(a:desc[1])
         call self.try()
         call        self.compilearg(a:desc[1][0], a:idx.'(either).0', 'check')
-        call self.up()
+        call self._up()
         call self.catch(s:cfreg)
         call        self.let(sucstr, 0)
-        call self.up()
+        call self._up()
     endif
     let i=1
     for arg in a:desc[1][1:]
         call        self.let(sucstr, 1)
         call        self.try()
         call            self.compilearg(arg, a:idx.'(either).'.i, 'check')
-        call        self.up()
+        call        self._up()
         call        self.catch(s:cfreg)
         call            self.let(sucstr, 0)
-        call        self.up()
-        call    self.up()
+        call        self._up()
+        call    self._up()
         let i+=1
     endfor
     call self.addif(sucstr)
     call self.addrestmsgs()
-    call self.up()
+    call self._up()
     call self.popms()
     call self.addif()
     call self.addthrow('eitherfail', 1, a:idx)
-    call self.up()
-    call self.up()
+    call self._up()
+    call self._up()
     return self
 endfunction
 function s:r.either.complete(desc, idx, type)
     for arg in a:desc[1][1:]
         call self.if('empty('.self.vstrs[-1].')')
         call        self.compilearg(arg, a:idx.'(either).'.i, 'complete')
-        call self.up()
+        call self._up()
         call self.endif()
         let i+=1
     endfor
     call self.while(istr.'<'.largstr)
     call            self.compilearg(a:list[1], a:idx.'(list)', a:type)
     call            self.increment(istr)
-    call self.up()
-    call self.up()
+    call self._up()
+    call self._up()
     call remove(self.subs, -1)
     return self
 endfunction
             call        self.let(foundstr, 1)
             call        self.compilearg(check[2], a:idx.'.'.i.'(val)', a:type)
             call        self.popms()
-            call self.up()
+            call self._up()
             call self.catch(s:cfreg)
             call        self.addif(foundstr)
             call            self.fail()
             call        self.addrestmsgs(1)
-            call self.up()
+            call self._up()
             call self.addif(foundstr)
             call        self.continue()
-            call self.up()
+            call self._up()
             continue
         endif
         call self.compilearg(check[2], a:idx.'.'.i.'(val)', a:type)
         call self.continue()
-        call self.up()
+        call self._up()
     endfor
     if hascheck
         call remove(self.msgs.savevars, -1)
     call            self.addif('filewritable('.dirnamestr.')==2')
     call                self.let(foundstr, 1)
     call                self.break()
-    call                self.up()
+    call                self._up()
     call            self.addif(existsstr.'('.dirnamestr.')')
     call                self.break()
-    call                self.up()
+    call                self._up()
     call            self.let(prevdirstr, dirnamestr)
     call            self.let(dirnamestr, osdirnamestr.'('.dirnamestr.')')
-    call        self.up()
+    call        self._up()
     call        self.nextthrow('!'.foundstr, 'nowrite', a:idx, curargstr)
-    call self.up()
-    call self.up()
+    call self._up()
+    call self._up()
     return self
 endfunction
 "▶2 getpath    :: &self!
 function s:r.isreg.check(desc, idx, type)
     let curargstr=self.argstr()
     return self.addtypecond([type('')], a:idx)
-                \.try().call('matchstr("", '.curargstr.')').up()
+                \.try().call('matchstr("", '.curargstr.')')._up()
                 \.catch().addthrow('nreg', 1, a:idx, curargstr, 'v:exception')
 endfunction
 "▶1 `bool'

File plugin/frawor/fwc/topconstructs.vim

                     call            self.let(a:caidxstr, self.getlastsub())
                     call        self.catch(s:cfreg)
                     call            self.let(failstr, 1)
-                    call        self.up()
+                    call        self._up()
                     if i>0
                         call    self.endif()
                     endif
             call self.increment(a:largsstr, ldefaults)
         endif
     endif
-    call self.up()
+    call self._up()
     let self.subs[-1]=[a:caidxstr]
     if lopt>1
         let i=1
         call self.addif(a:caidxstr.'=='.a:largsstr.'-1')
         call        self.setmatches(plstr, type([]), 1)
         call        self.break()
-        call self.up()
+        call self._up()
     endif
     call self.let(astr, self.getmatcher(get(a:adescr, 'prefixesmatcher',
                 \                           s:prefdefmatcher), plstr,
         endif
         if !self.o.onlystrings
             if haslist
-                call self.up()
+                call self._up()
                 call self.else()
                 call    self.let(astr, 0)
-                call self.up()
+                call self._up()
                 call self.endif()
                 call self.if(astr.' isnot 0')
             else
             call self.call(removestr)
         endif
         if haslist
-            call self.up()
+            call self._up()
             call self.endif()
         endif
     else
                             \            a:type)
                 call        self.increment(a:caidxstr, idxdiffstr)
                 call        self.break()
-                call self.up()
+                call self._up()
             endfor
-            call self.up()
-            call self.up()
+            call self._up()
+            call self._up()
         endif
         "▶3 Move prefix arguments to prefix dictionary
         if a:type is# 'complete'
-            call self.up()
+            call self._up()
         elseif prefopts.list
             let removestr='remove('.base.', '.a:caidxstr.', '.
                         \           a:caidxstr.'+'.(prefopts.argnum-1).')'
             call        self.increment(prefstr, removestr)
             call self.else()
             call        self.let(prefstr, removestr)
-            call self.up()
+            call self._up()
             call self.let(lastliststr, prefixstr)
         else
             if haslist
         endif
         "▲3
         let self.subs[-1]=[a:caidxstr]
-        call self.up()
+        call self._up()
         "▶3 Process `no{prefix}'
         if a:type is# 'check' || a:type is# 'pipe'
             if prefopts.alt
                     call self.let(lastliststr, 0)
                 endif
                 call        self.let(prefstr, 0)
-                call        self.up()
+                call        self._up()
             endif
         endif
         "▲3
     if a:type is# 'complete'
         call self.addif(astr.' is 0')
         call        self.break()
-        call self.up()
+        call self._up()
     endif
     if a:type is# 'check' || a:type is# 'pipe'
         if hasnext
             if haslist
                 call self.nextthrow(astr.' is 0', 'pnf', idx, self.argstr())
             endif
-            call self.up()
+            call self._up()
             if haslist
                 call self.if('exists('.string(argorigstr).')')
                 call    self.unlet(argorigstr)
-                call self.up()
-                call self.up()
+                call self._up()
+                call self._up()
             else
                 call self.unlet(argorigstr)
             endif
-            call self.up()
-            call self.up()
+            call self._up()
+            call self._up()
             call self.addrestmsgs(1)
             call self.popms()
             call self.catch(s:cfreg)
             call    self.if('exists('.string(argorigstr).')')
             call     self.call('insert('.base.','.argorigstr.','.a:caidxstr.')')
             call     self.increment(a:largsstr)
-            call    self.up()
-            call self.up()
+            call    self._up()
+            call self._up()
         else
             if haslist
                 call self.nextthrow(astr.' is 0', 'pnf', idx, self.argstr())
             endif
-            call self.up()
-            call self.up()
+            call self._up()
+            call self._up()
         endif
         if !empty(reqpreflist)
             call self.nextthrow('!empty(filter(copy('.rplstr.'), '.
                         \       'noreqpref', a:idx)
         endif
     else
-        call self.up()
-        call self.up()
+        call self._up()
+        call self._up()
     endif
     return [[a:caidxstr], addedsavemsgs]
 endfunction
         endif
         call self.addif(condition)
         call        self.compilearg(a:adescr.next[0], a:idx.'.(next)', a:type)
-        call self.up()
+        call self._up()
         if hasnext
             call self.pushms('throwignore')
             call        self.try()
             call              self.compilearg(a:adescr.next[0], a:idx.'.(next)',
                               \            'check')
             call              self.increment(a:caidxstr)
-            call            self.up()
+            call            self._up()
             call        self.catch(s:cfreg)
             call            self.call('remove('.self.vstrs[-1].', 0, -1)')
-            call        self.up()
+            call        self._up()
         endif
     else
         if hasnext
         call self.while(a:caidxstr.'<'.a:largsstr)
         call        self.compilearg(a:adescr.next[0], a:idx.'.(next)', a:type)
         call        self.increment(a:caidxstr)
-        call        self.up()
+        call        self._up()
         if hasnext
             call self.addrestmsgs(1)
             call self.catch(s:cfreg)
             call self.popms()
-            call self.up()
+            call self._up()
         endif
     endif
     return [[a:caidxstr], addedsavemsgs]
         if noact isnot 0 && len(noact)>1
             let self.onlyfirst+=1
             call self.compadescr(noact[1], idx.'.nullact', a:type, 0)
-            call self.out()
+            call self._out()
             call call(s:r.actions.optimizenullact, [a:caidxstr], self)
             let self.onlyfirst-=1
         endif
         let self.subs[-1]=savedsub
-        call self.up()
+        call self._up()
         if self.onlyfirst
             return [[a:caidxstr], a:addedsavemsgs]
         else
                         \        a:type, 0)
         endif
         call self.let(a:caidxstr, self.getlastsub())
-        call self.up()
+        call self._up()
         let self.subs[-1]=copy(astartsub)
     endfor
     if noact isnot 0
             call        self.let(a:caidxstr, self.getlastsub())
         endif
         let self.subs[-1]=copy(astartsub)
-        call self.up()
-        call self.up()
+        call self._up()
+        call self._up()
     endif
     let self.subs[-1]=[a:caidxstr]
     if a:type is# 'complete'
-        call self.up()
-        call self.up()
+        call self._up()
+        call self._up()
     endif
     return [[a:caidxstr], a:addedsavemsgs]
 endfunction