def parse_str(self, gen_str):
"""Attempts to extract the information from a generic interface."""
# Right now I'm going to punt. There are so many variations
# on these that it's difficult to write a RE for it. Also
# there are few ways to have to rewrite it. We will extract
# a name, and then a type string (which may include defaults)
gen_pattern = r'\s?(?P<name>.*?)\s?(?::)\s?(?P<type>.*)'
gp = re.compile(gen_pattern, re.IGNORECASE)
s = re.search(gp, gen_str)
if s:
self.name = s.group('name')
# Sometimes the type has a trailing space. Eliminating it.
self.type = re.sub(r'\s*$', '', s.group('type'))
self.success = True
else:
print('vhdl-mode: Could not parse generic string.')
self.success = False
评论列表
文章目录