def parse(self, code, line_no): '''To parse the given code''' # remove all comments code = code + '\n' code = re.sub(r'#.*?\n', '\n', code) # if a blank code if code.strip() == '': return [] # create the parser p = ZestyParser(code) # update the starting line number of the code p.start_line_no = line_no # parse the tuning specifications try: args = p.scan(p_program) except ParseError as e: err('orio.module.spmv.parser: %s' % e) # return the arguments return args
def __parse(self, code, line_no, token): '''To parse the given code and return a sequence of statements''' # append multiple newlines to imitate the actual line number code = ('\n' * (line_no-1)) + code # append a newline on the given code code += '\n' # remove all comments code = re.sub(r'#.*?\n', '\n', code) # create the parser p = ZestyParser(code) # parse the tuning specifications try: stmt_seq = p.scan(token) except ParseError, e: print 'error: %s' % e sys.exit(1)
def parse(self, code, line_no): '''To parse the given code''' # remove all comments code = code + '\n' code = re.sub(r'#.*?\n', '\n', code) # if a blank code if code.strip() == '': return [] # create the parser p = ZestyParser(code) # update the starting line number of the code p.start_line_no = line_no # parse the tuning specifications try: args = p.scan(p_program) except ParseError, e: err('orio.module.spmv.parser: %s' % e)
def parse(self, code, line_no): '''To parse the given code''' # remove all comments code = code + '\n' code = re.sub(r'#.*?\n', '\n', code) # if a blank code if code.strip() == '': return [] # create the parser p = ZestyParser(code) # update the starting line number of the code p.start_line_no = line_no # parse the tuning specifications try: assigns = p.scan(p_program) except ParseError, e: print 'error: %s' % e sys.exit(1)