コード例 #1
0
ファイル: Entity.py プロジェクト: Paebbels/pyVHDLParser
class SimpleEntity_OneLine_NoEnd_EndWithKeywordAndName(
        TestCase, ExpectedDataMixin, TokenLinking, TokenSequence,
        BlockSequenceWithParserError):
    code = "entity e is entity e;"
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None),  #
        (WordToken, "entity"),  # entity
        (SpaceToken, " "),  #
        (WordToken, "e"),  # e
        (SpaceToken, " "),  #
        (WordToken, "is"),  # is
        (SpaceToken, " "),  #
        (WordToken, "entity"),  # entity
        (SpaceToken, " "),  #
        (WordToken, "e"),  # e
        (CharacterToken, ";"),  # ;
        (EndOfDocumentToken, None)  #
    ])
    blockStream = ExpectedBlockStream([
        (StartOfDocumentBlock, None),  #
        (Entity.NameBlock, "entity e is"),  # entity e is
        (WhitespaceBlock, " "),  #
        (Entity.EndBlock, "entity e;"),  # entity e;
        (EndOfDocumentBlock, None)  #
    ])
コード例 #2
0
ファイル: Entity.py プロジェクト: Paebbels/pyVHDLParser
class SimpleEntity_AllLine_LongForm(TestCase, ExpectedDataMixin, LinkingTests,
                                    TokenSequence, BlockSequence):
    code = "entity\ne\nis\nend\nentity\ne\n;\n"
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None), (WordToken, "entity"),
        (LinebreakToken, "\n"), (WordToken, "e"), (LinebreakToken, "\n"),
        (WordToken, "is"), (LinebreakToken, "\n"), (WordToken, "end"),
        (LinebreakToken, "\n"), (WordToken, "entity"), (LinebreakToken, "\n"),
        (WordToken, "e"), (LinebreakToken, "\n"), (CharacterToken, ";"),
        (LinebreakToken, "\n"), (EndOfDocumentToken, None)
    ])
    blockStream = ExpectedBlockStream([
        (StartOfDocumentBlock, None),
        (Entity.NameBlock, "entity"),
        (LinebreakBlock, "\n"),
        #			(IndentationBlock,      "\t"),
        (Entity.NameBlock, "e"),
        (LinebreakBlock, "\n"),
        (Entity.NameBlock, "is"),
        (LinebreakBlock, "\n"),
        (Entity.EndBlock, "end\n"),
        #			(LinebreakBlock,        "\n"),
        (Entity.EndBlock, "entity\n"),
        #			(LinebreakBlock,        "\n"),
        (Entity.EndBlock, "e\n"),
        #			(LinebreakBlock,        "\n"),
        (Entity.EndBlock, ";"),
        (LinebreakBlock, "\n"),
        (EndOfDocumentBlock, None)
    ])
コード例 #3
0
ファイル: Procedure.py プロジェクト: Paebbels/pyVHDLParser
class SimpleProcedureInPackage_OneLine_NoParameter(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "package p is procedure p; end;"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "package"),
			(SpaceToken,           " "),
			(WordToken,            "p"),
			(SpaceToken,           " "),
			(WordToken,            "is"),
			(SpaceToken,           " "),
			(WordToken,            "procedure"),
			(SpaceToken,           " "),
			(WordToken,            "p"),
			(CharacterToken,       ";"),
			(SpaceToken,           " "),
			(WordToken,            "end"),
			(CharacterToken,       ";"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),           #
			(Package.NameBlock,    "package p is"), # package pis
			(WhitespaceBlock,      " "),            #
			(Procedure.NameBlock,  "procedure p;"),
			(WhitespaceBlock,          " "),            #
			(Package.EndBlock,     "end;"),         # end;
			(EndOfDocumentBlock,   None)            #
		]
	)
コード例 #4
0
class SimpleAssertInArchitecture_OneLine_OnlyAssert(TestCase,
                                                    ExpectedDataMixin,
                                                    TokenLinking,
                                                    TokenSequence):
    code = "architecture a of e is begin assert true report \"error\"; end;"
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None), (WordToken, "architecture"),
        (SpaceToken, " "), (WordToken, "a"), (SpaceToken, " "),
        (WordToken, "of"), (SpaceToken, " "), (WordToken, "e"),
        (SpaceToken, " "), (WordToken, "is"), (SpaceToken, " "),
        (WordToken, "begin"), (SpaceToken, " "), (WordToken, "assert"),
        (SpaceToken, " "), (WordToken, "true"), (SpaceToken, " "),
        (WordToken, "report"), (SpaceToken, " "), (StringLiteralToken,
                                                   "error"),
        (CharacterToken, ";"), (SpaceToken, " "), (WordToken, "end"),
        (CharacterToken, ";"), (EndOfDocumentToken, None)
    ])
    blockStream = ExpectedBlockStream([
        (StartOfDocumentBlock, None),
        (Architecture.NameBlock, "architecture a of e is"),
        (WhitespaceBlock, " "), (Architecture.BeginBlock, "begin"),
        (WhitespaceBlock, " "),
        (Assert.AssertBlock, "assert true report \"error\";"),
        (Architecture.EndBlock, "end;"), (EndOfDocumentBlock, None)
    ])
