Commits

ZyX_I committed 283b0c2

@/fwc: Fixed `any' dict key description

Comments (0)

Files changed (3)

plugin/frawor/fwc/compiler.vim

                     \         'keynmatch',a:idx,'@#@', 'keys('.curargstr.')[0]')
                     \.close()
     endif
-    let hascheck=len(filter(copy(a:dic[1]), 'v:val[0] is "check"'))
     let keystr=self.getlvarid('key')
     call self.add('for '.keystr.' in keys('.self.argstr().')').deeper()
     call add(self.subs, [keystr])
-    if hascheck
-        let foundstr=self.getlvarid('found')
-        let msglenstr=self.getlvarid('msglen')
-        let pmsglenstr=self.getlvarid('pmsglen')
-        call self.add('let '.foundstr.'=0',
-                    \ 'let '.msglenstr. '=len(@$@messages)',
-                    \ 'let '.pmsglenstr.'=len(@$@pmessages)')
-    endif
+    let foundstr=self.getlvarid('found')
+    let msglenstr=self.getlvarid('msglen')
+    let pmsglenstr=self.getlvarid('pmsglen')
     let addedcond=0
-    let addedcheck=0
+    let hascheck=0
     let i=-1
     for check in a:dic[1][1:]
         let i+=1
             let addedcond=1
             call self.nextcond(self.getexpr(check[1], keystr))
         elseif check[0] is 'any'
-            let addedcond=0
-            call self.nextcond()
+            if addedcond
+                call self.close()
+                let addedcond=0
+            endif
+            call self.compilearg(check[1], a:idx.'.'.i.'(val)', a:default)
+                        \.add('continue')
+            break
         elseif check[0] is 'check'
+            if addedcond
+                call self.close()
+            endif
+            if !hascheck
+                call self.add('let '.msglenstr. '=len(@$@messages)',
+                            \ 'let '.pmsglenstr.'=len(@$@pmessages)')
+            endif
+            let hascheck=1
             let savedargbase=self.argbase
             let self.argbase=keystr
             let savedsubs=remove(self.subs, 0, -1)
-            if i>0
-                if addedcheck
-                    call self.nextcond('!'.foundstr)
-                else
-                    call self.nextcond()
-                endif
-            elseif addedcond
-                call self.close()
-            endif
             call self.add('try').deeper()
+                            \.add('let '.foundstr.'=0')
                             \.compilearg(check[1], a:idx.'.'.i.'(key)', 'check')
             let self.argbase=savedargbase
             let self.subs+=savedsubs
                                     \                  pmsglenstr.', -1)')
                             \.up().close()
                         \.up().close()
-            if i>0
-                call self.up().close()
-            endif
+                        \.nextcond(foundstr).add('continue').up().close()
             let addedcond=0
-            let addedcheck=1
             continue
         endif
-        if hascheck
-            call self.add('let '.foundstr.'=1')
-        endif
-        call self.compilearg(check[2], a:idx.'.'.i.'(val)', a:default).up()
+        call self.compilearg(check[2], a:idx.'.'.i.'(val)', a:default)
+                    \.add('continue').up()
     endfor
-    if hascheck
-        call self.nextcond('!'.foundstr)
-    else
-        call self.nextcond()
+    if addedcond
+        call self.close()
     endif
-    call self.addthrow('keynmatch', a:idx, '@#@', keystr).close().up().close()
+    call self.addthrow('keynmatch', a:idx, '@#@', keystr).close()
     call remove(self.subs, -1)
     return self
 endfunction
 plugin/frawor/fwc/compiler:keynmatch
 plugin/frawor/fwc/compiler:nbool
 plugin/frawor/fwc/compiler:keynmatch
+plugin/frawor/fwc/compiler:nreg
 ::: Section <Checks/Built-in checks/path>
 plugin/frawor/fwc/compiler:nwrite
 plugin/frawor/fwc/compiler:nowrite

test/fwctests.dat

 ['dict {*$"exists" bool}', 'filter'], [{'g:+': []}],        0
 ['dict {=exists(@.@)bool}','filter'], [{'g:': []}],         [{'g:': 0}]
 ['dict {=exists(@.@)bool}','filter'], [{'g:+': []}],        0
+['dict {- bool}',          'filter'], [{'abc': []}],        [{'abc': 0}]
+['dict {abc bool - _}',    'filter'], [{'abc':[], 'ab':2}], [{'abc':0, 'ab':2}]
+['dict {?isreg bool - _}', 'filter'], [{'a': [], '\v(': 2}],[{'a': 0, '\v(': 2}]
 #▶3 tuple
 ['tuple bool, bool',       'filter'], [['', 'cba']],        [[0, 1]]
 ['tuple bool, bool',       'filter'], [['abc']],            0
 ['dict {?|earg bool bool}',   'check'], [{'0': 1}],        1
 ['dict {?|earg bool bool}',   'check'], [{'0': 2}],        0
 ['dict {?|earg bool bool}',   'check'], [{'2': 1}],        0
+['dict {- isreg}',            'check'], [{'a': 'abc'}],    1
+['dict {- isreg}',            'check'], [{'a': '\v('}],    0
 #▶3 path
 :call os.mkdir('FWCdirectory')
 :call os.chdir('FWCdirectory')