diff options
author | Alexei Sholik <alcosholik@gmail.com> | 2014-06-05 04:07:19 +0300 |
---|---|---|
committer | Alexei Sholik <alcosholik@gmail.com> | 2014-06-05 04:07:19 +0300 |
commit | db1e5ef0852069e7a471e990e6024fdf1b9b8a61 (patch) | |
tree | a406476c1d6dd2e64df74b86eae10e376ebd5993 /scripts/get_vimkw.py | |
download | pygments-git-db1e5ef0852069e7a471e990e6024fdf1b9b8a61.tar.gz |
Update ElixirLexer and example_elixir.ex
Elixir syntax has evolved quite significantly since the initial lexer
was written. In this update I have rewritten most of the code to support
modern Elixir (as of v0.14.0-dev).
The example file has also been updated to give an quick overview
of most of the language constructs.
Diffstat (limited to 'scripts/get_vimkw.py')
-rw-r--r-- | scripts/get_vimkw.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/get_vimkw.py b/scripts/get_vimkw.py new file mode 100644 index 00000000..4ea302f4 --- /dev/null +++ b/scripts/get_vimkw.py @@ -0,0 +1,43 @@ +from __future__ import print_function +import re + +r_line = re.compile(r"^(syn keyword vimCommand contained|syn keyword vimOption " + r"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('(%r,%r)' % + (i.group(1), "%s%s" % (i.group(1), i.group(2) or ''))) + + output_info['option'].append("('nnoremap','nnoremap')") + output_info['option'].append("('inoremap','inoremap')") + output_info['option'].append("('vnoremap','vnoremap')") + + for a, b in output_info.items(): + b.sort() + print('%s=[%s]' % (a, ','.join(b)), file=out) + +def is_keyword(w, keywords): + for i in range(len(w), 0, -1): + if w[:i] in keywords: + return keywords[w[:i]][:len(w)] == w + return False + +if __name__ == "__main__": + getkw("/usr/share/vim/vim73/syntax/vim.vim", "temp.py") |