コード例 #5
0
ファイル: Tokens.py プロジェクト: Paebbels/pyVHDLParser
class Sequence_5(TestCase, ExpectedDataMixin, TokenSequence):
    code = """abc/* comment */123/* comment */456.789/* comment */'Z'/* comment */"Hallo"/* comment */\\foo\\/* comment */-- comment\n/* comment *//* comment */;/* comment */  /* comment */ """
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None),
        (WordToken, "abc"),
        (MultiLineCommentToken, "/* comment */"),
        (IntegerLiteralToken, "123"),
        (MultiLineCommentToken, "/* comment */"),
        (RealLiteralToken, "456.789"),
        (MultiLineCommentToken, "/* comment */"),
        (CharacterLiteralToken, "Z"),
        (MultiLineCommentToken, "/* comment */"),
        (StringLiteralToken, "Hallo"),
        (MultiLineCommentToken, "/* comment */"),
        (ExtendedIdentifier, "\\foo\\"),
        (MultiLineCommentToken, "/* comment */"),
        (SingleLineCommentToken, "-- comment\n"),
        (MultiLineCommentToken, "/* comment */"),
        (MultiLineCommentToken, "/* comment */"),
        (CharacterToken, ";"),
        (MultiLineCommentToken, "/* comment */"),
        (SpaceToken, "  "),
        (MultiLineCommentToken, "/* comment */"),
        (
            SpaceToken, " "
        ),  # FIXME: workaround until incomplete fused tokens are handled in Tokenizer
        (EndOfDocumentToken, None)
    ])
コード例 #6
0
class SimplePackageBody_OneLine_OnlyEnd(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "package body p is end;"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "package"),
			(SpaceToken,           " "),
			(WordToken,            "body"),
			(SpaceToken,           " "),
			(WordToken,            "p"),
			(SpaceToken,           " "),
			(WordToken,            "is"),
			(SpaceToken,           " "),
			(WordToken,            "end"),
			(CharacterToken,       ";"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),           #
			(PackageBody.NameBlock, "package body p is"), # package body p is
			(WhitespaceBlock,       " "),            #
			(PackageBody.EndBlock,  "end;"),         # end;
			(EndOfDocumentBlock,    None)            #
		]
	)
コード例 #7
0
class SimplePackage_OneLine_NoEnd_EndWithKeywordAndName(TestCase, ExpectedDataMixin, TokenLinking, TokenSequence, BlockSequenceWithParserError):
	code = "package p is package p;"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),      #
			(WordToken,            "package"),  # package
			(SpaceToken,           " "),       #
			(WordToken,            "p"),       # p
			(SpaceToken,           " "),       #
			(WordToken,            "is"),      # is
			(SpaceToken,           " "),       #
			(WordToken,            "package"),  # package
			(SpaceToken,           " "),       #
			(WordToken,            "p"),       # p
			(CharacterToken,       ";"),       # ;
			(EndOfDocumentToken,   None)       #
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),             #
			(Package.NameBlock,     "package p is"),    # package p is
			(WhitespaceBlock,      " "),              #
			(Package.EndBlock,      "package p;"),      # package p;
			(EndOfDocumentBlock,   None)              #
		]
	)
コード例 #8
0
class SimplePackageBody_OneLine_NoIs_EndWithKeywordAndName(TestCase, ExpectedDataMixin, TokenLinking, TokenSequence, BlockSequenceWithParserError):
	code = "package body p end package body p;"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),      #
			(WordToken,            "package"), # package
			(SpaceToken,           " "),       #
			(WordToken,            "body"),    # body
			(SpaceToken,           " "),       #
			(WordToken,            "p"),       # p
			(SpaceToken,           " "),       #
			(WordToken,            "end"),     # end
			(SpaceToken,           " "),       #
			(WordToken,            "package"), # package
			(SpaceToken,           " "),       #
			(WordToken,            "body"),    # body
			(SpaceToken,           " "),       #
			(WordToken,            "p"),       # p
			(CharacterToken,       ";"),       # ;
			(EndOfDocumentToken,   None)       #
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),             #
			(PackageBody.NameBlock,  "package body p"),       # package body p
			(WhitespaceBlock,        " "),              #
			(PackageBody.EndBlock,   "end package body p;"),  # end package body p;
			(EndOfDocumentBlock,     None)              #
		]
	)
コード例 #9
0
class SimplePackage_MultiLine_LongForm(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = dedent("""\
		package p is
		end package p ;
		""")
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "package"),
			(SpaceToken,           " "),
			(WordToken,            "p"),
			(SpaceToken,           " "),
			(WordToken,            "is"),
			(LinebreakToken,       "\n"),
			(WordToken,            "end"),
			(SpaceToken,           " "),
			(WordToken,            "package"),
			(SpaceToken,           " "),
			(WordToken,            "p"),
			(SpaceToken,           " "),
			(CharacterToken,       ";"),
			(LinebreakToken,       "\n"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),
			(Package.NameBlock,     "package p is"),
			(LinebreakBlock,       "\n"),
			(Package.EndBlock,      "end package p ;"),
			(LinebreakBlock,       "\n"),
			(EndOfDocumentBlock,   None)
		]
	)
