Commits

ZyX_I committed b3f0c9b

@/fwc: Added tests for partial prefixes implementation, some fixes

Comments (0)

Files changed (4)

plugin/frawor/fwc/compiler.vim

                         \   (0):
                         \   ((prefopts.list)?
                         \       (2):
-                        \       (1+prefopts.argnum)))
+                        \       (1+((prefopts.alt)?
+                        \               (0):
+                        \               (prefopts.argnum)))))
         endfor
     endif
     "▶2 “next” key
                             \.let(prefstr, 0)
                             \.up()
             endif
+            let key=string([self.argbase]+self.subs[:-2])[1:-2]
+            if has_key(self.lavars, key)
+                unlet self.lavars[key]
+            endif
         endfor
         call self.up()
         if addtry

plugin/frawor/fwc/parser.vim

         if !exists('pref')
             if !exists('prefopts')
                 let prefopts=copy(s:defprefopts)
+                let prefopts.argnum=1
             endif
-            let prefopts.argnum=1
             if c=~#'^\w'
                 let pref=c
             elseif c is '"'
                 let prefopts.opt=1
             elseif c is '!'
                 let prefopts.alt=1
+                let prefopts.argnum=0
             elseif c is '*'
                 let prefopts.list=1
             elseif c is '}'
         else
             call self.addcon('prefix', pref, prefopts)
             if c is ':'
+                let prefopts.opt=1
                 call self.getvar()
                 let c=self.readc()
             endif
 plugin/frawor/fwc/compiler:anf
 plugin/frawor/fwc/compiler:invlen
 plugin/frawor/fwc/compiler:anf
+::: Section <Prefixes>
 <<< messages

test/fwctests.dat

 ['<abc (bool) def (bool bool) - (isreg)>',   'filter'], ['\v('],   0
 ['<abc (bool) def (bool bool) - (isreg)>',   'filter'], ['b', ''], 0
 ['<~smart abc (bool)>',                      'filter'], ['b', ''], ['abc', 0]
+#▶1 Prefixes
+['{abc bool}',                      'filter'], ['a', {}], [{'abc': 0}]
+['{abc :=(2) bool}',                'filter'], ['a', {}], [{'abc': 0}]
+['{abc :=(2) bool}',                'filter'], [],        [{'abc': 2}]
+['{!abc !def :=(2)}',               'filter'], ['a'],     [{'abc': 1, 'def': 2}]
+['{!abc !def :=(2)}',               'filter'], ['noa'],   [{'abc': 0, 'def': 2}]
+['{!abc}',                          'filter'], ['a'],     [{'abc': 1}]
+['{!abc}',                          'filter'], ['noa'],   [{'abc': 0}]
+['{!+2 abc bool bool}',             'filter'], ['a',2,3], [{'abc': [1, 1]}]
+['{!+2 abc bool bool}',             'filter'], ['noa'],   [{'abc': 0}]
 # vim: cms=#%s fmr=▶,▲