Commits

ZyX_I committed cc1cd05

@/fwc: Added `#^' (remove last message) and `##' (don't use custom messages) messages specifications

  • Participants
  • Parent commits 4054278

Comments (0)

Files changed (4)

plugin/frawor/fwc/compiler.vim

         let args=map(args[:(curidx-1)], 'string(v:val)')+[self.argstr(1)]+
                     \args[(curidx+1):]
     endif
-    if !empty(self.pmsgs)
+    if !empty(self.pmsgs) && !empty(self.pmsgs[-1])
         call self.add('call add(@$@pmessages, ['.self.pmsgs[-1].'])')
     endif
     return self.add('call add(@$@messages, ['.string(a:msg).', '.
 endfunction
 "▶1 compilemsg     :: msgcontext, _ + self → self + self
 function s:compiler.compilemsg(msg, idx)
+    if a:msg[1] is 0
+        call add(self.pmsgs, '')
+        return self
+    elseif a:msg[1] is 1
+        if !empty(self.pmsgs)
+            call remove(self.pmsgs, -1)
+        endif
+        return self
+    endif
     let msg=[]
     let curargstr=self.argstr()
     for msgarg in a:msg[2:]

plugin/frawor/fwc/parser.vim

     return self.conclose()
 endfunction
 "▶1 scanmsg    :: &self
-" Input: {wordchar}+ ( "(" ( "." | "%" | {var} | "," ) ")"? )?
-" Output: context(msg, String, {msgarg}*)
+" Input: ( "#" | "^" | {wordchar}+ ( "(" ( "." | "%" | {var} | "," ) ")"? )? )
+" Output: context(msg, (String, {msgarg}* | 0 | 1))
 "         {msgarg} :: context(curval)
 "                   | context(curarg)
 "                   | {var}
 function s:parser.scanmsg()
-    call self.addcon('msg', self.readc())
+    let c=self.readc()
+    call self.addcon('msg', ((c is '#')?(0):((c is '^')?(1):(c))))
     if self.len
         let c=self.readc()
         if c is '('
 Frawor:plugin/fwccheck:str:0<
 plugin/frawor/fwc/compiler:nbool
 Frawor:plugin/fwccheck:str:1<
+plugin/frawor/fwc/compiler:nbool
+plugin/frawor/fwc/compiler:nbool
+plugin/frawor/fwc/compiler:nbool
+Frawor:plugin/fwccheck:str:a:args[0]<
+plugin/frawor/fwc/compiler:nbool
 <<< messages

test/fwctests.dat

 ['#str(%) bool (type "" #str(.) isreg)', 'check'], [1, '\v('], 0
 ['#str(*$"type"(@)) bool',               'check'], [2],        0
 ['#str(*$"type"(@)) bool',               'check'], [""],       0
+['#str(%) ?_ #^ bool',                   'check'], [""],       0
+['#str(%) ?_ ## bool',                   'check'], [""],       0
+['#str(%) #str(.) #^ bool',              'check'], [""],       0
+['#str(%) #str(.) ## bool',              'check'], [""],       0
 # vim: cms=#%s fmr=▶,▲