コード例 #10
0
class SimplePortList_OneLine_DoublePort(TestCase, ExpectedDataMixin,
                                        TokenLinking, TokenSequence,
                                        BlockSequence):
    code = "entity e is port (port1 : bit; port2 : boolean ); end;"
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None), (WordToken, "entity"), (SpaceToken, " "),
        (WordToken, "e"), (SpaceToken, " "), (WordToken, "is"),
        (SpaceToken, " "), (WordToken, "port"), (SpaceToken, " "),
        (CharacterToken, "("), (WordToken, "port1"), (SpaceToken, " "),
        (CharacterToken, ":"), (SpaceToken, " "), (WordToken, "bit"),
        (CharacterToken, ";"), (SpaceToken, " "), (WordToken, "port2"),
        (SpaceToken, " "), (CharacterToken, ":"), (SpaceToken, " "),
        (WordToken, "boolean"), (SpaceToken, " "), (CharacterToken, ")"),
        (CharacterToken, ";"), (SpaceToken, " "), (WordToken, "end"),
        (CharacterToken, ";"), (EndOfDocumentToken, None)
    ])
    blockStream = ExpectedBlockStream([
        (StartOfDocumentBlock, None),  #
        (Entity.NameBlock, "entity e is"),  # entity e is
        (WhitespaceBlock, " "),  #
        (PortList.OpenBlock, "port ("),  # port (
        (PortListInterfaceSignalBlock, "port1 : bit"),  # port1 : bit
        (PortList.DelimiterBlock, ";"),  # ;
        (PortListInterfaceSignalBlock, "port2 : boolean "),  # port2 : boolean
        (PortList.CloseBlock, ");"),  # );
        (WhitespaceBlock, " "),  #
        (Entity.EndBlock, "end;"),  # end;
        (EndOfDocumentBlock, None)  #
    ])
コード例 #11
0
class SimplePackage_MultiLine_LongForm_WithSingleGeneric(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = dedent("""\
		package p is
			generic (
				G : integer
			);
		end package p;
		""")
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "package"),
			(SpaceToken,           " "),
			(WordToken,            "p"),
			(SpaceToken,           " "),
			(WordToken,            "is"),
			(LinebreakToken,       None),
			(IndentationToken,     "\t"),
			(WordToken,            "generic"),
			(SpaceToken,           " "),
			(CharacterToken,       "("),
			(LinebreakToken,       None),
			(IndentationToken,     "\t\t"),
			(WordToken,            "G"),
			(SpaceToken,           " "),
			(CharacterToken,       ":"),
			(SpaceToken,           " "),
			(WordToken,            "integer"),
			(LinebreakToken,       None),
			(IndentationToken,     "\t"),
			(CharacterToken,       ")"),
			(CharacterToken,       ";"),
			(LinebreakToken,       None),
			(WordToken,            "end"),
			(SpaceToken,           " "),
			(WordToken,            "package"),
			(SpaceToken,           " "),
			(WordToken,            "p"),
			(CharacterToken,       ";"),
			(LinebreakToken,       None),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock,    None),
			(Package.NameBlock,        "package p is"),
			(LinebreakBlock,          "\n"),
			(IndentationBlock,        "\t"),
			(GenericList.OpenBlock,   "generic ("),
			(LinebreakBlock,          "\n"),
			(IndentationBlock,        "\t\t"),
			(GenericList.GenericListInterfaceConstantBlock, "G : integer"),
			(LinebreakBlock,          "\n"),
			(GenericList.GenericListInterfaceConstantBlock, "\t"),
			(GenericList.CloseBlock,  ");"),
			(LinebreakBlock,          "\n"),
			(Package.EndBlock,         "end package p;"),
			(LinebreakBlock,          "\n"),
			(EndOfDocumentBlock,      None)
		]
	)
コード例 #12
0
class SimpleArchitecture_OneLine_EndWithKeyword(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "architecture a of e is begin end architecture;"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "architecture"),
			(SpaceToken,           " "),
			(WordToken,            "a"),
			(SpaceToken,           " "),
			(WordToken,            "of"),
			(SpaceToken,           " "),
			(WordToken,            "e"),
			(SpaceToken,           " "),
			(WordToken,            "is"),
			(SpaceToken,           " "),
			(WordToken,            "begin"),
			(SpaceToken,           " "),
			(WordToken,            "end"),
			(SpaceToken,           " "),
			(WordToken,            "architecture"),
			(CharacterToken,       ";"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock,    None),
			(Architecture.NameBlock,  "architecture a of e is"),
			(WhitespaceBlock,         " "),
			(Architecture.BeginBlock, "begin"),
			(WhitespaceBlock,         " "),
			(Architecture.EndBlock,   "end architecture;"),
			(EndOfDocumentBlock,      None)
		]
	)
コード例 #13
0
class SimplePackage_OneLine_EndWithKeyword(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "package p is end package;"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),      #
			(WordToken,            "package"),  # package
			(SpaceToken,           " "),       #
			(WordToken,            "p"),       # e
			(SpaceToken,           " "),       #
			(WordToken,            "is"),      # is
			(SpaceToken,           " "),       #
			(WordToken,            "end"),     # end
			(SpaceToken,           " "),       #
			(WordToken,            "package"),  # package
			(CharacterToken,       ";"),       # ;
			(EndOfDocumentToken,   None)       #
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),           #
			(Package.NameBlock,     "package p is"),  # package p is
			(WhitespaceBlock,      " "),            #
			(Package.EndBlock,      "end package;"),  # end package;
			(EndOfDocumentBlock,   None)            #
		],
	)
