Example #1
0
 def process_item(self):
     line = self.item.get_line()[4:].lstrip()
     if line.startswith('('):
         self.isvalid = False
         return
     specs = []
     i = line.find('::')
     if i != -1:
         for s in line[:i].split(','):
             s = s.strip()
             if s: specs.append(s)
         line = line[i + 2:].lstrip()
     self.specs = specs
     i = line.find('(')
     if i != -1:
         self.name = line[:i].rstrip()
         assert line[-1] == ')', ` line `
         self.params = split_comma(line[i + 1:-1].lstrip())
     else:
         self.name = line
         self.params = []
     if not is_name(self.name):
         self.isvalid = False
         return
     return BeginStatement.process_item(self)
Example #2
0
	def post(self):
		workout_title = self.request.get("workout")
		new_workout = Workout(parent = PARENT_KEY, title = workout_title)
		new_workout.put()
		arguments = self.request.arguments()
		exercises = [ {} for i in range( utils.findLength(arguments) ) ]
		print exercises
		for argu in arguments:
			if str(argu) != 'workout':
				num = utils.findPosition(argu)
				if utils.is_time(argu):
					exercises[num]['time'] = int(self.request.get(argu))
				if utils.is_rest(argu):
					exercises[num]['rest'] = int(self.request.get(argu))
				if utils.is_name(argu): 
					exercises[num]['name'] = str(self.request.get(argu))
		print exercises
		for counter, exercise in enumerate(exercises): ## Needs to be ordered
			print counter
			print exercise
			new_exercise = Exercise(parent = PARENT_KEY, 
									name = exercise['name'],
									time = exercise['time'],
									rest = exercise['rest'],
									workout_title =  workout_title,
									order =  counter)
			new_exercise.put()

		self.redirect('/home') 
Example #3
0
 def process_item(self):
     line = self.item.get_line()[4:].lstrip()
     if line.startswith('('):
         self.isvalid = False
         return
     specs = []
     i = line.find('::')
     if i!=-1:
         for s in line[:i].split(','):
             s = s.strip()
             if s: specs.append(s)
         line = line[i+2:].lstrip()
     self.specs = specs
     i = line.find('(')
     if i!=-1:
         self.name = line[:i].rstrip()
         assert line[-1]==')',`line`
         self.params = split_comma(line[i+1:-1].lstrip())
     else:
         self.name = line
         self.params = []
     if not is_name(self.name):
         self.isvalid = False
         return
     return BeginStatement.process_item(self)
Example #4
0
    def analyze(self):
        content = self.content[:]

        if self.prefix:
            self.update_attributes(self.prefix.upper().split())

        variables = self.a.variables
        for a in self.args:
            assert a not in variables
            if is_name(a):
                variables[a] = Variable(self, a)
            elif a == '*':
                variables[a] = Variable(self, a)  # XXX: fix me appropriately
            else:
                raise AnalyzeError('argument must be a name or * but got %r' %
                                   (a))

        if isinstance(self, Function):
            var = variables[self.result] = Variable(self, self.result)
            if self.typedecl is not None:
                var.set_type(self.typedecl)

        while content:
            stmt = content.pop(0)
            if isinstance(stmt, Contains):
                for stmt in filter_stmts(content, SubProgramStatement):
                    stmt.analyze()
                    self.a.internal_subprogram[stmt.name] = stmt
                stmt = content.pop(0)
                while isinstance(stmt, Comment):
                    stmt = content.pop(0)
                assert isinstance(stmt, self.end_stmt_cls), ` stmt `
            elif isinstance(stmt, self.end_stmt_cls):
                continue
            else:
                stmt.analyze()

        if content:
            logger.info('Not analyzed content: %s' % content)
            # self.show_message('Not analyzed content: %s' % content)

        parent_provides = self.parent.get_provides()
        if parent_provides is not None:
            if self.name in parent_provides:
                self.warning(
                    'module subprogram name conflict with %s, overriding.' %
                    (self.name))
            if self.is_public():
                parent_provides[self.name] = self

        if self.is_recursive() and self.is_elemental():
            self.warning(
                'C1241 violation: prefix cannot specify both ELEMENTAL and RECURSIVE'
            )
        return
Example #5
0
    def analyze(self):
        content = self.content[:]

        if self.prefix:
            self.update_attributes(self.prefix.upper().split())

        variables = self.a.variables
        for a in self.args:
            assert a not in variables
            if is_name(a):
                variables[a] = Variable(self, a)
            elif a=='*':
                variables[a] = Variable(self, a) # XXX: fix me appropriately
            else:
                raise AnalyzeError('argument must be a name or * but got %r' % (a)) 

        if isinstance(self, Function):
            var = variables[self.result] = Variable(self, self.result)
            if self.typedecl is not None:
                var.set_type(self.typedecl)

        while content:
            stmt = content.pop(0)
            if isinstance(stmt, Contains):
                stmt.analyze() # OC addition
                for stmt in filter_stmts(content, SubProgramStatement):
                    stmt.analyze()
                    self.a.internal_subprogram[stmt.name] = stmt
                stmt = content.pop(0)
                while isinstance (stmt, Comment):
                    stmt = content.pop(0)
                assert isinstance(stmt, self.end_stmt_cls),`stmt`
            elif isinstance(stmt, self.end_stmt_cls):
                continue
            else:
                stmt.analyze()

        if content:
            logger.info('Not analyzed content: %s' % content)
            # self.show_message('Not analyzed content: %s' % content)

        parent_provides = self.parent.get_provides()
        if parent_provides is not None:
            if self.name in parent_provides:
                self.warning('module subprogram name conflict with %s, overriding.' % (self.name))
            if self.is_public():
                parent_provides[self.name] = self

        if self.is_recursive() and self.is_elemental():
            self.warning('C1241 violation: prefix cannot specify both ELEMENTAL and RECURSIVE')
        return
Example #6
0
    def analyze(self):
        content = self.content[:]

        if self.prefix:
            self.update_attributes(prefix.upper().split())

        variables = self.a.variables
        for a in self.args:
            assert not variables.has_key(a)
            assert is_name(a)
            variables[a] = Variable(self, a)

        if isinstance(self, Function):
            var = variables[self.result] = Variable(self, self.result)
            if self.typedecl is not None:
                var.set_type(self.typedecl)

        while content:
            stmt = content.pop(0)
            if isinstance(stmt, Contains):
                for stmt in filter_stmts(content, SubProgramStatement):
                    stmt.analyze()
                    self.a.internal_subprogram[stmt.name] = stmt
                stmt = content.pop(0)
                assert isinstance(stmt, self.end_stmt_cls),`stmt`
            elif isinstance(stmt, self.end_stmt_cls):
                continue
            else:
                stmt.analyze()

        if content:
            self.show_message('Not analyzed content: %s' % content)

        #parent_provides = self.parent.get_provides()
        #if parent_provides is not None:
        #    if self.is_public():
        #        if parent_provides.has_key(self.name):
        #            self.warning('module subprogram name conflict with %s, overriding.' % (self.name))
        #        parent_provides[self.name] = self

        return
Example #7
0
    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()
        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
Example #9
0
    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
Example #10
0
 def is_valid_user(args):
     return is_name(args['fullname']) and args['gender'].upper() in (
         'M', 'F') and is_valid_date(args['birthdate'])