def process_item(self): item = self.item apply_map = item.apply_map clsname = self.__class__.__name__.lower() line = item.get_line() from block_statements import Function if not line.lower().startswith(clsname): i = 0 j = 0 for c in line: i += 1 if c==' ': continue j += 1 if j==len(clsname): break line = line[:i].replace(' ','') + line[i:] assert line.lower().startswith(clsname),`line,clsname` line = line[len(clsname):].lstrip() if line.startswith('('): i = line.find(')') selector = apply_map(line[:i+1].strip()) line = line[i+1:].lstrip() elif line.startswith('*'): selector = '*' line = line[1:].lstrip() if line.startswith('('): i = line.find(')') selector += apply_map(line[:i+1].rstrip()) line = line[i+1:].lstrip() else: m = re.match(r'\d+(_\w+|)|[*]',line) if not m: self.isvalid = False return i = m.end() selector += line[:i].rstrip() line = line[i:].lstrip() else: selector = '' fm = Function.match(line) if fm: l2 = line[:fm.end()] m2 = re.match(r'.*?\b(?P<name>\w+)\Z',l2) if not m2: self.isvalid = False return fname = m2.group('name') fitem = item.copy(clsname+selector+' :: '+fname, apply_map=True) self.parent.put_item(fitem) item.clone(line) self.isvalid = False return if line.startswith(','): line = line[1:].lstrip() self.raw_selector = selector if isinstance(self, Character): self.selector = self._parse_char_selector(selector) else: self.selector = self._parse_kind_selector(selector) i = line.find('::') if i==-1: self.attrspec = [] self.entity_decls = split_comma(line, self.item) else: self.attrspec = split_comma(line[:i].rstrip(), self.item) self.entity_decls = split_comma(line[i+2:].lstrip(), self.item) for entity in self.entity_decls: if not is_entity_decl(entity): self.isvalid = False return if isinstance(self.parent, Function) \ and self.parent.name in self.entity_decls: assert self.parent.typedecl is None,`self.parent.typedecl` self.parent.typedecl = self self.ignore = True if isinstance(self, Type): self.name = self.selector[1].lower() assert is_name(self.name),`self.name` else: self.name = clsname return
def process_item(self): item = self.item apply_map = item.apply_map clsname = self.__class__.__name__.lower() line = item.get_line() from block_statements import Function #if line.find('[')>0: import pdb; pdb.set_trace() if not line.lower().startswith(clsname): i = 0 j = 0 for c in line: i += 1 if c == ' ': continue j += 1 if j == len(clsname): break line = line[:i].replace(' ', '') + line[i:] assert line.lower().startswith(clsname), ` line, clsname ` line = line[len(clsname):].lstrip() if line.startswith('('): i = line.find(')') selector = apply_map(line[:i + 1].strip()) line = line[i + 1:].lstrip() elif line.startswith('*'): selector = '*' line = line[1:].lstrip() if line.startswith('('): i = line.find(')') selector += apply_map(line[:i + 1].rstrip()) line = line[i + 1:].lstrip() else: m = re.match(r'\d+(_\w+|)|[*]', line) if not m: self.isvalid = False return i = m.end() selector += line[:i].rstrip() line = line[i:].lstrip() else: selector = '' fm = Function.match(line) if fm: l2 = line[:fm.end()] m2 = re.match(r'.*?\b(?P<name>\w+)\Z', l2) if not m2: self.isvalid = False return fname = m2.group('name') fitem = item.copy(clsname + selector + ' :: ' + fname, apply_map=True) self.parent.put_item(fitem) item.clone(line) self.isvalid = False return if line.startswith(','): line = line[1:].lstrip() self.raw_selector = selector if isinstance(self, Character): self.selector = self._parse_char_selector(selector) else: self.selector = self._parse_kind_selector(selector) i = line.find('::') if i == -1: self.attrspec = [] self.entity_decls = split_comma(line, self.item) else: self.attrspec = split_comma(line[:i].rstrip(), self.item) self.entity_decls = split_comma(line[i + 2:].lstrip(), self.item) for entity in self.entity_decls: if not is_entity_decl(entity): self.isvalid = False return if isinstance(self.parent, Function) \ and self.parent.name in self.entity_decls: assert self.parent.typedecl is None, ` self.parent.typedecl ` self.parent.typedecl = self self.parent.result_in_typedecl = True # OC addition #self.ignore = True # OC deletion if isinstance(self, Type): self.name = self.selector[1].lower() assert is_name(self.name), ` self.name ` else: self.name = clsname return
def process_item(self): item = self.item apply_map = item.apply_map clsname = self.__class__.__name__.lower() # line = item.get_line() # KGEN deletion itemline = item.get_line() # KGEN addition line = itemline[:] # KGEN addition from block_statements import Function # if line.find('[')>0: import pdb; pdb.set_trace() if not line.lower().startswith(clsname): i = 0 j = 0 for c in line: i += 1 if c == " ": continue j += 1 if j == len(clsname): break line = line[:i].replace(" ", "") + line[i:] assert line.lower().startswith(clsname), ` line, clsname ` line = line[len(clsname) :].lstrip() if line.startswith("("): i = line.find(")") selector = apply_map(line[: i + 1].strip()) line = line[i + 1 :].lstrip() elif line.startswith("*"): selector = "*" line = line[1:].lstrip() if line.startswith("("): i = line.find(")") selector += apply_map(line[: i + 1].rstrip()) line = line[i + 1 :].lstrip() else: m = re.match(r"\d+(_\w+|)|[*]", line) if not m: self.isvalid = False return i = m.end() selector += line[:i].rstrip() line = line[i:].lstrip() else: selector = "" fm = Function.match(line) if fm: l2 = line[: fm.end()] m2 = re.match(r".*?\b(?P<name>\w+)\Z", l2) if not m2: self.isvalid = False return fname = m2.group("name") # start of KGEN deletion # prevending adding typedecl stmt for Function result # fitem = item.copy(clsname+selector+' :: '+fname, # apply_map=True) # self.parent.put_item(fitem) # end of KGEN deletion # start of KGEN addition pos = itemline.find(line) if pos > 0: if not hasattr(self.parent, "funcresult_in_stmt"): self.parent.funcresult_in_stmt = {} self.parent.funcresult_in_stmt[fname] = self.item.apply_map(itemline[:pos].rstrip()) self.parent.result_in_typedecl = False # end of KGEN addition item.clone(line) self.isvalid = False return if line.startswith(","): line = line[1:].lstrip() self.raw_selector = selector if isinstance(self, Character): self.selector = self._parse_char_selector(selector) else: self.selector = self._parse_kind_selector(selector) i = line.find("::") if i == -1: self.attrspec = [] self.entity_decls = split_comma(line, self.item) else: self.attrspec = split_comma(line[:i].rstrip(), self.item) self.entity_decls = split_comma(line[i + 2 :].lstrip(), self.item) for entity in self.entity_decls: if not is_entity_decl(entity): self.isvalid = False return if isinstance(self.parent, Function) and self.parent.name in self.entity_decls: assert self.parent.typedecl is None, ` self.parent.typedecl ` self.parent.typedecl = self self.parent.result_in_typedecl = True # KGEN addition # self.ignore = True # KGEN deletion if isinstance(self, Type): self.name = self.selector[1].lower() assert is_name(self.name), ` self.name ` else: self.name = clsname return