コード例 #14
0
class SimplePackageBody_OneLine_EndWithKeywordAndName_WrongName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "package body p is end package body a;"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),      #
			(WordToken,            "package"), # package
			(SpaceToken,           " "),       #
			(WordToken,            "body"),    # body
			(SpaceToken,           " "),       #
			(WordToken,            "p"),       # p
			(SpaceToken,           " "),       #
			(WordToken,            "is"),      # is
			(SpaceToken,           " "),       #
			(WordToken,            "end"),     # end
			(SpaceToken,           " "),       #
			(WordToken,            "package"), # package
			(SpaceToken,           " "),       #
			(WordToken,            "body"),    # body
			(SpaceToken,           " "),       #
			(WordToken,            "a"),       # a
			(CharacterToken,       ";"),       # ;
			(EndOfDocumentToken,   None)       #
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),             #
			(PackageBody.NameBlock, "package body p is"),    # package p is
			(WhitespaceBlock,       " "),              #
			(PackageBody.EndBlock,  "end package body a;"),  # end package a;
			(EndOfDocumentBlock,    None)              #
		]
	)
コード例 #15
0
ファイル: Process.py プロジェクト: Paebbels/pyVHDLParser
class SimpleProcessInArchitecture_OneLine_NoIs(TestCase, ExpectedDataMixin,
                                               LinkingTests, TokenSequence,
                                               BlockSequence):
    code = "architecture a of e is begin process begin end process; end;"
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None), (WordToken, "architecture"),
        (SpaceToken, " "), (WordToken, "a"), (SpaceToken, " "),
        (WordToken, "of"), (SpaceToken, " "), (WordToken, "e"),
        (SpaceToken, " "), (WordToken, "is"), (SpaceToken, " "),
        (WordToken, "begin"), (SpaceToken, " "), (WordToken, "process"),
        (SpaceToken, " "), (WordToken, "begin"), (SpaceToken, " "),
        (WordToken, "end"), (SpaceToken, " "), (WordToken, "process"),
        (CharacterToken, ";"), (SpaceToken, " "), (WordToken, "end"),
        (CharacterToken, ";"), (EndOfDocumentToken, None)
    ])
    blockStream = ExpectedBlockStream([(StartOfDocumentBlock, None),
                                       (Architecture.NameBlock,
                                        "architecture a of e is"),
                                       (WhitespaceBlock, " "),
                                       (Architecture.BeginBlock, "begin"),
                                       (WhitespaceBlock, " "),
                                       (Process.OpenBlock, "process "),
                                       (Process.BeginBlock, "begin"),
                                       (WhitespaceBlock, " "),
                                       (Process.EndBlock, "end process;"),
                                       (WhitespaceBlock, " "),
                                       (Architecture.EndBlock, "end;"),
                                       (EndOfDocumentBlock, None)])
コード例 #16
0
ファイル: Entity.py プロジェクト: Paebbels/pyVHDLParser
class SimpleEntity_OneLine_EndWithName(TestCase, ExpectedDataMixin,
                                       LinkingTests, TokenSequence,
                                       BlockSequence):
    code = "entity e is end e;"
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None),  #
        (WordToken, "entity"),  # entity
        (SpaceToken, " "),  #
        (WordToken, "e"),  # e
        (SpaceToken, " "),  #
        (WordToken, "is"),  # is
        (SpaceToken, " "),  #
        (WordToken, "end"),  # end
        (SpaceToken, " "),  #
        (WordToken, "e"),  # e
        (CharacterToken, ";"),  # ;
        (EndOfDocumentToken, None)  #
    ])
    blockStream = ExpectedBlockStream([
        (StartOfDocumentBlock, None),  #
        (Entity.NameBlock, "entity e is"),  # entity e is
        (WhitespaceBlock, " "),  #
        (Entity.EndBlock, "end e;"),  # end e;
        (EndOfDocumentBlock, None)  #
    ])
コード例 #17
0
ファイル: Entity.py プロジェクト: Paebbels/pyVHDLParser
class SimpleEntity_MultiLine_LongForm_WithSingleGeneric_TypoInGeneric(
        TestCase, ExpectedDataMixin, TokenLinking,
        BlockSequenceWithParserError):
    code = dedent("""\
		entity e is
			gen (
				G : integer
			;
		end	entity e;
		""")
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None), (WordToken, "entity"), (SpaceToken, " "),
        (WordToken, "e"), (SpaceToken, " "), (WordToken, "is"),
        (LinebreakToken, None), (IndentationToken, "\t"), (WordToken, "gen"),
        (SpaceToken, " "), (CharacterToken, "("), (LinebreakToken, None),
        (IndentationToken, "\t\t"), (WordToken, "G"), (SpaceToken, " "),
        (CharacterToken, ":"), (SpaceToken, " "), (WordToken, "integer"),
        (LinebreakToken, None), (IndentationToken, "\t"),
        (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"),
        (SpaceToken, " "), (WordToken, "entity"), (SpaceToken, " "),
        (WordToken, "a"), (CharacterToken, ";"), (EndOfDocumentToken, None)
    ])
    blockStream = ExpectedBlockStream([
        (StartOfDocumentBlock, None), (Entity.NameBlock, "entity e is"),
        (LinebreakBlock, "\n"), (IndentationBlock, "\t"),
        (GenericList.OpenBlock, "generic ("), (LinebreakBlock, "\n"),
        (IndentationBlock, "\t\t"),
        (GenericList.GenericListInterfaceConstantBlock, "G : integer"),
        (LinebreakBlock, "\n"),
        (GenericList.GenericListInterfaceConstantBlock, "\t"),
        (GenericList.CloseBlock, ");"), (LinebreakBlock, "\n"),
        (Entity.EndBlock, "end entity e;"), (LinebreakBlock, "\n"),
        (EndOfDocumentBlock, None)
    ])
