def default_completes(self, word): comps = dict(vars=[], func=[], types=[], keys=[]) for func in keywords.get_functions(): if func.lower().startswith(word.lower()): comps['func'].append(func) for key in keywords.words['keywords']: if key.lower().startswith(word.lower()): comps['keys'].append(key) for type in keywords.words['types']: if type.lower().startswith(word.lower()): comps['types'].append(type) for type in keywords.words['variables']: if type.lower().startswith(word.lower()): comps['vars'].append(type) return comps
def parse_block_content(self): """ Parse block content """ # functions pat = r'([\w\[\]]+)\s+([\w_]+)(\(.*?\))[\n\s]*?\{block(\d+)[|\d]+\}' # c = re.compile(pat, re.DOTALL) # c = re.compile(pat) to_variables = self.code for p in re.finditer(pat, self.code): self.var['func'].append(p.groups()[1]) id = int(p.groups()[3]) for b in self.blocks: if b.id == id: b.parse_function_variables(p.groups()[2]) to_variables = to_variables.replace(p.group(0), '') self.var['func'] = list( set([ x for x in self.var['func'] if not x in keywords.get_functions() + keywords.words['keywords'] ])) # define pat = r'#define\s+([\w_\d]+?)(\s+|;|\()' for v in re.findall(pat, to_variables): self.var['vars'].append(v[0]) # variables # int k = 0; pat = r'(\w+)\s+(\w+)(\[.*?\])?\s?(;|\))' for v in re.findall(pat, to_variables): if not v[1].isdigit(): self.var['vars'].append(v[1]) # x = x + 3; pat = r'(\w+)?\s+(\w+)(\[.*?\])?\s*?(\+|\-|\/|\*)?=' for v in re.findall(pat, to_variables): if not v[1].isdigit(): self.var['vars'].append(v[1]) # include # #include <math.h> pat = r'#include\s+<(.*?)>' for v in re.findall(pat, to_variables): self.parse_include(v) self.var['vars'] = list(set(self.var['vars']))
def default_completes(self, word): comps = dict( vars=[], func=[], types=[], keys=[] ) for func in keywords.get_functions(): if func.lower().startswith(word.lower()): comps['func'].append(func) for key in keywords.words['keywords']: if key.lower().startswith(word.lower()): comps['keys'].append(key) for type in keywords.words['types']: if type.lower().startswith(word.lower()): comps['types'].append(type) for type in keywords.words['variables']: if type.lower().startswith(word.lower()): comps['vars'].append(type) return comps
def parse_block_content(self): """ Parse block content """ # functions pat = r'([\w\[\]]+)\s+([\w_]+)(\(.*?\))[\n\s]*?\{block(\d+)[|\d]+\}' # c = re.compile(pat, re.DOTALL) # c = re.compile(pat) to_variables = self.code for p in re.finditer(pat, self.code): self.var['func'].append(p.groups()[1]) id = int(p.groups()[3]) for b in self.blocks: if b.id == id: b.parse_function_variables(p.groups()[2]) to_variables = to_variables.replace(p.group(0),'') self.var['func'] = list(set([x for x in self.var['func'] if not x in keywords.get_functions()+keywords.words['keywords'] ])) # define pat = r'#define\s+([\w_\d]+?)(\s+|;|\()' for v in re.findall(pat, to_variables): self.var['vars'].append(v[0]) # variables # int k = 0; pat = r'(\w+)\s+(\w+)(\[.*?\])?\s?(;|\))' for v in re.findall(pat, to_variables): if not v[1].isdigit(): self.var['vars'].append(v[1]) # x = x + 3; pat = r'(\w+)?\s+(\w+)(\[.*?\])?\s*?(\+|\-|\/|\*)?=' for v in re.findall(pat, to_variables): if not v[1].isdigit(): self.var['vars'].append(v[1]) # include # #include <math.h> pat = r'#include\s+<(.*?)>' for v in re.findall(pat, to_variables): self.parse_include(v) self.var['vars'] = list(set(self.var['vars']))