summaryrefslogtreecommitdiff
path: root/scripts/get_vimkw.py
diff options
context:
space:
mode:
authorblackbird <devnull@localhost>2007-05-28 23:31:04 +0200
committerblackbird <devnull@localhost>2007-05-28 23:31:04 +0200
commitad601c3df3c3e6f3516bc2088bfb5e2ed0e1950e (patch)
tree3651e7330a4a847fe66f67eb46c2b7642b9afa96 /scripts/get_vimkw.py
parent100c4d2b426777dd1198378c45693dacc2c6413a (diff)
downloadpygments-ad601c3df3c3e6f3516bc2088bfb5e2ed0e1950e.tar.gz
[svn] added tim hatch's lexer (forgot about the CHANGELOG entry...) and updated docs to jinja 1
Diffstat (limited to 'scripts/get_vimkw.py')
-rw-r--r--scripts/get_vimkw.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/get_vimkw.py b/scripts/get_vimkw.py
new file mode 100644
index 00000000..a8e38c26
--- /dev/null
+++ b/scripts/get_vimkw.py
@@ -0,0 +1,37 @@
+import re
+from pprint import pprint
+
+r_line = re.compile(r"^(syn keyword vimCommand contained|syn keyword vimOption contained|syn keyword vimAutoEvent contained)\s+(.*)")
+r_item = re.compile(r"(\w+)(?:\[(\w+)\])?")
+
+def getkw(input, output):
+ out = file(output, 'w')
+
+ output_info = {'command': [], 'option': [], 'auto': []}
+ for line in file(input):
+ m = r_line.match(line)
+ if m:
+ # Decide which output gets mapped to d
+ if 'vimCommand' in m.group(1):
+ d = output_info['command']
+ elif 'AutoEvent' in m.group(1):
+ d = output_info['auto']
+ else:
+ d = output_info['option']
+
+ # Extract all the shortened versions
+ for i in r_item.finditer(m.group(2)):
+ d.append((i.group(1), "%s%s" % (i.group(1), i.group(2) or '')))
+ d.sort()
+
+ for a, b in output_info.items():
+ print >>out, '%s=%r' % (a, b)
+
+def is_keyword(w, keywords):
+ for i in range(len(w), 0, -1):
+ if w[:i] in keywords:
+ return signals[w[:i]][:len(w)] == w
+ return False
+
+if __name__ == "__main__":
+ getkw("/usr/share/vim/vim70/syntax/vim.vim", "temp.py")