コード例 #18
0
class SimpleArchitecture_MultiLine_EndWithKeywordAndName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "architecture\na\nof\ne\nis\nbegin\nend\narchitecture\na\n;\n"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "architecture"),
			(LinebreakToken,       None),
			(WordToken,            "a"),
			(LinebreakToken,       None),
			(WordToken,            "of"),
			(LinebreakToken,       None),
			(WordToken,            "e"),
			(LinebreakToken,       None),
			(WordToken,            "is"),
			(LinebreakToken,       None),
			(WordToken,            "begin"),
			(LinebreakToken,       None),
			(WordToken,            "end"),
			(LinebreakToken,       None),
			(WordToken,            "architecture"),
			(LinebreakToken,       None),
			(WordToken,            "a"),
			(LinebreakToken,       None),
			(CharacterToken,       ";"),
			(LinebreakToken,       None),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock,    None),
			(Architecture.NameBlock,  "architecture"),
			(LinebreakBlock,          "\n"),
#			(IndentationBlock,        "\t"),
			(Architecture.NameBlock,  "a"),
			(LinebreakBlock,          "\n"),
			(Architecture.NameBlock,  "of"),
			(LinebreakBlock,          "\n"),
			(Architecture.NameBlock,  "e"),
			(LinebreakBlock,          "\n"),
			(Architecture.NameBlock,  "is"),
			(LinebreakBlock,          "\n"),
			(Architecture.BeginBlock, "begin"),
			(LinebreakBlock,          "\n"),
			(Architecture.EndBlock,   "end\n"),
#			(LinebreakBlock,          "\n"),
			(Architecture.EndBlock,   "architecture\n"),
#			(LinebreakBlock,          "\n"),
			(Architecture.EndBlock,   "a\n"),
#			(LinebreakBlock,          "\n"),
			(Architecture.EndBlock,   ";"),
			(LinebreakBlock,          "\n"),
			(EndOfDocumentBlock,      None)
		]
	)
コード例 #19
0
class SimpleArchitecture_MultilineComments_EndWithKeywordAndName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "architecture/* comment */a/* comment */of/* comment */e/* comment */is/* comment */begin/* comment */end/* comment */architecture/* comment */a/* comment */;/* comment */"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,             "architecture"),
			(MultiLineCommentToken, "/* comment */"),
			(WordToken,            "a"),
			(MultiLineCommentToken, "/* comment */"),
			(WordToken,            "of"),
			(MultiLineCommentToken, "/* comment */"),
			(WordToken,            "e"),
			(MultiLineCommentToken, "/* comment */"),
			(WordToken,            "is"),
			(MultiLineCommentToken, "/* comment */"),
			(WordToken,            "begin"),
			(MultiLineCommentToken, "/* comment */"),
			(WordToken,            "end"),
			(MultiLineCommentToken, "/* comment */"),
			(WordToken,            "architecture"),
			(MultiLineCommentToken, "/* comment */"),
			(WordToken,            "a"),
			(MultiLineCommentToken, "/* comment */"),
			(CharacterToken,       ";"),
			(MultiLineCommentToken, "/* comment */"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock,    None),
			(Architecture.NameBlock,  "architecture"),
			(CommentBlock,            "/* comment */"),
			(Architecture.NameBlock,  "a"),
			(CommentBlock,            "/* comment */"),
			(Architecture.NameBlock,  "of"),
			(CommentBlock,            "/* comment */"),
			(Architecture.NameBlock,  "e"),
			(CommentBlock,            "/* comment */"),
			(Architecture.NameBlock,  "is"),
			(CommentBlock,            "/* comment */"),
			(Architecture.BeginBlock, "begin"),
			(CommentBlock,            "/* comment */"),
			(Architecture.EndBlock,   "end"),
			(CommentBlock,            "/* comment */"),
			(Architecture.EndBlock,   "architecture"),
			(CommentBlock,            "/* comment */"),
			(Architecture.EndBlock,   "a"),
			(CommentBlock,            "/* comment */"),
			(Architecture.EndBlock,   ";"),
			(CommentBlock,            "/* comment */"),
			(EndOfDocumentBlock,      None)
		]
	)
