Example #1
0
	def readHead(self, context):
		words = context.currentLine.split()
		self.attrs |= set(words[1:])
		self._phase = 'header'
		self.name = self.key
		# Создать пустой блок
		self.addItem(WppBlock())
		if not self.getAccessLevel():
			self.attrs.add('public')
Example #2
0
 def readHead(self, context):
     pair = context.currentLine.split(':', 1)
     if len(pair) != 2:
         context.throwError('Expected ":" in cast')
     chunks = pair[0].split()
     self.attrs |= set(chunks[1:])
     self.name = context.currentLine.strip()
     self.addItem(WppType.create(pair[1], context))
     self.addItem(WppBlock())
     if not self.getAccessLevel():
         self.attrs.add('public')
Example #3
0
 def readHead(self, context):
     from Wpp.WppExpression import WppExpression
     from Wpp.WppBlock import WppBlock
     pair = context.currentLine.strip().split(' ', 1)
     self.phase = pair[0]
     if self.phase not in {'if', 'elif', 'else'}:
         context.throwError('Invalid phase of "if" statement: "' +
                            self.phase + '"')
     if self.phase != 'else':
         if len(pair) != 2:
             context.throwError('Expected boolean expression')
         expr = WppExpression.create(pair[1], context)
         self.addItem(expr)
     self.addItem(WppBlock())
Example #4
0
    def readHead(self, context):
        self.addItem(WppBlock())
        pair = context.currentLine.split(' ', 1)
        lexems = parseExpr(pair[1], context)
        node, pos = scanLexems(lexems, 0, {'=>'}, context)
        collection = node.makeTaxon()
        self.addItem(collection)

        # value
        pos += 1
        value, lexemType, constType = lexems[pos]
        if value == 'var' and lexemType == 'id':
            # Для значения создается новая переменная
            pos += 1
            value, lexemType, constType = lexems[pos]
            if lexemType != 'id':
                context.throwError('Expected variable name for value')
            self.attrs.add('localValue')
            varValue = WppVar()
            varValue.name = value
            self.addItem(varValue)
            self.setRef('value', varValue)
        else:
            if lexemType != 'id':
                context.throwError('Expected variable name for value')
            self.valueId = value

        # index (optional)
        pos += 1
        value, lexemType, constType = lexems[pos]
        if lexemType == 'cmd' and value == '=>':
            pos += 1
            value, lexemType, constType = lexems[pos]
            if value == 'var' and lexemType == 'id':
                pos += 1
                value, lexemType, constType = lexems[pos]
                if lexemType != 'id':
                    context.throwError('Expected variable name for index')
                self.attrs.add('localIndex')
                varIndex = WppVar()
                varIndex.name = value
                self.addItem(varIndex)
                self.setRef('index', varIndex)
            else:
                if lexemType != 'id':
                    context.throwError('Expected variable name for index')
                self.indexId = value
Example #5
0
	def readHead(self, context):
		from Wpp.WppLocalType import WppLocalType
		self._phase = 'header'
		# Создать пустой блок
		self.addItem(WppBlock())
		pair = context.currentLine.split(':', 1)
		if len(pair) == 2:
			# Создать тип функции
			self.addItem(WppLocalType.create(pair[1], context))
		chunks = pair[0].split()
		if len(chunks) < 2:
			context.throwError('Expected name of '+self.type)
		self.name = chunks[-1]	# Имя функции
		self.attrs |= set(chunks[1:-1]) # Атрибуты
		defaultAccess = self.getDefaultAccessLevel()
		if defaultAccess and not self.getAccessLevel(): # Если квалификатор доступа не указан, используется defaultAccess
			self.attrs.add(defaultAccess)