Mercurial > vim
annotate runtime/plugin/logiPat.vim @ 8202:c16aa03d8db5 v7.4.1394
commit https://github.com/vim/vim/commit/0b962473ddc7cee3cb45253dea273573bcca9bf9
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 22 22:51:33 2016 +0100
patch 7.4.1394
Problem: Can't sort inside a sort function.
Solution: Use a struct to store the sort parameters. (Jacob Niehus)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 22 Feb 2016 23:00:05 +0100 |
parents | ee45d3b0579b |
children | b73f9ed65072 |
rev | line source |
---|---|
6855
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
1 " LogiPat: |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
2 " Author: Charles E. Campbell |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
3 " Date: Mar 13, 2013 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
4 " Version: 3 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
5 " Purpose: to do Boolean-logic based regular expression pattern matching |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
6 " Copyright: Copyright (C) 1999-2011 Charles E. Campbell {{{1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
7 " Permission is hereby granted to use and distribute this code, |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
8 " with or without modifications, provided that this copyright |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
9 " notice is copied with it. Like most anything else that's free, |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
10 " LogiPat.vim is provided *as is* and comes with no warranty |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
11 " of any kind, either expressed or implied. By using this |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
12 " plugin, you agree that in no event will the copyright |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
13 " holder be liable for any damages resulting from the use |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
14 " of this software. |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
15 " |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
16 " Usage: {{{1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
17 " :LogiPat ... |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
18 " |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
19 " Boolean logic supported: |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
20 " () grouping operators |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
21 " ! not the following pattern |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
22 " | logical or |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
23 " & logical and |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
24 " "..pattern.." |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
25 " Example: {{{1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
26 " :LogiPat !("january"|"february") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
27 " would match all strings not containing the strings january |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
28 " or february |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
29 " GetLatestVimScripts: 1290 1 :AutoInstall: LogiPat.vim |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
30 " |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
31 " Behold, you will conceive in your womb, and bring forth a son, {{{1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
32 " and will call his name Jesus. He will be great, and will be |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
33 " called the Son of the Most High. The Lord God will give him the |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
34 " throne of his father, David, and he will reign over the house of |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
35 " Jacob forever. There will be no end to his kingdom. (Luke 1:31-33 WEB) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
36 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
37 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
38 " Load Once: {{{1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
39 if &cp || exists("loaded_logipat") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
40 finish |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
41 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
42 let g:loaded_LogiPat = "v3" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
43 let s:keepcpo = &cpo |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
44 set cpo&vim |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
45 "DechoRemOn |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
46 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
47 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
48 " Public Interface: {{{1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
49 com! -nargs=* LogiPat call LogiPat(<q-args>,1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
50 silent! com -nargs=* LP call LogiPat(<q-args>,1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
51 com! -nargs=+ ELP echomsg LogiPat(<q-args>) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
52 com! -nargs=+ LogiPatFlags let s:LogiPatFlags="<args>" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
53 silent! com -nargs=+ LPF let s:LogiPatFlags="<args>" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
54 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
55 " ===================================================================== |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
56 " Functions: {{{1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
57 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
58 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
59 " LogiPat: this function interprets the boolean-logic pattern {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
60 fun! LogiPat(pat,...) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
61 " call Dfunc("LogiPat(pat<".a:pat.">)") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
62 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
63 " LogiPat(pat,dosearch) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
64 if a:0 > 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
65 let dosearch= a:1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
66 else |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
67 let dosearch= 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
68 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
69 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
70 let s:npatstack = 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
71 let s:nopstack = 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
72 let s:preclvl = 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
73 let expr = a:pat |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
74 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
75 " Lexer/Parser |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
76 while expr != "" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
77 " call Decho("expr<".expr.">") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
78 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
79 if expr =~ '^"' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
80 " push a Pattern; accept "" as a single " in the pattern |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
81 let expr = substitute(expr,'^\s*"','','') |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
82 let pat = substitute(expr,'^\(\%([^"]\|\"\"\)\{-}\)"\([^"].*$\|$\)','\1','') |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
83 let pat = substitute(pat,'""','"','g') |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
84 let expr = substitute(expr,'^\(\%([^"]\|\"\"\)\{-}\)"\([^"].*$\|$\)','\2','') |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
85 let expr = substitute(expr,'^\s*','','') |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
86 " call Decho("pat<".pat."> expr<".expr.">") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
87 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
88 call s:LP_PatPush('.*'.pat.'.*') |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
89 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
90 elseif expr =~ '^[!()|&]' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
91 " push an operator |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
92 let op = strpart(expr,0,1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
93 let expr = strpart(expr,strlen(op)) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
94 " allow for those who can't resist doubling their and/or operators |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
95 if op =~ '[|&]' && expr[0] == op |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
96 let expr = strpart(expr,strlen(op)) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
97 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
98 call s:LP_OpPush(op) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
99 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
100 elseif expr =~ '^\s' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
101 " skip whitespace |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
102 let expr= strpart(expr,1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
103 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
104 else |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
105 echoerr "operator<".strpart(expr,0,1)."> not supported (yet)" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
106 let expr= strpart(expr,1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
107 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
108 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
109 endwhile |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
110 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
111 " Final Execution |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
112 call s:LP_OpPush('Z') |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
113 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
114 let result= s:LP_PatPop(1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
115 " call Decho("result=".result) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
116 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
117 " sanity checks and cleanup |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
118 if s:npatstack > 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
119 echoerr s:npatstack." patterns left on stack!" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
120 let s:npatstack= 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
121 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
122 if s:nopstack > 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
123 echoerr s:nopstack." operators left on stack!" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
124 let s:nopstack= 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
125 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
126 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
127 " perform the indicated search |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
128 if dosearch |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
129 if exists("s:LogiPatFlags") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
130 " call Decho("search(result<".result."> LogiPatFlags<".s:LogiPatFlags.">)") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
131 call search(result,s:LogiPatFlags) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
132 else |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
133 " call Decho("search(result<".result.">)") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
134 call search(result) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
135 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
136 let @/= result |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
137 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
138 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
139 " call Dret("LogiPat ".result) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
140 return result |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
141 endfun |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
142 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
143 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
144 " s:String: Vim6.4 doesn't have string() {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
145 func! s:String(str) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
146 return "'".escape(a:str, '"')."'" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
147 endfunc |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
148 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
149 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
150 " LP_PatPush: {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
151 fun! s:LP_PatPush(pat) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
152 " call Dfunc("LP_PatPush(pat<".a:pat.">)") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
153 let s:npatstack = s:npatstack + 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
154 let s:patstack_{s:npatstack} = a:pat |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
155 " call s:StackLook("patpush") "Decho |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
156 " call Dret("LP_PatPush : npatstack=".s:npatstack) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
157 endfun |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
158 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
159 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
160 " LP_PatPop: pop a number/variable from LogiPat's pattern stack {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
161 fun! s:LP_PatPop(lookup) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
162 " call Dfunc("LP_PatPop(lookup=".a:lookup.")") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
163 if s:npatstack > 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
164 let ret = s:patstack_{s:npatstack} |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
165 let s:npatstack = s:npatstack - 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
166 else |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
167 let ret= "---error---" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
168 echoerr "(LogiPat) invalid expression" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
169 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
170 " call s:StackLook("patpop") "Decho |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
171 " call Dret("LP_PatPop ".ret) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
172 return ret |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
173 endfun |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
174 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
175 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
176 " LP_OpPush: {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
177 fun! s:LP_OpPush(op) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
178 " call Dfunc("LP_OpPush(op<".a:op.">)") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
179 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
180 " determine new operator's precedence level |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
181 if a:op == '(' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
182 let s:preclvl= s:preclvl + 10 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
183 let preclvl = s:preclvl |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
184 elseif a:op == ')' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
185 let s:preclvl= s:preclvl - 10 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
186 if s:preclvl < 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
187 let s:preclvl= 0 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
188 echoerr "too many )s" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
189 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
190 let preclvl= s:preclvl |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
191 elseif a:op =~ '|' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
192 let preclvl= s:preclvl + 2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
193 elseif a:op =~ '&' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
194 let preclvl= s:preclvl + 4 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
195 elseif a:op == '!' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
196 let preclvl= s:preclvl + 6 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
197 elseif a:op == 'Z' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
198 let preclvl= -1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
199 else |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
200 echoerr "expr<".expr."> not supported (yet)" |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
201 let preclvl= s:preclvl |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
202 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
203 " call Decho("new operator<".a:op."> preclvl=".preclvl) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
204 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
205 " execute higher-precdence operators |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
206 " call Decho("execute higher-precedence operators") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
207 call s:LP_Execute(preclvl) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
208 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
209 " push new operator onto operator-stack |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
210 " call Decho("push new operator<".a:op."> onto stack with preclvl=".preclvl." at nopstack=".(s:nopstack+1)) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
211 if a:op =~ '!' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
212 let s:nopstack = s:nopstack + 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
213 let s:opprec_{s:nopstack} = preclvl |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
214 let s:opstack_{s:nopstack} = a:op |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
215 elseif a:op =~ '|' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
216 let s:nopstack = s:nopstack + 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
217 let s:opprec_{s:nopstack} = preclvl |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
218 let s:opstack_{s:nopstack} = a:op |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
219 elseif a:op == '&' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
220 let s:nopstack = s:nopstack + 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
221 let s:opprec_{s:nopstack} = preclvl |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
222 let s:opstack_{s:nopstack} = a:op |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
223 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
224 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
225 " call s:StackLook("oppush") "Decho |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
226 " call Dret("LP_OpPush : s:preclvl=".s:preclvl) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
227 endfun |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
228 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
229 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
230 " LP_Execute: execute operators from opstack using pattern stack {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
231 fun! s:LP_Execute(preclvl) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
232 " call Dfunc("LP_Execute(preclvl=".a:preclvl.") npatstack=".s:npatstack." nopstack=".s:nopstack) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
233 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
234 " execute all higher precedence operators |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
235 while s:nopstack > 0 && a:preclvl < s:opprec_{s:nopstack} |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
236 let op= s:opstack_{s:nopstack} |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
237 " call Decho("op<".op."> nop=".s:nopstack." [preclvl=".a:preclvl."] < [opprec_".s:nopstack."=".s:opprec_{s:nopstack}."]") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
238 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
239 let s:nopstack = s:nopstack - 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
240 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
241 if op == '!' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
242 let n1= s:LP_PatPop(1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
243 call s:LP_PatPush(s:LP_Not(n1)) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
244 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
245 elseif op == '|' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
246 let n1= s:LP_PatPop(1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
247 let n2= s:LP_PatPop(1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
248 call s:LP_PatPush(s:LP_Or(n2,n1)) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
249 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
250 elseif op =~ '&' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
251 let n1= s:LP_PatPop(1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
252 let n2= s:LP_PatPop(1) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
253 call s:LP_PatPush(s:LP_And(n2,n1)) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
254 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
255 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
256 " call s:StackLook("execute") "Decho |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
257 endwhile |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
258 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
259 " call Dret("LP_Execute") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
260 endfun |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
261 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
262 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
263 " LP_Not: writes a logical-not for a pattern {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
264 fun! s:LP_Not(pat) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
265 " call Dfunc("LP_Not(pat<".a:pat.">)") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
266 if a:pat =~ '^\.\*' && a:pat =~ '\.\*$' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
267 let pat= substitute(a:pat,'^\.\*\(.*\)\.\*$','\1','') |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
268 let ret= '^\%(\%('.pat.'\)\@!.\)*$' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
269 else |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
270 let ret= '^\%(\%('.a:pat.'\)\@!.\)*$' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
271 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
272 " call Dret("LP_Not ".ret) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
273 return ret |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
274 endfun |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
275 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
276 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
277 " LP_Or: writes a logical-or branch using two patterns {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
278 fun! s:LP_Or(pat1,pat2) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
279 " call Dfunc("LP_Or(pat1<".a:pat1."> pat2<".a:pat2.">)") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
280 let ret= '\%('.a:pat1.'\|'.a:pat2.'\)' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
281 " call Dret("LP_Or ".ret) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
282 return ret |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
283 endfun |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
284 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
285 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
286 " LP_And: writes a logical-and concat using two patterns {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
287 fun! s:LP_And(pat1,pat2) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
288 " call Dfunc("LP_And(pat1<".a:pat1."> pat2<".a:pat2.">)") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
289 let ret= '\%('.a:pat1.'\&'.a:pat2.'\)' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
290 " call Dret("LP_And ".ret) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
291 return ret |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
292 endfun |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
293 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
294 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
295 " StackLook: {{{2 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
296 fun! s:StackLook(description) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
297 " call Dfunc("StackLook(description<".a:description.">)") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
298 let iop = 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
299 let ifp = 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
300 " call Decho("Pattern Operator") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
301 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
302 " print both pattern and operator |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
303 while ifp <= s:npatstack && iop <= s:nopstack |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
304 let fp = s:patstack_{ifp} |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
305 let op = s:opstack_{iop}." (P".s:opprec_{s:nopstack}.')' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
306 let fplen= strlen(fp) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
307 if fplen < 30 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
308 let fp= fp.strpart(" ",1,30-fplen) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
309 endif |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
310 " call Decho(fp.op) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
311 let ifp = ifp + 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
312 let iop = iop + 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
313 endwhile |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
314 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
315 " print just pattern |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
316 while ifp <= s:npatstack |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
317 let fp = s:patstack_{ifp} |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
318 " call Decho(fp) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
319 let ifp = ifp + 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
320 endwhile |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
321 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
322 " print just operator |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
323 while iop <= s:nopstack |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
324 let op = s:opstack_{iop}." (P".s:opprec_{s:nopstack}.')' |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
325 " call Decho(" ".op) |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
326 let iop = iop + 1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
327 endwhile |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
328 " call Dret("StackLook") |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
329 endfun |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
330 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
331 " --------------------------------------------------------------------- |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
332 " Cleanup And Modeline: {{{1 |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
333 let &cpo= s:keepcpo |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
334 unlet s:keepcpo |
ee45d3b0579b
Add the logiPat plugin to the distribution.
Bram Moolenaar <bram@vim.org>
parents:
diff
changeset
|
335 " vim: ts=4 fdm=marker |