コード例 #20
0
class SimpleArchitecture_SingleLineComments_EndWithKeywordAndName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "architecture-- comment\na-- comment\nof-- comment\ne-- comment\nis-- comment\nbegin-- comment\nend-- comment\narchitecture-- comment\na-- comment\n;-- comment\n"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,               "architecture"),
			(SingleLineCommentToken,  "-- comment\n"),
			(WordToken,               "a"),
			(SingleLineCommentToken,  "-- comment\n"),
			(WordToken,               "of"),
			(SingleLineCommentToken,  "-- comment\n"),
			(WordToken,               "e"),
			(SingleLineCommentToken,  "-- comment\n"),
			(WordToken,              "is"),
			(SingleLineCommentToken,  "-- comment\n"),
			(WordToken,              "begin"),
			(SingleLineCommentToken,  "-- comment\n"),
			(WordToken,              "end"),
			(SingleLineCommentToken,  "-- comment\n"),
			(WordToken,              "architecture"),
			(SingleLineCommentToken,  "-- comment\n"),
			(WordToken,              "a"),
			(SingleLineCommentToken,  "-- comment\n"),
			(CharacterToken,         ";"),
			(SingleLineCommentToken,  "-- comment\n"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock,    None),
			(Architecture.NameBlock,  "architecture"),
			(CommentBlock,            "-- comment\n"),
			(Architecture.NameBlock,  "a"),
			(CommentBlock,            "-- comment\n"),
			(Architecture.NameBlock,  "of"),
			(CommentBlock,            "-- comment\n"),
			(Architecture.NameBlock,  "e"),
			(CommentBlock,            "-- comment\n"),
			(Architecture.NameBlock,  "is"),
			(CommentBlock,            "-- comment\n"),
			(Architecture.BeginBlock, "begin"),
			(CommentBlock,            "-- comment\n"),
			(Architecture.EndBlock,   "end"),
			(CommentBlock,            "-- comment\n"),
			(Architecture.EndBlock,   "architecture"),
			(CommentBlock,            "-- comment\n"),
			(Architecture.EndBlock,   "a"),
			(CommentBlock,            "-- comment\n"),
			(Architecture.EndBlock,   ";"),
			(CommentBlock,            "-- comment\n"),
			(EndOfDocumentBlock,      None)
		]
	)
コード例 #21
0
ファイル: Tokens.py プロジェクト: Paebbels/pyVHDLParser
class Tokenizer_ExceptionInKeyword(TestCase, ExpectedDataMixin, TokenSequence):
    code = """keyword"""
    tokenStream = ExpectedTokenStream([(StartOfDocumentToken, None),
                                       (WordToken, "keyword"),
                                       (EndOfDocumentToken, None)])

    def test_KeywordToWordTokenMissmatch(self) -> None:
        tokenStream = Tokenizer.GetVHDLTokenizer(self.code)
        tokenIterator = iter(tokenStream)
        token = next(tokenIterator)
        self.assertIsInstance(
            token,
            StartOfDocumentToken,
            msg=
            "Token has not expected type.\n  Actual:   {actual}     pos={pos!s}\n  Expected: {expected}"
            .format(actual=token.__class__.__qualname__,
                    pos=token.Start,
                    expected=StartOfDocumentToken.__qualname__))

        token = next(tokenIterator)
        keywordToken = token
        self.assertIsInstance(
            token,
            WordToken,
            msg=
            "Token has not expected type.\n  Actual:   {actual}     pos={pos!s}\n  Expected: {expected}"
            .format(actual=token.__class__.__qualname__,
                    pos=token.Start,
                    expected=StartOfDocumentToken.__qualname__))
        self.assertTrue(
            token == "keyword",
            msg=
            "The token's value does not match.\n  Context:  {context}\n  Actual:   {actual}\n  Expected: {expected}"
            .format(context="at {pos!s}".format(pos=token.Start),
                    actual="'{token!r}' of {type}".format(
                        token=token, type=token.__class__.__qualname__),
                    expected="'{value}' of {type}".format(
                        value="keyword", type=WordToken.__qualname__)))

        token = next(tokenIterator)
        self.assertIsInstance(
            token,
            EndOfDocumentToken,
            msg=
            "Token has not expected type.\n  Actual:   {actual}     pos={pos!s}\n  Expected: {expected}"
            .format(actual=token.__class__.__qualname__,
                    pos=token.Start,
                    expected=EndOfDocumentToken.__qualname__))

        with self.assertRaises(TokenizerException) as ex:
            _ = EntityKeyword(keywordToken)
コード例 #22
0
class SimplePackage_MultiLine_LongForm_WithSingleGeneric_TypoInGeneric(TestCase, ExpectedDataMixin, TokenLinking):
	code = dedent("""\
		package p is
			gen (
				G : integer
			;
		end	package e;
		""")
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "package"),
			(SpaceToken,           " "),
			(WordToken,            "p"),
			(SpaceToken,           " "),
			(WordToken,            "is"),
			(LinebreakToken,       None),
			(IndentationToken,     "\t"),
			(WordToken,            "gen"),
			(SpaceToken,           " "),
			(CharacterToken,       "("),
			(LinebreakToken,       None),
			(IndentationToken,     "\t\t"),
			(WordToken,            "G"),
			(SpaceToken,           " "),
			(CharacterToken,       ":"),
			(SpaceToken,           " "),
			(WordToken,            "integer"),
			(LinebreakToken,       None),
			(IndentationToken,     "\t"),
			(CharacterToken,       ")"),
			(CharacterToken,       ";"),
			(LinebreakToken,       None),
			(WordToken,            "end"),
			(SpaceToken,           " "),
			(WordToken,            "package"),
			(SpaceToken,           " "),
			(WordToken,            "p"),
			(CharacterToken,       ";"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),             #
			(Package.NameBlock,     "package p is"),    # package e is
			(WhitespaceBlock,      " "),              #
			(Package.EndBlock,      "end package p;"),  # end package a;
			(EndOfDocumentBlock,   None)              #
		]
	)
