[jsinterp] Fix typo and cleanup regexes (closes #13134)

pull/11526/merge
Sergey M․ 8 years ago
parent 9221d5d7a8
commit 0e2d626ddd
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

@ -214,15 +214,18 @@ class JSInterpreter(object):
_FUNC_NAME_RE = r'''(?:[a-zA-Z$0-9]+|"[a-zA-Z$0-9]+"|'[a-zA-Z$0-9]+')''' _FUNC_NAME_RE = r'''(?:[a-zA-Z$0-9]+|"[a-zA-Z$0-9]+"|'[a-zA-Z$0-9]+')'''
obj = {} obj = {}
obj_m = re.search( obj_m = re.search(
(r'(?<!this\.)%s\s*=\s*\{' % re.escape(objname)) + r'''(?x)
r'\s*(?P<fields>(%s\s*:\s*function\(.*?\)\s*\{.*?\}(?:,\s*)?)*)' + (?<!this\.)%s\s*=\s*{\s*
r'\}\s*;' % _FUNC_NAME_RE, (?P<fields>(%s\s*:\s*function\s*\(.*?\)\s*{.*?}(?:,\s*)?)*)
}\s*;
''' % (re.escape(objname), _FUNC_NAME_RE),
self.code) self.code)
fields = obj_m.group('fields') fields = obj_m.group('fields')
# Currently, it only supports function definitions # Currently, it only supports function definitions
fields_m = re.finditer( fields_m = re.finditer(
r'(?P<key>%s)\s*:\s*function' r'''(?x)
r'\((?P<args>[a-z,]+)\){(?P<code>[^}]+)}' % _FUNC_NAME_RE, (?P<key>%s)\s*:\s*function\s*\((?P<args>[a-z,]+)\){(?P<code>[^}]+)}
''' % _FUNC_NAME_RE,
fields) fields)
for f in fields_m: for f in fields_m:
argnames = f.group('args').split(',') argnames = f.group('args').split(',')

Loading…
Cancel
Save