Beispiel #1
0
    def stateParse(cls, parserState: ParserState):
        currentBlock = parserState.Block

        if isinstance(currentBlock, Architecture.NameBlock):
            parserState.NextState = cls.stateParseDeclarations
            return
        elif isinstance(currentBlock, (LinebreakBlock, IndentationBlock)):
            parserState.PushState = WhitespaceGroup.stateParse
            parserState.NextGroup = WhitespaceGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, CommentBlock):
            parserState.PushState = CommentGroup.stateParse
            parserState.NextGroup = CommentGroup(parserState.LastGroup,
                                                 currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, EndOfDocumentBlock):
            parserState.NextGroup = EndOfDocumentGroup(currentBlock)
            return

        raise GroupParserException(
            "End of architecture declaration not found.".format(
                block=currentBlock.__class__.__qualname__), currentBlock)
Beispiel #2
0
    def stateParse(cls, parserState: ParserState):
        currentBlock = parserState.Block

        if isinstance(currentBlock, SensitivityList.OpenBlock):
            return
        elif isinstance(
                currentBlock,
            (SensitivityList.ItemBlock, SensitivityList.DelimiterBlock)):
            return
        elif isinstance(currentBlock, SensitivityList.CloseBlock):
            parserState.Pop()
            return
        elif isinstance(currentBlock, (LinebreakBlock, IndentationBlock)):
            parserState.PushState = WhitespaceGroup.stateParse
            parserState.NextGroup = WhitespaceGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, CommentBlock):
            parserState.PushState = CommentGroup.stateParse
            parserState.NextGroup = CommentGroup(parserState.LastGroup,
                                                 currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return

        if isinstance(currentBlock, EndOfDocumentBlock):
            parserState.NextGroup = EndOfDocumentGroup(currentBlock)
            return

        raise GroupParserException("End of generic list not found.",
                                   currentBlock)
Beispiel #3
0
	def stateParse(cls, parserState: ParserState):
		for block in parserState.GetBlockIterator:
			if (not isinstance(block, (WhitespaceBlock, LinebreakBlock, IndentationBlock))):
				parserState.NextGroup = cls(parserState.LastGroup, parserState.BlockMarker, block.PreviousBlock)
				parserState.Pop()
				parserState.ReIssue =   True
				return

		raise GroupParserException("End of library clause not found.", block)
Beispiel #4
0
    def stateParse(cls, parserState: ParserState):
        for block in parserState.GetBlockIterator:
            if isinstance(block, Use.EndBlock):
                parserState.NextGroup = cls(parserState.LastGroup,
                                            parserState.BlockMarker, block)
                parserState.Pop()
                return

        raise GroupParserException("End of library clause not found.", block)
Beispiel #5
0
	def stateParse(cls, parserState: ParserState):
		for block in parserState.GetBlockIterator:
			if (not isinstance(block, CommentBlock)):
				parserState.NextGroup = cls(parserState.LastGroup, parserState.BlockMarker, block)
				parserState.Pop()
				parserState.ReIssue =   True
				return

		raise GroupParserException("End of library clause not found.", block)
Beispiel #6
0
    def stateParse(cls, parserState: ParserState):  #document, group):
        assert isinstance(parserState.CurrentGroup, PackageBodyBlock.NameBlock)
        cls.stateParsePackageBodyName(parserState)

        for block in parserState.GroupIterator:
            if isinstance(block, GenericListBlocks.OpenBlock):
                parserState.PushState = cls.stateParseGenericList
                parserState.ReIssue()
            elif isinstance(block, PortListBlocks.OpenBlock):
                parserState.PushState = cls.stateParsePortList
                parserState.ReIssue()
            elif isinstance(block, ConstantBlock):
                parserState.PushState = Constant.stateParse
                parserState.ReIssue()
            elif isinstance(block, Function.BeginBlock):
                parserState.PushState = Function.stateParse
                parserState.ReIssue()
            elif isinstance(block, PackageBodyBlock.EndBlock):
                break
            else:
                raise BlockParserException(
                    "Block '{0!r}' not supported in a package body.".format(
                        block), block)  # FIXME: change to DOMParserException
        else:
            raise BlockParserException(
                "", None)  # FIXME: change to DOMParserException

        parserState.Pop()
Beispiel #7
0
	def stateParse(cls, parserState: ParserState):
		currentBlock = parserState.Block

		# consume OpenBlock
		if isinstance(currentBlock, Procedure.NameBlock):
			parserState.NextGroup =   cls(parserState.LastGroup, currentBlock)
			parserState.BlockMarker = currentBlock
			parserState.NextState =   cls.stateParseGenerics
			return
		else:
			raise BlockParserException("Begin of procedure expected.", currentBlock)
Beispiel #8
0
    def stateParse(cls, parserState: ParserState):
        for block in parserState.GetBlockIterator:
            if isinstance(block, GenericList.DelimiterBlock):
                parserState.Pop()
                return
            elif isinstance(block, GenericList.CloseBlock):
                # parserState.NextGroup = cls(parserState.LastGroup, parserState.BlockMarker, block)
                parserState.Pop()
                parserState.ReIssue = True
                return

        raise GroupParserException("End of generic not found.", block)
Beispiel #9
0
    def stateParse(cls, parserState: ParserState):
        currentBlock = parserState.Block

        # consume OpenBlock
        if isinstance(currentBlock, Process.OpenBlock):
            parserState.NextGroup = cls(parserState.LastGroup, currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.NextState = cls.stateParseSensitivityList
            return
        else:
            raise GroupParserException("Begin of process expected.",
                                       currentBlock)
Beispiel #10
0
	def stateParse(cls, parserState: ParserState):
		marker = parserState.Block
		if parserState.Block.MultiPart:
			for block in parserState.GetBlockIterator:
				if (isinstance(block, ReportBlock) and not block.MultiPart):
					marker2 = block
					break
			else:
				raise BlockParserException("End of multi parted constant declaration not found.", block)
		else:
			marker2 = marker

		parserState.NextGroup = cls(parserState.LastGroup, marker, marker2)
		parserState.Pop()
		return
Beispiel #11
0
    def stateParseArchitectureName(
            cls, parserState: ParserState):  #document, group):
        assert isinstance(parserState.CurrentGroup,
                          ArchitectureBlock.NameBlock)

        tokenIterator = iter(parserState)

        # iterate architetures NameBlock to find the architecture name
        for token in tokenIterator:
            if isinstance(token, IdentifierToken):
                architectureName = token.Value
                break
        else:
            raise BlockParserException(
                "", None)  # FIXME: change to DOMParserException

        for token in tokenIterator:
            if isinstance(token, IdentifierToken):
                entityName = token.Value
                break
        else:
            raise BlockParserException(
                "", None)  # FIXME: change to DOMParserException

        oldNode = parserState.CurrentNode
        architecture = cls(architectureName, entityName)

        parserState.CurrentNode.AddArchitecture(architecture)
        parserState.CurrentNode = architecture
        parserState.CurrentNode.AddLibraryReferences(oldNode.Libraries)
        parserState.CurrentNode.AddUses(oldNode.PackageReferences)

        oldNode.Libraries.clear()
        oldNode.PackageReferences.clear()
Beispiel #12
0
    def stateParse(cls, parserState: ParserState):  #document, group):
        # cls.stateParseArchitectureName(parserState)
        #
        # for block in parserState.GroupIterator:
        # 	if isinstance(block, Constant.ConstantBlock):
        # 		raise NotImplementedError()
        # 	# elif isinstance(block, ArchitectureBlock.ConcurrentBeginBlock):
        # 	# 	raise NotImplementedError()
        # 	elif isinstance(block, ArchitectureBlock.EndBlock):
        # 		break
        # else:
        # 	raise BlockParserException("", None)

        parserState.Pop()
Beispiel #13
0
    def stateParsePortList(cls, parserState: ParserState):  #document, group):
        assert isinstance(parserState.CurrentGroup, PortListBlocks.OpenBlock)

        for block in parserState.GroupIterator:
            if isinstance(
                    block,
                    pyVHDLParser.Blocks.InterfaceObject.InterfaceSignalBlock):
                cls.stateParsePort(parserState)
            elif isinstance(block, PortListBlocks.CloseBlock):
                break
        else:
            raise BlockParserException(
                "", None)  # FIXME: change to DOMParserException

        parserState.Pop()
Beispiel #14
0
    def stateParse2(cls, parserState: ParserState):
        currentBlock = parserState.Block

        # consume OpenBlock
        if isinstance(currentBlock, Function.ReturnTypeBlock):
            parserState.NextState = cls.stateParseDeclarations
            parserState.PushState = cls.stateParse2
            parserState.NextGroup = ReturnTypeGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            return
        else:
            parserState.Pop()
            parserState.ReIssue = True
            return
Beispiel #15
0
    def stateParsePackageName(cls,
                              parserState: ParserState):  #document, group):
        assert isinstance(parserState.CurrentGroup, PackageBlock.NameBlock)

        tokenIterator = iter(parserState)
        for token in tokenIterator:
            if isinstance(token, IdentifierToken):
                packageName = token.Value
                break
        else:
            raise BlockParserException(
                "", None)  # FIXME: change to DOMParserException

        oldNode = parserState.CurrentNode
        package = cls(packageName)

        parserState.CurrentNode.AddPackage(package)
        parserState.CurrentNode = package
        parserState.CurrentNode.AddLibraryReferences(oldNode.Libraries)
        parserState.CurrentNode.AddUses(oldNode.PackageReferences)

        oldNode.Libraries.clear()
        oldNode.PackageReferences.clear()
Beispiel #16
0
    def stateParse(cls, parserState: ParserState):
        currentBlock = parserState.Block

        if isinstance(currentBlock, GenericList.OpenBlock):
            return
        elif isinstance(
                currentBlock,
                pyVHDLParser.Blocks.InterfaceObject.InterfaceConstantBlock):
            parserState.PushState = GenericListItemGroup.stateParse
            parserState.NextGroup = GenericListItemGroup(
                parserState.LastGroup, currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, GenericList.CloseBlock):
            parserState.Pop()
            return
        elif isinstance(currentBlock, (LinebreakBlock, IndentationBlock)):
            parserState.PushState = WhitespaceGroup.stateParse
            parserState.NextGroup = WhitespaceGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, CommentBlock):
            parserState.PushState = CommentGroup.stateParse
            parserState.NextGroup = CommentGroup(parserState.LastGroup,
                                                 currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return

        if isinstance(currentBlock, EndOfDocumentBlock):
            parserState.NextGroup = EndOfDocumentGroup(currentBlock)
            return

        raise GroupParserException("End of generic list not found.",
                                   currentBlock)
Beispiel #17
0
    def stateParse(cls, parserState: ParserState):
        currentBlock = parserState.Block

        if isinstance(currentBlock, Configuration.NameBlock):
            return
        elif isinstance(currentBlock, Configuration.EndBlock):
            parserState.NextGroup = cls(parserState.LastGroup,
                                        parserState.BlockMarker,
                                        parserState.Block)
            parserState.Pop()
            parserState.BlockMarker = None
            return
        elif isinstance(currentBlock, (LinebreakBlock, IndentationBlock)):
            parserState.PushState = WhitespaceGroup.stateParse
            parserState.NextGroup = WhitespaceGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, CommentBlock):
            parserState.PushState = CommentGroup.stateParse
            parserState.NextGroup = CommentGroup(parserState.LastGroup,
                                                 currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        else:
            for block in cls.SIMPLE_BLOCKS:
                if isinstance(currentBlock, block):
                    group = cls.SIMPLE_BLOCKS[block]
                    parserState.PushState = group.stateParse
                    parserState.BlockMarker = currentBlock
                    parserState.ReIssue = True
                    return

            for block in cls.COMPOUND_BLOCKS:
                if isinstance(currentBlock, block):
                    group = cls.COMPOUND_BLOCKS[block]
                    parserState.PushState = group.stateParse
                    parserState.BlockMarker = currentBlock
                    parserState.ReIssue = True
                    return

        if isinstance(currentBlock, EndOfDocumentBlock):
            parserState.NextGroup = EndOfDocumentGroup(currentBlock)
            return

        raise GroupParserException(
            "End of configuration declaration not found.".format(
                block=currentBlock.__class__.__qualname__), currentBlock)
Beispiel #18
0
    def stateParseDeclarations(cls, parserState: ParserState):
        currentBlock = parserState.Block

        if isinstance(currentBlock, Architecture.BeginBlock):
            parserState.NextState = cls.stateParseStatements
            return
        elif isinstance(currentBlock, (LinebreakBlock, IndentationBlock)):
            parserState.PushState = WhitespaceGroup.stateParse
            parserState.NextGroup = WhitespaceGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, CommentBlock):
            parserState.PushState = CommentGroup.stateParse
            parserState.NextGroup = CommentGroup(parserState.LastGroup,
                                                 currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        else:
            for block in cls.DECLARATION_SIMPLE_BLOCKS:
                if isinstance(currentBlock, block):
                    group = cls.DECLARATION_SIMPLE_BLOCKS[block]
                    parserState.PushState = group.stateParse
                    parserState.BlockMarker = currentBlock
                    parserState.ReIssue = True
                    return

            for block in cls.DECLARATION_COMPOUND_BLOCKS:
                if isinstance(currentBlock, block):
                    group = cls.DECLARATION_COMPOUND_BLOCKS[block]
                    parserState.PushState = group.stateParse
                    parserState.BlockMarker = currentBlock
                    parserState.ReIssue = True
                    return

        if isinstance(currentBlock, EndOfDocumentBlock):
            parserState.NextGroup = EndOfDocumentGroup(currentBlock)
            return

        raise GroupParserException(
            "End of architecture declaration not found.".format(
                block=currentBlock.__class__.__qualname__), currentBlock)
Beispiel #19
0
    def stateParseStatements(cls, parserState: ParserState):
        currentBlock = parserState.Block

        if isinstance(currentBlock, Entity.EndBlock):
            parserState.NextGroup = cls(parserState.LastGroup,
                                        parserState.BlockMarker,
                                        parserState.Block)
            parserState.Pop()
            parserState.BlockMarker = None
            return
        elif isinstance(currentBlock, (LinebreakBlock, IndentationBlock)):
            parserState.PushState = WhitespaceGroup.stateParse
            parserState.NextGroup = WhitespaceGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, CommentBlock):
            parserState.PushState = CommentGroup.stateParse
            parserState.NextGroup = CommentGroup(parserState.LastGroup,
                                                 currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        else:
            for block in cls.STATEMENT_SIMPLE_BLOCKS:
                if isinstance(currentBlock, block):
                    group = cls.STATEMENT_SIMPLE_BLOCKS[block]
                    parserState.PushState = group.stateParse
                    parserState.BlockMarker = currentBlock
                    parserState.ReIssue = True
                    return

            for block in cls.STATEMENT_COMPOUND_BLOCKS:
                if isinstance(currentBlock, block):
                    group = cls.STATEMENT_COMPOUND_BLOCKS[block]
                    parserState.PushState = group.stateParse
                    parserState.BlockMarker = currentBlock
                    parserState.ReIssue = True
                    return

        if isinstance(currentBlock, EndOfDocumentBlock):
            parserState.NextGroup = EndOfDocumentGroup(currentBlock)
            return

        raise GroupParserException("End of entity declaration not found.",
                                   currentBlock)
Beispiel #20
0
    def stateParsePorts(cls, parserState: ParserState):
        currentBlock = parserState.Block

        if isinstance(currentBlock, PortList.OpenBlock):
            parserState.NextState = cls.stateParseDeclarations
            parserState.PushState = PortListGroup.stateParse
            parserState.NextGroup = PortListGroup(parserState.LastGroup,
                                                  currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, (LinebreakBlock, IndentationBlock)):
            parserState.PushState = WhitespaceGroup.stateParse
            parserState.NextGroup = WhitespaceGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, CommentBlock):
            parserState.PushState = CommentGroup.stateParse
            parserState.NextGroup = CommentGroup(parserState.LastGroup,
                                                 currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return

        if isinstance(currentBlock, EndOfDocumentBlock):
            parserState.NextGroup = EndOfDocumentGroup(currentBlock)
            return

        raise GroupParserException("End of port clause not found.",
                                   currentBlock)
Beispiel #21
0
    def stateParseGenerics(cls, parserState: ParserState):
        currentBlock = parserState.Block

        if isinstance(currentBlock, GenericList.OpenBlock):
            parserState.NextState = cls.stateParseParameters
            parserState.PushState = GenericListGroup.stateParse
            parserState.NextGroup = GenericListGroup(parserState.LastGroup,
                                                     currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, ParameterList.OpenBlock):
            parserState.NextState = cls.stateParseDeclarations
            parserState.PushState = ParameterListGroup.stateParse
            parserState.NextGroup = ParameterListGroup(parserState.LastGroup,
                                                       currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, Function.ReturnTypeBlock):
            if isinstance(currentBlock.EndToken, EndToken):
                parserState.Pop()
            else:
                parserState.NextState = cls.stateParse2
                parserState.ReIssue = True
            return
        elif isinstance(currentBlock, (LinebreakBlock, IndentationBlock)):
            parserState.PushState = WhitespaceGroup.stateParse
            parserState.NextGroup = WhitespaceGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, CommentBlock):
            parserState.PushState = CommentGroup.stateParse
            parserState.NextGroup = CommentGroup(parserState.LastGroup,
                                                 currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return

        if isinstance(currentBlock, EndOfDocumentBlock):
            parserState.NextGroup = EndOfDocumentGroup(currentBlock)
            return

        raise BlockParserException("End of generic clause not found.",
                                   currentBlock)
Beispiel #22
0
    def stateParseDeclarations(cls, parserState: ParserState):
        currentBlock = parserState.Block

        if isinstance(currentBlock, Function.BeginBlock):
            parserState.NextState = cls.stateParseStatements
            return
        elif isinstance(currentBlock, Function.EndBlock):
            parserState.NextGroup = cls(parserState.LastGroup,
                                        parserState.BlockMarker,
                                        parserState.Block)
            parserState.Pop()
            parserState.BlockMarker = None
            return
        elif isinstance(currentBlock, (LinebreakBlock, IndentationBlock)):
            parserState.PushState = WhitespaceGroup.stateParse
            parserState.NextGroup = WhitespaceGroup(parserState.LastGroup,
                                                    currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        elif isinstance(currentBlock, CommentBlock):
            parserState.PushState = CommentGroup.stateParse
            parserState.NextGroup = CommentGroup(parserState.LastGroup,
                                                 currentBlock)
            parserState.BlockMarker = currentBlock
            parserState.ReIssue = True
            return
        else:
            for block in cls.DECLARATION_SIMPLE_BLOCKS:
                if isinstance(currentBlock, block):
                    group = cls.DECLARATION_SIMPLE_BLOCKS[block]
                    parserState.PushState = group.stateParse
                    parserState.BlockMarker = currentBlock
                    parserState.ReIssue = True
                    return

            for block in cls.DECLARATION_COMPOUND_BLOCKS:
                if isinstance(currentBlock, block):
                    group = cls.DECLARATION_COMPOUND_BLOCKS[block]
                    parserState.PushState = group.stateParse
                    parserState.BlockMarker = currentBlock
                    parserState.ReIssue = True
                    return

        if isinstance(currentBlock, EndOfDocumentBlock):
            parserState.NextGroup = EndOfDocumentGroup(currentBlock)
            return

        raise BlockParserException(
            "End of function declarative region not found.", currentBlock)