コード例 #23
0
ファイル: Tokens.py プロジェクト: Paebbels/pyVHDLParser
class Sequence_3(TestCase, ExpectedDataMixin, TokenSequence):
    code = """abc\n123\n456.789\n'Z'\n"Hallo"\n\\foo\\\n-- comment\n/* comment */\n;\n  \nabc\r\n123\r\n456.789\r\n'Z'\r\n"Hallo"\r\n\\foo\\\r\n-- comment\r\n/* comment */\r\n;\r\n  \r\n\tabc """
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None),
        (WordToken, "abc"),
        (LinebreakToken, None),
        (IntegerLiteralToken, "123"),
        (LinebreakToken, None),
        (RealLiteralToken, "456.789"),
        (LinebreakToken, None),
        (CharacterLiteralToken, "Z"),
        (LinebreakToken, None),
        (StringLiteralToken, "Hallo"),
        (LinebreakToken, None),
        (ExtendedIdentifier, "\\foo\\"),
        (LinebreakToken, None),
        (SingleLineCommentToken, "-- comment\n"),
        #			(LinebreakToken,          None),
        (MultiLineCommentToken, "/* comment */"),
        (LinebreakToken, None),
        (CharacterToken, ";"),
        (LinebreakToken, None),
        (IndentationToken, "  "),
        (LinebreakToken, None),
        (WordToken, "abc"),
        (LinebreakToken, None),
        (IntegerLiteralToken, "123"),
        (LinebreakToken, None),
        (RealLiteralToken, "456.789"),
        (LinebreakToken, None),
        (CharacterLiteralToken, "Z"),
        (LinebreakToken, None),
        (StringLiteralToken, "Hallo"),
        (LinebreakToken, None),
        (ExtendedIdentifier, "\\foo\\"),
        (LinebreakToken, None),
        (SingleLineCommentToken, "-- comment\r\n"),
        #			(LinebreakToken,          None),
        (MultiLineCommentToken, "/* comment */"),
        (LinebreakToken, None),
        (CharacterToken, ";"),
        (LinebreakToken, None),
        (IndentationToken, "  "),
        (LinebreakToken, None),
        (IndentationToken, "\t"),
        (WordToken, "abc"),
        (SpaceToken, " "),
        (EndOfDocumentToken, None)
    ])
コード例 #24
0
class SimplePackageBody_AllLine_LongForm(TestCase, ExpectedDataMixin, TokenLinking, TokenSequence):
	code = "package\nbody\np\nis\nend\npackage\nbody\np\n;\n"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "package"),
			(LinebreakToken,       "\n"),
			(WordToken,            "body"),
			(LinebreakToken,       "\n"),
			(WordToken,            "p"),
			(LinebreakToken,       "\n"),
			(WordToken,            "is"),
			(LinebreakToken,       "\n"),
			(WordToken,            "end"),
			(LinebreakToken,       "\n"),
			(WordToken,            "package"),
			(LinebreakToken,       "\n"),
			(WordToken,            "body"),
			(LinebreakToken,       "\n"),
			(WordToken,            "p"),
			(LinebreakToken,       "\n"),
			(CharacterToken,       ";"),
			(LinebreakToken,       "\n"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock,  None),
			(PackageBody.NameBlock, "package"),
			(LinebreakBlock,        "\n"),
			(PackageBody.NameBlock, "body"),
			(LinebreakBlock,        "\n"),
#			(IndentationBlock,      "\t"),
			(PackageBody.NameBlock, "p"),
			(LinebreakBlock,        "\n"),
			(PackageBody.NameBlock, "is"),
			(LinebreakBlock,        "\n"),
			(PackageBody.EndBlock,  "end\n"),
#			(LinebreakBlock,        "\n"),
			(PackageBody.EndBlock,  "package\n"),
#			(LinebreakBlock,        "\n"),
			(PackageBody.EndBlock,  "body\n"),
#			(LinebreakBlock,        "\n"),
			(PackageBody.EndBlock,  "p\n"),
#			(LinebreakBlock,        "\n"),
			(PackageBody.EndBlock,  ";"),
			(LinebreakBlock,        "\n"),
			(EndOfDocumentBlock,    None)
		]
	)
コード例 #25
0
class Library_OneLine_SingleLibrary(TestCase, ExpectedDataMixin, LinkingTests,
                                    TokenSequence, BlockSequence):
    code = "library lib0;"
    tokenStream = ExpectedTokenStream([(StartOfDocumentToken, None),
                                       (WordToken, "library"),
                                       (SpaceToken, " "), (WordToken, "lib0"),
                                       (CharacterToken, ";"),
                                       (EndOfDocumentToken, None)])
    blockStream = ExpectedBlockStream([
        (StartOfDocumentBlock, None),  #
        (Library.StartBlock, "library "),  # library
        (Library.LibraryNameBlock, "lib0"),  # lib0
        (Library.EndBlock, ";"),  # ;
        (EndOfDocumentBlock, None)  #
    ])
コード例 #26
0
ファイル: Tokens.py プロジェクト: Paebbels/pyVHDLParser
class Sequence_2(TestCase, ExpectedDataMixin, TokenSequence):
    code = """abc   \\def\\ \t 'a' "abc" /* help */ -- foo\n """
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None),
        (WordToken, "abc"),
        (SpaceToken, "   "),
        (ExtendedIdentifier, "\\def\\"),
        (SpaceToken, " \t "),
        (CharacterLiteralToken, "a"),
        (SpaceToken, " "),
        (StringLiteralToken, "abc"),
        (SpaceToken, " "),
        (MultiLineCommentToken, "/* help */"),
        (SpaceToken, " "),
        (SingleLineCommentToken, "-- foo\n"),
        (
            SpaceToken, " "
        ),  # FIXME: workaround until incomplete fused tokens are handled in Tokenizer
        (EndOfDocumentToken, None)
    ])
