Commits

ZyX_I committed fd96b9e

@/fwc: Forced idx and type arguments to compadescr

  • Participants
  • Parent commits f99bdd6

Comments (0)

Files changed (2)

File plugin/frawor/fwc/compiler.vim

     endif
     return self
 endfunction
-"▶1 compadescr      :: &self(adescr[, idx[, purgemax[, type]]])
-function s:compiler.compadescr(adescr, ...)
-    let purgemax=get(a:000, 1, 0)
-    let type=get(a:000, 2, self.type)
+"▶1 compadescr      :: &self(adescr, idx, type[, purgemax]])
+function s:compiler.compadescr(adescr, idx, type, ...)
+    let purgemax=get(a:000, 0, 0)
     "▶2 Length checks, lagsstr and nextsub variables
     if !empty(self.subs)
         let largsstr=self.getlargsstr()
-        if type is 'check' || type is 'pipe'
+        if a:type is 'check' || a:type is 'pipe'
             if !has_key(a:adescr, 'minimum')
                 call s:F.getlenrange(a:adescr)
             endif
         for arg in a:adescr.arg
             let i+=1
             if self.o.only
-                let idx=''
-            elseif a:0
-                let idx=a:1.'.'.i
-            elseif type(self.subs)!=type([])
-                let idx=self.subs[-1]
+                let idx=a:idx
             else
-                let idx=''
+                let idx=a:idx.'.'.i
             endif
-            if type is 'complete' && !self.o.only
+            if a:type is 'complete' && !self.o.only
                 call self.addif(largsstr.'-1 == '.self.getlastsub())
             endif
-            call self.compilearg(arg, idx, type)
+            call self.compilearg(arg, idx, a:type)
             call self.incsub()
-            if type is 'complete' && !self.o.only
+            if a:type is 'complete' && !self.o.only
                 call self.up()
             endif
             if self.onlyfirst
         call self.let(caidxstr, oldsub)
     endif
     let self.subs[-1]=[caidxstr]
-    let idx=get(a:000, 0, '')
     "▶2 Following keys (optional, prefixes, next, actions)
     for key in s:_r.FWC_topconstructs._order
         if has_key(a:adescr, key)
             endif
             let [newnextsub, addedsavemsgs]=
                         \call(s:_r.FWC_topconstructs[key].compile,
-                        \     [a:adescr,idx, caidxstr, largsstr, purgemax, type,
+                        \     [a:adescr,a:idx,caidxstr,largsstr,purgemax,a:type,
                         \      nextsub, addedsavemsgs],
                         \     self)
             unlet nextsub
     endfor
     "▶2 Check for processed argument length
     " XXX a:0 is checked here
-    if !a:0 && type(self.subs[-1])==type([]) && type isnot 'complete'
+    if !a:0 && type(self.subs[-1])==type([]) && a:type isnot 'complete'
         let largsstr=self.getlargsstr()
         let proclen=self.getlastsub()
         call self.addif(proclen.' isnot '.largsstr)
         call        t.let('@$@messages',  '[]')
                     \.let('@$@pmessages', '[]')
                     \.try()
-        call t.compadescr(tree)
+        call t.compadescr(tree, '', t.type)
         call t
                 \.up().finally()
                     \.for('@$@targs', '@$@messages')
                         \.call('call(@%@.p._f.warn, @$@targs, {})').up()
                 \.up().up()
     else
-        call t.let('@-@', '[]').compadescr(tree)
+        call t.let('@-@', '[]').compadescr(tree, '', t.type)
     endif
     if a:doreturn is 1
         if t.type is 'check'

File plugin/frawor/fwc/topconstructs.vim

     if a:type is 'complete'
         let hasnext=s:F.hasnext(a:adescr, 'next')
         if !hasnext && len(a:adescr.optional)==1
-            call self.compadescr(a:adescr.optional[0], a:idx.'.0(optional)', 0,
-                        \        a:type)
+            call self.compadescr(a:adescr.optional[0], a:idx.'.0(optional)',
+                        \        a:type, 0)
             let oldsub=self.getsub(self.subs[-1])
             if oldsub isnot a:caidxstr
                 call self.let(a:caidxstr, oldsub)
     call self.addsavemsgs()
                 \.try()
                     \.pushms('throw')
-                    \.compadescr(a:adescr.optional[0],
-                    \            a:idx.'.0(optional)',
-                    \            (a:purgemax || a:adescr.maximum==-1), a:type)
+                    \.compadescr(a:adescr.optional[0], a:idx.'.0(optional)',
+                    \            a:type, (a:purgemax || a:adescr.maximum==-1))
                     \.popms()
                     \.addrestmsgs(1)
     if lopt>1
             call self.if(failstr)
                         \.try()
                             \.pushms('throw')
-                            \.compadescr(opt, a:idx.'.'.i.'(optional)', 0,
-                            \            a:type)
+                            \.compadescr(opt,a:idx.'.'.i.'(optional)',a:type,0)
                             \.popms()
                             \.addrestmsgs(1)
                             \.let(failstr, 0)
         let savedsub=copy(self.subs[-1])
         if noact isnot 0 && len(noact)>1
             let self.onlyfirst+=1
-            call self.compadescr(noact[1], idx.'.nullact', 0, a:type).out()
+            call self.compadescr(noact[1], idx.'.nullact', a:type, 0).out()
             call call(s:r.actions.optimizenullact, [a:caidxstr], self)
             let self.onlyfirst-=1
         endif
     for [actstr; actargs] in actions
         call self.addif(actionstr.' is '.self.string(actstr))
         if !empty(actargs)
-            call self.compadescr(actargs[0], idx.'.'.self.string(actstr), 0,
-                        \        a:type)
+            call self.compadescr(actargs[0], idx.'.'.self.string(actstr),
+                        \        a:type, 0)
         endif
         call self.let(a:caidxstr, self.getlastsub()).up()
         let self.subs[-1]=copy(astartsub)
         endif
         call self.incsub(-1)
         if len(noact)>1
-            call self.compadescr(noact[1], idx.'.nullact', 0, a:type)
+            call self.compadescr(noact[1], idx.'.nullact', a:type, 0)
                         \.let(a:caidxstr, self.getlastsub())
         endif
         let self.subs[-1]=copy(astartsub)