Commits

ZyX_I committed 76f9590

@/fwc/compiler: Implemented `next' key

  • Participants
  • Parent commits e2bd55c

Comments (0)

Files changed (3)

File plugin/frawor/fwc/compiler.vim

     let addedsavemsgs=0
     let caidxstr=self.getlvarid('caidx')
     let caidx=[caidxstr]
-    let oldsub=s:F.getsub(nextsub)
-    call self.let(caidxstr, oldsub)
-    let self.subs[-1]=copy(caidx)
     if has_key(a:adescr, 'optional')
+        call self.let(caidxstr, s:F.getsub(nextsub))
+        let self.subs[-1]=copy(caidx)
+        unlet nextsub
+        let nextsub=copy(caidx)
         let lopt=len(a:adescr.optional)
         if lopt>1
             let failstr=self.getlvarid('fail')
             endfor
         endif
     endif
-    " TODO
+    if has_key(a:adescr, 'prefixes')
+        " TODO
+    endif
+    if has_key(a:adescr, 'next')
+        call self.let(caidxstr, s:F.getsub(nextsub))
+        let self.subs[-1]=copy(caidx)
+        unlet nextsub
+        let nextsub=copy(caidx)
+        if has_key(a:adescr, 'actions')
+            if !addedsavemsgs
+                call self.addsavemsgs()
+                let addedsavemsgs=1
+            endif
+            call self.try().pushms('throw')
+        endif
+        let largsstr=self.getlargsstr()
+        call self.while(caidxstr.'<'.largsstr)
+                    \.compilearg(a:adescr.next[0], get(a:000, 0, '').'.(next)')
+                    \.increment(caidxstr)
+                    \.up()
+        if has_key(a:adescr, 'actions')
+            call self.catch(s:cfreg).popms().up()
+        endif
+    endif
+    if has_key(a:adescr, 'actions')
+        " TODO
+    endif
     " XXX a:0 is checked here
     if !a:0 && type(self.subs[-1])==type([])
         let largsstr=self.getlargsstr()

File test/fwccheck.ok

 plugin/frawor/fwc/compiler:lennmatch
 plugin/frawor/fwc/compiler:invlen
 plugin/frawor/fwc/compiler:invlen
+::: Section <Next arguments>
+plugin/frawor/fwc/compiler:nbool
 <<< messages

File test/fwctests.dat

 ['bool [bool] [bool bool bool]',         'check'], [0, 0],       1
 ['bool [bool] [bool bool bool]',         'check'], [0, 0, 0],    0
 ['bool [bool] [bool bool bool]',         'check'], [0, 0, 0, 0], 1
+#▶1 Next arguments
+['+ bool',                              'filter'], [2, {}, 4],   [1, 0, 1]
+['+ bool',                              'filter'], [],           []
+['+ bool',                               'check'], [0, {}, 4],   0
+['+ bool',                               'check'], [0, 1, 0],    1
 # vim: cms=#%s fmr=▶,▲