コード例 #27
0
class SimpleFunctionInPackage_OneLine_NoParameter(TestCase, ExpectedDataMixin,
                                                  LinkingTests, TokenSequence,
                                                  BlockSequence):
    code = "package p is function f return bit; end;"
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None), (WordToken, "package"),
        (SpaceToken, " "), (WordToken, "p"), (SpaceToken, " "),
        (WordToken, "is"), (SpaceToken, " "), (WordToken, "function"),
        (SpaceToken, " "), (WordToken, "f"), (SpaceToken, " "),
        (WordToken, "return"), (SpaceToken, " "), (WordToken, "bit"),
        (CharacterToken, ";"), (SpaceToken, " "), (WordToken, "end"),
        (CharacterToken, ";"), (EndOfDocumentToken, None)
    ])
    blockStream = ExpectedBlockStream([
        (StartOfDocumentBlock, None),  #
        (Package.NameBlock, "package p is"),  # package pis
        (WhitespaceBlock, " "),  #
        (Function.NameBlock, "function f "),
        (Function.ReturnTypeBlock, "return bit;"),
        (WhitespaceBlock, " "),  #
        (Package.EndBlock, "end;"),  # end;
        (EndOfDocumentBlock, None)  #
    ])
コード例 #28
0
ファイル: Use.py プロジェクト: Paebbels/pyVHDLParser
class Use_OneLine_SinglePackage_Const0(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "use lib0.pkg0.const0;"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "use"),
			(SpaceToken,           " "),
			(WordToken,            "lib0"),
			(CharacterToken,       "."),
			(WordToken,            "pkg0"),
			(CharacterToken,       "."),
			(WordToken,            "const0"),
			(CharacterToken,       ";"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),               #
			(Use.StartBlock,          "use "),          # use
			(Use.ReferenceNameBlock,  "lib0.pkg0.const0"), # lib0.pkg0.all
			(Use.EndBlock,            ";"),             # ;
			(EndOfDocumentBlock,      None)             #
		]
	)
コード例 #29
0
ファイル: Use.py プロジェクト: Paebbels/pyVHDLParser
class Use_MultipleLines_SinglePackage_All(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence):
	code = "use\nlib0\n.\npkg0\n.\nall\n;"
	tokenStream = ExpectedTokenStream(
		[ (StartOfDocumentToken, None),
			(WordToken,            "use"),
			(LinebreakToken,       "\n"),
			(WordToken,            "lib0"),
			(LinebreakToken,       "\n"),
			(CharacterToken,       "."),
			(LinebreakToken,       "\n"),
			(WordToken,            "pkg0"),
			(LinebreakToken,       "\n"),
			(CharacterToken,       "."),
			(LinebreakToken,       "\n"),
			(WordToken,            "all"),
			(LinebreakToken,       "\n"),
			(CharacterToken,       ";"),
			(EndOfDocumentToken,   None)
		]
	)
	blockStream = ExpectedBlockStream(
		[ (StartOfDocumentBlock, None),               #
			(Use.StartBlock,          "use"),          # use
			(LinebreakBlock,          "\n"),
			(Use.ReferenceNameBlock,  "lib0"), # lib0.pkg0.all
			(LinebreakBlock,          "\n"),
			(Use.ReferenceNameBlock,  "."), # lib0.pkg0.all
			(LinebreakBlock,          "\n"),
			(Use.ReferenceNameBlock,  "pkg0"), # lib0.pkg0.all
			(LinebreakBlock,          "\n"),
			(Use.ReferenceNameBlock,  "."), # lib0.pkg0.all
			(LinebreakBlock,          "\n"),
			(Use.ReferenceNameBlock,  "all\n"), # lib0.pkg0.all
			(Use.EndBlock,            ";"),             # ;
			(EndOfDocumentBlock,      None)             #
		]
	)
コード例 #30
0
ファイル: Context.py プロジェクト: Paebbels/pyVHDLParser
class Library_OneLine_SingleLibrary(TestCase, ExpectedDataMixin, LinkingTests,
                                    TokenSequence, BlockSequence):
    code = "context ctx is use lib0.pkg0.all; end context;"
    tokenStream = ExpectedTokenStream([
        (StartOfDocumentToken, None), (WordToken, "context"),
        (SpaceToken, " "), (WordToken, "ctx"), (SpaceToken, " "),
        (WordToken, "is"), (SpaceToken, " "), (WordToken, "use"),
        (SpaceToken, " "), (WordToken, "lib0"), (CharacterToken, "."),
        (WordToken, "pkg0"), (CharacterToken, "."), (WordToken, "all"),
        (CharacterToken, ";"), (SpaceToken, " "), (WordToken, "end"),
        (SpaceToken, " "), (WordToken, "context"), (CharacterToken, ";"),
        (EndOfDocumentToken, None)
    ])
    blockStream = ExpectedBlockStream([
        (StartOfDocumentBlock, None),  #
        (Context.NameBlock, "context ctx is"),  #
        (WhitespaceBlock, " "),
        (Use.StartBlock, "use "),  # use
        (Use.ReferenceNameBlock, "lib0.pkg0.all"),  # lib0.pkg0.all
        (Use.EndBlock, ";"),  # ;
        (WhitespaceBlock, " "),
        (Context.EndBlock, "end context;"),
        (EndOfDocumentBlock, None)  #
    ])