예제 #1
0
    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
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)