コード例 #1
0
ファイル: Type.py プロジェクト: el-coder-sb/pyVHDLParser
	def statePossibleVariableAssignment(cls, parserState: ParserState):
		token = parserState.Token
		if (isinstance(token, CharacterToken) and (token == "=")):
			parserState.NewToken =      VariableAssignmentKeyword(parserState.TokenMarker)
			parserState.TokenMarker =   parserState.NewToken
			parserState.NextState =     cls.stateVariableAssignment
			return

		raise NotImplementedError("State=PossibleCommentStart: {0!r}".format(token))
コード例 #2
0
    def stateSubtypeIndication(cls, parserState: ParserState):
        token = parserState.Token
        if (isinstance(token, FusedCharacterToken) and (token == ":=")):
            parserState.NewToken = VariableAssignmentKeyword(token)
            parserState.NewBlock = cls(parserState.LastBlock,
                                       parserState.TokenMarker,
                                       endToken=parserState.NewToken)
            parserState.NextState = cls.DELIMITER_BLOCK.stateItemDelimiter
            parserState.PushState = cls.EXPRESSION.stateBeforeExpression
            parserState.TokenMarker = None
            parserState.Counter = 0
            return
        elif isinstance(token, CharacterToken):
            if (token == ';'):
                parserState.NewToken = DelimiterToken(token)
                parserState.NewBlock = cls(
                    parserState.LastBlock,
                    parserState.TokenMarker,
                    endToken=parserState.NewToken.PreviousToken)
                _ = cls.DELIMITER_BLOCK(parserState.NewBlock,
                                        parserState.NewToken)
                parserState.Pop()
                return
            elif (token == ')'):
                parserState.NewToken = BoundaryToken(token)
                parserState.NewBlock = cls(
                    parserState.LastBlock,
                    parserState.TokenMarker,
                    endToken=parserState.NewToken.PreviousToken)
                parserState.Pop(2)
                parserState.TokenMarker = parserState.NewToken
                return
        elif isinstance(token, SpaceToken):
            parserState.NewToken = BoundaryToken(token)
            parserState.NextState = cls.stateWhitespace5
            return
        elif isinstance(token, (LinebreakToken, CommentToken)):
            block = LinebreakBlock if isinstance(
                token, LinebreakToken) else CommentBlock
            parserState.NewBlock = cls(parserState.LastBlock,
                                       parserState.TokenMarker,
                                       endToken=token.PreviousToken,
                                       multiPart=True)
            _ = block(parserState.NewBlock, token)
            parserState.TokenMarker = None
            parserState.NextState = cls.stateWhitespace5
            return

        raise TokenParserException(
            "Expected ';', ':=' or whitespace after subtype indication.",
            token)
コード例 #3
0
ファイル: __init__.py プロジェクト: el-coder-sb/pyVHDLParser
    def stateWhitespace4(cls, parserState: ParserState):
        token = parserState.Token
        if (isinstance(token, FusedCharacterToken) and (token == ":=")):
            parserState.NewToken = VariableAssignmentKeyword(token)
            parserState.NewBlock = cls(parserState.LastBlock,
                                       parserState.TokenMarker,
                                       endToken=parserState.NewToken)
            parserState.PushState = cls.EXPRESSION_BLOCK.stateExpression
            parserState.TokenMarker = None
            parserState.Counter = 0
            return
        elif (isinstance(token, CharacterToken) and (token == ";")):
            parserState.NewToken = EndToken(token)
            parserState.NewBlock = cls(parserState.LastBlock,
                                       parserState.TokenMarker,
                                       endToken=parserState.NewToken)
            parserState.Pop()
            return
        elif isinstance(token, LinebreakToken):
            if (not (isinstance(parserState.LastBlock, CommentBlock)
                     and isinstance(parserState.LastBlock.StartToken,
                                    MultiLineCommentToken))):
                parserState.NewBlock = cls(parserState.LastBlock,
                                           parserState.TokenMarker,
                                           endToken=token.PreviousToken,
                                           multiPart=True)
                _ = LinebreakBlock(parserState.NewBlock, token)
            else:
                parserState.NewBlock = LinebreakBlock(parserState.LastBlock,
                                                      token)
            parserState.TokenMarker = None
            return
        elif isinstance(token, CommentToken):
            parserState.NewBlock = CommentBlock(parserState.LastBlock, token)
            parserState.TokenMarker = None
            return
        elif (isinstance(token, SpaceToken) and
              (isinstance(parserState.LastBlock, CommentBlock) and isinstance(
                  parserState.LastBlock.StartToken, MultiLineCommentToken))):
            parserState.NewToken = BoundaryToken(token)
            parserState.NewBlock = WhitespaceBlock(parserState.LastBlock,
                                                   parserState.NewToken)
            parserState.TokenMarker = None
            return

        raise BlockParserException(
            "Expected ':=' or ';' after subtype indication.", token)
コード例 #4
0
    def stateWhitespace5(cls, parserState: ParserState):
        token = parserState.Token
        if (isinstance(token, FusedCharacterToken) and (token == ":=")):
            parserState.NewToken = VariableAssignmentKeyword(token)
            parserState.NewBlock = cls(parserState.LastBlock,
                                       parserState.TokenMarker,
                                       endToken=parserState.NewToken)
            parserState.NextState = cls.DELIMITER_BLOCK.stateItemDelimiter
            parserState.PushState = cls.EXPRESSION.stateBeforeExpression
            parserState.Counter = 0
            return
        elif isinstance(token, CharacterToken):
            if (token == ';'):
                parserState.NewToken = DelimiterToken(token)
                parserState.NewBlock = cls(
                    parserState.LastBlock,
                    parserState.TokenMarker,
                    endToken=parserState.NewToken.PreviousToken)
                _ = cls.DELIMITER_BLOCK(parserState.NewBlock,
                                        parserState.NewToken)
                parserState.Pop()
                return
            elif (token == ')'):
                parserState.NewToken = BoundaryToken(token)
                parserState.NewBlock = cls(
                    parserState.LastBlock,
                    parserState.TokenMarker,
                    endToken=parserState.NewToken.PreviousToken)
                parserState.Pop(2)
                parserState.TokenMarker = parserState.NewToken
                return
        elif isinstance(token, LinebreakToken):
            if (not (isinstance(parserState.LastBlock, CommentBlock)
                     and isinstance(parserState.LastBlock.StartToken,
                                    MultiLineCommentToken))):
                parserState.NewBlock = cls(parserState.LastBlock,
                                           parserState.TokenMarker,
                                           endToken=token.PreviousToken,
                                           multiPart=True)
                _ = LinebreakBlock(parserState.NewBlock, token)
            else:
                parserState.NewBlock = LinebreakBlock(parserState.LastBlock,
                                                      token)
            parserState.TokenMarker = None
            return
        elif isinstance(token, CommentToken):
            parserState.NewBlock = CommentBlock(parserState.LastBlock, token)
            parserState.TokenMarker = None
            return
        elif (isinstance(token, IndentationToken)
              and isinstance(token.PreviousToken,
                             (LinebreakToken, SingleLineCommentToken))):
            return
        elif (isinstance(token, SpaceToken) and
              (isinstance(parserState.LastBlock, CommentBlock) and isinstance(
                  parserState.LastBlock.StartToken, MultiLineCommentToken))):
            parserState.NewToken = BoundaryToken(token)
            parserState.NewBlock = WhitespaceBlock(parserState.LastBlock,
                                                   parserState.NewToken)
            parserState.TokenMarker = None
            return

        raise TokenParserException("Expected ';' or ':='.", token)