Commits

ZyX_I committed d229b79

@/checks

Comments (0)

Files changed (1)

plugin/frawor/checks.vim

 endfunction
 "▶2 scan.scanopt    :: &self
 " Input: {arg}* "]"?
-" Output: context(optional, {arg}*)
+" Output: context(optional, ({arg}|context(default, {var}, {arg}))*)
 function s:F.scan.scanopt()
     call self.addcon('optional')
     while !self.eos
         let c=self.readc()
         if c is ']'
             break
+        elseif c is '='
+            call self.addcon("default").getvar().scan().conclose()
+        else
+            call self.ungetc(c).scan()
         endif
-        call self.ungetc(c).scan()
     endwhile
     return self.conclose()
 endfunction
             call s.scan()
         endwhile
     endif
-    "▶3 Squash {arg}s
-    if len(s.l)>2 && s.l[2][0] is s.type
-        let s.l[2]=["args", s.l[2]]
-        let i=3
-        while i<len(s.l)
-            if s.l[i][0] is s.type
-                call add(s.l[2], remove(s.l, i))
-            else
-                let i+=1
-            endif
-        endwhile
-    endif
+    "▶3 Transform s.l[2:] to dictionary
+    let args=remove(s.l, 2, -1)
+    call add(s.l, {})
+    for arg in args
+        if !has_key(s.l[-1], arg[0])
+            let s.l[-1][arg[0]]=[]
+        endif
+        if arg[0] is 'actions' || arg[0] is 'prefixes'
+            call extend(s.l[-1][arg[0]], arg[1:])
+        else
+            call add(s.l[-1][arg[0]], arg[1:])
+        endif
+    endfor
     "▲3
     return s.tree
 endfunction