1
# -*- coding: utf-8 -*-
3
pygments.lexers._luabuiltins
4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6
This file contains the names and modules of lua functions
7
It is able to re-generate itself, but for adding new functions you
8
probably have to add some callbacks (see function module_callbacks).
10
Do not edit the MODULES dict by hand.
12
:copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
13
:license: BSD, see LICENSE for details.
16
MODULES = {'basic': ['_G',
43
'coroutine': ['coroutine.create',
49
'debug': ['debug.debug',
104
'modules': ['module',
123
'string': ['string.byte',
137
'table': ['table.concat',
143
if __name__ == '__main__':
148
# you can't generally find out what module a function belongs to if you
149
# have only its name. Because of this, here are some callback functions
150
# that recognize if a gioven function belongs to a specific module
151
def module_callbacks():
152
def is_in_coroutine_module(name):
153
return name.startswith('coroutine.')
155
def is_in_modules_module(name):
156
if name in ['require', 'module'] or name.startswith('package'):
161
def is_in_string_module(name):
162
return name.startswith('string.')
164
def is_in_table_module(name):
165
return name.startswith('table.')
167
def is_in_math_module(name):
168
return name.startswith('math')
170
def is_in_io_module(name):
171
return name.startswith('io.')
173
def is_in_os_module(name):
174
return name.startswith('os.')
176
def is_in_debug_module(name):
177
return name.startswith('debug.')
179
return {'coroutine': is_in_coroutine_module,
180
'modules': is_in_modules_module,
181
'string': is_in_string_module,
182
'table': is_in_table_module,
183
'math': is_in_math_module,
184
'io': is_in_io_module,
185
'os': is_in_os_module,
186
'debug': is_in_debug_module}
190
def get_newest_version():
191
f = urllib.urlopen('http://www.lua.org/manual/')
192
r = re.compile(r'^<A HREF="(\d\.\d)/">Lua \1</A>')
198
def get_lua_functions(version):
199
f = urllib.urlopen('http://www.lua.org/manual/%s/' % version)
200
r = re.compile(r'^<A HREF="manual.html#pdf-(.+)">\1</A>')
205
functions.append(m.groups()[0])
208
def get_function_module(name):
209
for mod, cb in module_callbacks().iteritems():
213
return name.split('.')[0]
217
def regenerate(filename, modules):
224
header = content[:content.find('MODULES = {')]
225
footer = content[content.find("if __name__ == '__main__':"):]
228
f = open(filename, 'w')
230
f.write('MODULES = %s\n\n' % pprint.pformat(modules))
235
version = get_newest_version()
236
print '> Downloading function index for Lua %s' % version
237
functions = get_lua_functions(version)
238
print '> %d functions found:' % len(functions)
241
for full_function_name in functions:
242
print '>> %s' % full_function_name
243
m = get_function_module(full_function_name)
244
modules.setdefault(m, []).append(full_function_name)
246
regenerate(__file__, modules)