ZyX_I avatar ZyX_I committed f98913f

@/fwc: Added `is' check

Comments (0)

Files changed (5)

plugin/frawor/autocommands.vim

 "▶2 augroup.add  :: {f}, agid, [event] → + :autocmd, s:augroups
 function s:F.augroup.add(plugdict, fdict, agid, events)
     "▶3 Check arguments
-    if type(a:agid)!=type("")
+    if type(a:agid)!=type('')
         call s:_f.throw('agidnstr', a:plugdict.id)
     elseif a:agid!~#'^\w\+$'
         call s:_f.throw('invagid', a:plugdict.id, a:agid)

plugin/frawor/fwc/compiler.vim

             \ 'keynmatch': 'key `%s'' does not match any specification',
             \    'nmatch': 'no matches found for %s',
             \   'notfail': '`not'' check failed',
+            \     'isnot': 'expected %s, but got %s',
         \}, '"Error while processing check %s for %s: ".v:val'))
 let s:_messages._types=['number', 'string', 'function reference', 'list',
             \           'dictionary']
                 let addedcond=1
                 call self.nextthrow('index([0, 1], '.curargstr.')==-1',
                             \       'nbool', idx,'@#@', 'string('.curargstr.')')
+            "▶3 `is'
+            elseif desc[0] is 'is'
+                let addedcond=1
+                let var=self.getvar(desc[1])
+                call self.nextthrow(curargstr.' isnot '.var,
+                            \       'isnot', idx, '@#@', var,
+                            \                'string('.curargstr.')')
             "▶3 `_', `any'
             elseif desc[0] is '_' || desc[0] is 'any'
                 " Just do nothing here

plugin/frawor/fwc/parser.vim

 "▶3 check.bool
 " Checks whether {argument} is either 0 or 1
 let s:args.check.bool=[]
+"▶3 check.is
+" Checks whether {argument} is {var}
+let s:args.check.is=['var']
 "▶3 check._, check.any
 " Unconditionally accepts {argument}
 let s:args.check._=[]
 plugin/frawor/fwc/compiler:nindict
 plugin/frawor/fwc/compiler:typefail
 plugin/frawor/fwc/compiler:notfail
+plugin/frawor/fwc/compiler:isnot
 ::: Section <Checks/Built-in checks/in>
 plugin/frawor/fwc/compiler:ninlist
 plugin/frawor/fwc/compiler:ninlist

test/fwctests.dat

 ['key={"abc": 1}',  'check'], [0],                  0
 ['not bool',        'check'], [0],                  0
 ['not bool',        'check'], [2],                  1
+['is =2',           'check'], [2],                  1
+['is =2',           'check'], [[]],                 0
 ['_',               'check'], [[[[]]]],             1
 ['any',             'check'], [[[[]]]],             1
 #▶3 in
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.