From 1b9c88508d1eba2c9b43155b9d95dd0b6c2993e2 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 28 Mar 2023 21:23:20 +0200 Subject: [PATCH 01/15] Checked checkboxes for features from pyVHDLModel. --- doc/Concepts.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Concepts.rst b/doc/Concepts.rst index 21dc484ec..5c99a684b 100644 --- a/doc/Concepts.rst +++ b/doc/Concepts.rst @@ -51,9 +51,9 @@ streaming-parser implemented with Python generators. 7. Build dependencies - * :fa:`square-o` Analyze order + * :fa:`check-square-o` Analyze order * :fa:`square-o` Type hierarchy - * :fa:`square-o` Instance hierarchy + * :fa:`check-square-o` Instance hierarchy 8. Checkers From 416bde3913698be269f253cd35aa2a5c07832f0d Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 29 Mar 2023 00:09:04 +0200 Subject: [PATCH 02/15] Bumped version to v0.9.0. --- pyVHDLParser/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyVHDLParser/__init__.py b/pyVHDLParser/__init__.py index e6f696c86..ad4ab1c75 100644 --- a/pyVHDLParser/__init__.py +++ b/pyVHDLParser/__init__.py @@ -34,7 +34,7 @@ __email__ = "Paebbels@gmail.com" __copyright__ = "Copyright 2017-2023 Patrick Lehmann - Boetzingen, Germany\nCopyright 2016-2017 Patrick Lehmann - Dresden, Germany" __license__ = "Apache License, Version 2.0" -__version__ = "0.8.0" +__version__ = "0.9.0" __keywords__ = ["parser", "vhdl", "code generator", "hdl"] from pyTooling.Decorators import export From 87ffae758e3e51791e9e22f99de3ec009f6d1ee0 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 2 Apr 2023 22:04:13 +0200 Subject: [PATCH 03/15] Renamed some packages. --- doc/BlockStream/index.rst | 4 +- doc/DocumentObjectModel/index.rst | 4 +- doc/GroupStream/index.rst | 4 +- doc/TokenStream/index.rst | 50 +- .../Blocks/Assignment/SignalAssignment.py | 2 +- .../Blocks/Assignment/VariableAssignment.py | 2 +- .../Blocks/Attribute/AttributeDeclaration.py | 2 +- .../Attribute/AttributeSpecification.py | 2 +- pyVHDLParser/Blocks/Comment.py | 2 +- pyVHDLParser/Blocks/ControlStructure/Case.py | 6 +- pyVHDLParser/Blocks/ControlStructure/Exit.py | 4 +- .../Blocks/ControlStructure/ForLoop.py | 6 +- pyVHDLParser/Blocks/ControlStructure/If.py | 6 +- pyVHDLParser/Blocks/ControlStructure/Next.py | 4 +- pyVHDLParser/Blocks/ControlStructure/Null.py | 4 +- .../Blocks/ControlStructure/Return.py | 4 +- .../Blocks/ControlStructure/WhileLoop.py | 4 +- pyVHDLParser/Blocks/Exception.py | 29 - pyVHDLParser/Blocks/Expression.py | 2 +- pyVHDLParser/Blocks/Generate/CaseGenerate.py | 2 +- pyVHDLParser/Blocks/Generate/ForGenerate.py | 2 +- pyVHDLParser/Blocks/Generate/IfGenerate.py | 2 +- pyVHDLParser/Blocks/Generate/__init__.py | 2 +- pyVHDLParser/Blocks/Generic.py | 673 ++++++++++-------- pyVHDLParser/Blocks/Generic1.py | 395 ---------- .../Instantiation/EntityInstantiation.py | 2 +- .../Instantiation/FunctionInstantiation.py | 2 +- .../Instantiation/PackageInstantiation.py | 2 +- .../Instantiation/ProcedureInstantiation.py | 2 +- pyVHDLParser/Blocks/InterfaceObject.py | 2 +- pyVHDLParser/Blocks/List/GenericList.py | 4 +- pyVHDLParser/Blocks/List/GenericMapList.py | 2 +- pyVHDLParser/Blocks/List/ParameterList.py | 4 +- pyVHDLParser/Blocks/List/PortList.py | 4 +- pyVHDLParser/Blocks/List/PortMapList.py | 2 +- pyVHDLParser/Blocks/List/SensitivityList.py | 2 +- pyVHDLParser/Blocks/Object/Constant.py | 2 +- pyVHDLParser/Blocks/Object/SharedVariable.py | 2 +- pyVHDLParser/Blocks/Object/Signal.py | 2 +- pyVHDLParser/Blocks/Object/Variable.py | 2 +- pyVHDLParser/Blocks/Object/__init__.py | 4 +- pyVHDLParser/Blocks/Reference/Context.py | 4 +- pyVHDLParser/Blocks/Reference/Library.py | 2 +- pyVHDLParser/Blocks/Reference/Use.py | 2 +- pyVHDLParser/Blocks/Region.py | 278 ++++++++ pyVHDLParser/Blocks/Reporting/Assert.py | 2 +- pyVHDLParser/Blocks/Reporting/Report.py | 2 +- pyVHDLParser/Blocks/Sequential/Function.py | 6 +- pyVHDLParser/Blocks/Sequential/Package.py | 6 +- pyVHDLParser/Blocks/Sequential/PackageBody.py | 6 +- pyVHDLParser/Blocks/Sequential/Procedure.py | 6 +- pyVHDLParser/Blocks/Sequential/Process.py | 6 +- .../Blocks/Structural/Architecture.py | 6 +- pyVHDLParser/Blocks/Structural/Block.py | 4 +- pyVHDLParser/Blocks/Structural/Component.py | 4 +- .../Blocks/Structural/Configuration.py | 4 +- pyVHDLParser/Blocks/Structural/Entity.py | 6 +- pyVHDLParser/Blocks/Type/Subtype.py | 2 +- pyVHDLParser/Blocks/Type/Type.py | 2 +- .../Blocks/{Common.py => Whitespace.py} | 180 ++--- pyVHDLParser/Blocks/__init__.py | 6 +- pyVHDLParser/CLI/Block.py | 2 +- pyVHDLParser/Filters/Comment.py | 2 +- pyVHDLParser/Groups/Comment.py | 2 +- pyVHDLParser/Groups/DesignUnit.py | 2 +- pyVHDLParser/Groups/List.py | 2 +- pyVHDLParser/Groups/Sequential/Function.py | 2 +- pyVHDLParser/Groups/Sequential/Procedure.py | 2 +- pyVHDLParser/Groups/Sequential/Process.py | 2 +- pyVHDLParser/Groups/__init__.py | 2 +- pyVHDLParser/__init__.py | 2 + test/BlockParserTests/ArchitectureTest.py | 2 +- test/BlockParserTests/EntityTest.py | 2 +- test/BlockParserTests/GenericListTest.py | 2 +- test/BlockParserTests/LibraryTest.py | 2 +- test/BlockParserTests/PackageBodyTest.py | 2 +- test/BlockParserTests/PackageTest.py | 2 +- test/BlockParserTests/PortListTest.py | 2 +- test/BlockParserTests/ProcessTest.py | 2 +- test/BlockParserTests/UseTest.py | 2 +- .../unit/SimpleBlockSequences/Architecture.py | 2 +- tests/unit/SimpleBlockSequences/Assert.py | 2 +- tests/unit/SimpleBlockSequences/Constant.py | 2 +- tests/unit/SimpleBlockSequences/Context.py | 2 +- tests/unit/SimpleBlockSequences/Entity.py | 2 +- tests/unit/SimpleBlockSequences/Function.py | 2 +- tests/unit/SimpleBlockSequences/Package.py | 2 +- .../unit/SimpleBlockSequences/PackageBody.py | 2 +- tests/unit/SimpleBlockSequences/PortList.py | 2 +- tests/unit/SimpleBlockSequences/Procedure.py | 2 +- tests/unit/SimpleBlockSequences/Process.py | 2 +- tests/unit/SimpleBlockSequences/Signal.py | 2 +- tests/unit/SimpleBlockSequences/Use.py | 2 +- 93 files changed, 918 insertions(+), 937 deletions(-) delete mode 100644 pyVHDLParser/Blocks/Exception.py delete mode 100644 pyVHDLParser/Blocks/Generic1.py create mode 100644 pyVHDLParser/Blocks/Region.py rename pyVHDLParser/Blocks/{Common.py => Whitespace.py} (98%) diff --git a/doc/BlockStream/index.rst b/doc/BlockStream/index.rst index dea20c7ea..e022b8c9f 100644 --- a/doc/BlockStream/index.rst +++ b/doc/BlockStream/index.rst @@ -1,7 +1,7 @@ .. _blkstm: -2. Pass - Blocks -################ +2. Pass - Tokens ⇒ Blocks +######################### In the :ref:`second pass ` a stream of double-linked :class:`~pyVHDLParser.Token.Token` objects is read and grouped in another Python diff --git a/doc/DocumentObjectModel/index.rst b/doc/DocumentObjectModel/index.rst index 94c08f247..01ab1fbea 100644 --- a/doc/DocumentObjectModel/index.rst +++ b/doc/DocumentObjectModel/index.rst @@ -1,5 +1,5 @@ -4. Pass - Code-DOM -################## +4. Pass - Groups ⇒ Code-DOM +########################### A Code-DOM is a Document-Object-Model for source code files. diff --git a/doc/GroupStream/index.rst b/doc/GroupStream/index.rst index 9c599ca4a..7e7ac9b33 100644 --- a/doc/GroupStream/index.rst +++ b/doc/GroupStream/index.rst @@ -1,7 +1,7 @@ .. _grpstm: -3. Pass - Groups -################ +3. Pass - Blocks ⇒ Groups +######################### In the :ref:`third pass ` a stream of double-linked :class:`~pyVHDLParser.Block.Block` objects is read and grouped in another Python diff --git a/doc/TokenStream/index.rst b/doc/TokenStream/index.rst index d5094acd4..ea5c47293 100644 --- a/doc/TokenStream/index.rst +++ b/doc/TokenStream/index.rst @@ -1,46 +1,54 @@ .. _tokstm: -1. Pass - Tokens -################ +1. Pass - String ⇒ Tokens +######################### -In the :ref:`first pass ` a source file is sliced into a chain -of double-linked objects of base-class :class:`~pyVHDLParser.Token.Token`. While -token creation, the start and end position of a token is preserved as a -:class:`~pyVHDLParser.SourceCodePosition` object within each token. +In the :ref:`first pass ` a source file (string) is sliced into a chain of double-linked token objects +of base-class :class:`~pyVHDLParser.Token.Token`. While creating tokens, the start and end position of the token is +preserved as two :class:`~pyVHDLParser.SourceCodePosition` object within each token. -In contrast to ordinary parsers, pyVHDLParser preserves cases, whitespaces (space, -tab, ...), linebreaks and comments. +In contrast to ordinary lexers/parsers, pyVHDLParser preserves cases, whitespaces (space, tab, ...), linebreaks and +comments. **Condensed definition of class** :class:`~pyVHDLParser.SourceCodePosition`: .. code-block:: Python - @Export - class SourceCodePosition: + @export + class SourceCodePosition(metaclass=ExtendedType, useSlots=True): """Represent a position (row, column, absolute) in a source code file.""" - Row : int = None #: Row in the source code file - Column : int = None #: Column (character) in the source code file's line - Absolute : int = None #: Absolute character position regardless of linebreaks. + + Row: int #: Row in the source code file (starting at 1) + Column: int #: Column (character) in the source code file's line (starting at 1) + Absolute: int #: Absolute character position regardless of linebreaks. **Condensed definition of class** :class:`~pyVHDLParser.Token.Token`: .. code-block:: Python - @Export - class Token: + @export + class Token(metaclass=ExtendedType, useSlots=True): """Base-class for all token classes.""" - _previousToken : Token = None #: Reference to the previous token - _NextToken : Token = None #: Reference to the next token - Start : SourceCodePosition = None #: Position for the token start - End : SourceCodePosition = None #: Position for the token end + + _previousToken: Token #: Reference to the previous token (backward pointer) + NextToken: Nullable[Token] #: Reference to the next token (forward pointer) + Start: SourceCodePosition #: Position in the file for the token start + End: SourceCodePosition #: Position in the file for the token end def __init__(self, previousToken : Token, start : SourceCodePosition, end : SourceCodePosition = None): - def __len__(self): + def __len__(self) -> int: + def __iter__(self) -> Iterator[Token]: + + def GetIterator(self, inclusiveStartToken: bool = False, inclusiveStopToken: bool = True, stopToken: Token = None) -> Iterator[Token]: + def GetReverseIterator(self, inclusiveStartToken: bool = False, inclusiveStopToken: bool = True, stopToken: Token = None) -> Iterator[Token]: + + @property + def PreviousToken(self) -> Token: @property - def PreviousToken(self): + def Length(self) -> int: diff --git a/pyVHDLParser/Blocks/Assignment/SignalAssignment.py b/pyVHDLParser/Blocks/Assignment/SignalAssignment.py index 5cd70e292..3050cdb8a 100644 --- a/pyVHDLParser/Blocks/Assignment/SignalAssignment.py +++ b/pyVHDLParser/Blocks/Assignment/SignalAssignment.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/Assignment/VariableAssignment.py b/pyVHDLParser/Blocks/Assignment/VariableAssignment.py index 5cd70e292..3050cdb8a 100644 --- a/pyVHDLParser/Blocks/Assignment/VariableAssignment.py +++ b/pyVHDLParser/Blocks/Assignment/VariableAssignment.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/Attribute/AttributeDeclaration.py b/pyVHDLParser/Blocks/Attribute/AttributeDeclaration.py index b8ff20fa8..35850a8c6 100644 --- a/pyVHDLParser/Blocks/Attribute/AttributeDeclaration.py +++ b/pyVHDLParser/Blocks/Attribute/AttributeDeclaration.py @@ -33,7 +33,7 @@ from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @export diff --git a/pyVHDLParser/Blocks/Attribute/AttributeSpecification.py b/pyVHDLParser/Blocks/Attribute/AttributeSpecification.py index c12679208..f1915cad6 100644 --- a/pyVHDLParser/Blocks/Attribute/AttributeSpecification.py +++ b/pyVHDLParser/Blocks/Attribute/AttributeSpecification.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, WordToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/Comment.py b/pyVHDLParser/Blocks/Comment.py index 0e2fd9ebb..c85729d03 100644 --- a/pyVHDLParser/Blocks/Comment.py +++ b/pyVHDLParser/Blocks/Comment.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, IndentationToken from pyVHDLParser.Token.Keywords import SingleLineCommentKeyword, MultiLineCommentStartKeyword, MultiLineCommentEndKeyword from pyVHDLParser.Blocks import CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import IndentationBlock +from pyVHDLParser.Blocks.Whitespace import IndentationBlock @export diff --git a/pyVHDLParser/Blocks/ControlStructure/Case.py b/pyVHDLParser/Blocks/ControlStructure/Case.py index fb04a0c7d..31698d617 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Case.py +++ b/pyVHDLParser/Blocks/ControlStructure/Case.py @@ -32,9 +32,9 @@ from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, CaseKeyword, WhenKeyword, IsKeyword, EndKeyword, MapAssociationKeyword from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import SequentialBeginBlock -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import SequentialBeginBlock +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedByCharORClosingRoundBracket, ExpressionBlockEndedByKeywordORClosingRoundBracket diff --git a/pyVHDLParser/Blocks/ControlStructure/Exit.py b/pyVHDLParser/Blocks/ControlStructure/Exit.py index aa7b1fa11..aa0e22204 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Exit.py +++ b/pyVHDLParser/Blocks/ControlStructure/Exit.py @@ -33,8 +33,8 @@ from pyVHDLParser.Token import WordToken, ExtendedIdentifier, CharacterToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, WhenKeyword from pyVHDLParser.Blocks import Block, TokenToBlockParser, CommentBlock, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic1 import EndOfStatementBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Generic import EndOfStatementBlock from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedBySemicolon diff --git a/pyVHDLParser/Blocks/ControlStructure/ForLoop.py b/pyVHDLParser/Blocks/ControlStructure/ForLoop.py index 914be83bf..51cb66a12 100644 --- a/pyVHDLParser/Blocks/ControlStructure/ForLoop.py +++ b/pyVHDLParser/Blocks/ControlStructure/ForLoop.py @@ -32,9 +32,9 @@ from pyVHDLParser.Token import LinebreakToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier, CharacterToken, SpaceToken from pyVHDLParser.Token.Keywords import InKeyword, ForKeyword, LoopKeyword, BoundaryToken, IdentifierToken, WordToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import SequentialBeginBlock -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import SequentialBeginBlock +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedByKeywordORClosingRoundBracket, ExpressionBlockEndedByKeywordOrToOrDownto diff --git a/pyVHDLParser/Blocks/ControlStructure/If.py b/pyVHDLParser/Blocks/ControlStructure/If.py index 7eaef87c5..fb10e1947 100644 --- a/pyVHDLParser/Blocks/ControlStructure/If.py +++ b/pyVHDLParser/Blocks/ControlStructure/If.py @@ -32,9 +32,9 @@ from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, IfKeyword, ThenKeyword, ElsIfKeyword, ElseKeyword from pyVHDLParser.Blocks import Block, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import SequentialBeginBlock -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import SequentialBeginBlock +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedByKeywordORClosingRoundBracket diff --git a/pyVHDLParser/Blocks/ControlStructure/Next.py b/pyVHDLParser/Blocks/ControlStructure/Next.py index df64c9efe..1efa27b25 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Next.py +++ b/pyVHDLParser/Blocks/ControlStructure/Next.py @@ -33,8 +33,8 @@ from pyVHDLParser.Token import WordToken, ExtendedIdentifier, CharacterToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, WhenKeyword from pyVHDLParser.Blocks import Block, TokenToBlockParser, CommentBlock, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic1 import EndOfStatementBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Generic import EndOfStatementBlock from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedBySemicolon diff --git a/pyVHDLParser/Blocks/ControlStructure/Null.py b/pyVHDLParser/Blocks/ControlStructure/Null.py index 7851db70a..f2d9deb45 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Null.py +++ b/pyVHDLParser/Blocks/ControlStructure/Null.py @@ -33,8 +33,8 @@ from pyVHDLParser.Token import CharacterToken from pyVHDLParser.Token.Keywords import BoundaryToken, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser, CommentBlock, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic1 import EndOfStatementBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Generic import EndOfStatementBlock @export diff --git a/pyVHDLParser/Blocks/ControlStructure/Return.py b/pyVHDLParser/Blocks/ControlStructure/Return.py index c3743a144..9bb3733c8 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Return.py +++ b/pyVHDLParser/Blocks/ControlStructure/Return.py @@ -32,8 +32,8 @@ from pyVHDLParser.Token import CommentToken, CharacterToken, SpaceToken, LinebreakToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import BoundaryToken, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser, BlockParserException, CommentBlock -from pyVHDLParser.Blocks.Generic1 import EndOfStatementBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Generic import EndOfStatementBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedBySemicolon diff --git a/pyVHDLParser/Blocks/ControlStructure/WhileLoop.py b/pyVHDLParser/Blocks/ControlStructure/WhileLoop.py index 4e43b5d4c..0aae452e3 100644 --- a/pyVHDLParser/Blocks/ControlStructure/WhileLoop.py +++ b/pyVHDLParser/Blocks/ControlStructure/WhileLoop.py @@ -34,9 +34,9 @@ from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, GenericKeyword, PortKeyword from pyVHDLParser.Token.Parser import SpaceToken, WordToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock -from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Region import EndBlock as EndBlockBase from pyVHDLParser.Blocks.List import GenericList, PortList diff --git a/pyVHDLParser/Blocks/Exception.py b/pyVHDLParser/Blocks/Exception.py deleted file mode 100644 index d936f6829..000000000 --- a/pyVHDLParser/Blocks/Exception.py +++ /dev/null @@ -1,29 +0,0 @@ -# ==================================================================================================================== # -# __ ___ _ ____ _ ____ # -# _ __ _ \ \ / / | | | _ \| | | _ \ __ _ _ __ ___ ___ _ __ # -# | '_ \| | | \ \ / /| |_| | | | | | | |_) / _` | '__/ __|/ _ \ '__| # -# | |_) | |_| |\ V / | _ | |_| | |___| __/ (_| | | \__ \ __/ | # -# | .__/ \__, | \_/ |_| |_|____/|_____|_| \__,_|_| |___/\___|_| # -# |_| |___/ # -# ==================================================================================================================== # -# Authors: # -# Patrick Lehmann # -# # -# License: # -# ==================================================================================================================== # -# Copyright 2017-2023 Patrick Lehmann - Boetzingen, Germany # -# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -# ==================================================================================================================== # -# diff --git a/pyVHDLParser/Blocks/Expression.py b/pyVHDLParser/Blocks/Expression.py index 9f295bcc1..fd6f17202 100644 --- a/pyVHDLParser/Blocks/Expression.py +++ b/pyVHDLParser/Blocks/Expression.py @@ -39,7 +39,7 @@ from pyVHDLParser.Token.Keywords import NotOperator, AbsOperator, OpeningRoundBracketToken, BoundaryToken, ClosingRoundBracketToken, IdentifierToken from pyVHDLParser.Token.Keywords import LoopKeyword, ToKeyword, DowntoKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser, BlockParserException, CommentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @export diff --git a/pyVHDLParser/Blocks/Generate/CaseGenerate.py b/pyVHDLParser/Blocks/Generate/CaseGenerate.py index d4cc7671c..887c07756 100644 --- a/pyVHDLParser/Blocks/Generate/CaseGenerate.py +++ b/pyVHDLParser/Blocks/Generate/CaseGenerate.py @@ -33,7 +33,7 @@ from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, GenericKeyword, PortKeyword from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, IndentationToken from pyVHDLParser.Blocks import Block, BlockParserException, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock from pyVHDLParser.Blocks.Generate import EndGenerateBlock as EndGenerateBlockBase from pyVHDLParser.Blocks.List import GenericList, PortList diff --git a/pyVHDLParser/Blocks/Generate/ForGenerate.py b/pyVHDLParser/Blocks/Generate/ForGenerate.py index 11131415c..6868a9a62 100644 --- a/pyVHDLParser/Blocks/Generate/ForGenerate.py +++ b/pyVHDLParser/Blocks/Generate/ForGenerate.py @@ -33,7 +33,7 @@ from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, BeginKeyword, ProcessKeyword, AssertKeyword from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, GenericKeyword, PortKeyword from pyVHDLParser.Blocks import Block, BlockParserException, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock from pyVHDLParser.Blocks.Generate import EndGenerateBlock as EndGenerateBlockBase from pyVHDLParser.Blocks.List import GenericList, PortList diff --git a/pyVHDLParser/Blocks/Generate/IfGenerate.py b/pyVHDLParser/Blocks/Generate/IfGenerate.py index dc420a789..c5ffd145b 100644 --- a/pyVHDLParser/Blocks/Generate/IfGenerate.py +++ b/pyVHDLParser/Blocks/Generate/IfGenerate.py @@ -34,7 +34,7 @@ from pyVHDLParser.Token.Keywords import BeginKeyword, ProcessKeyword, AssertKeyword from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, GenericKeyword, PortKeyword from pyVHDLParser.Blocks import Block, BlockParserException, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock from pyVHDLParser.Blocks.Generate import EndGenerateBlock as EndGenerateBlockBase from pyVHDLParser.Blocks.List import GenericList, PortList diff --git a/pyVHDLParser/Blocks/Generate/__init__.py b/pyVHDLParser/Blocks/Generate/__init__.py index ed0e36860..3ef657aa2 100644 --- a/pyVHDLParser/Blocks/Generate/__init__.py +++ b/pyVHDLParser/Blocks/Generate/__init__.py @@ -30,7 +30,7 @@ from pyTooling.Decorators import export from pyVHDLParser.Token.Keywords import GenerateKeyword -from pyVHDLParser.Blocks.Generic import EndBlock +from pyVHDLParser.Blocks.Region import EndBlock @export diff --git a/pyVHDLParser/Blocks/Generic.py b/pyVHDLParser/Blocks/Generic.py index 37d45df7a..9bea11015 100644 --- a/pyVHDLParser/Blocks/Generic.py +++ b/pyVHDLParser/Blocks/Generic.py @@ -1,278 +1,395 @@ -# ==================================================================================================================== # -# __ ___ _ ____ _ ____ # -# _ __ _ \ \ / / | | | _ \| | | _ \ __ _ _ __ ___ ___ _ __ # -# | '_ \| | | \ \ / /| |_| | | | | | | |_) / _` | '__/ __|/ _ \ '__| # -# | |_) | |_| |\ V / | _ | |_| | |___| __/ (_| | | \__ \ __/ | # -# | .__/ \__, | \_/ |_| |_|____/|_____|_| \__,_|_| |___/\___|_| # -# |_| |___/ # -# ==================================================================================================================== # -# Authors: # -# Patrick Lehmann # -# # -# License: # -# ==================================================================================================================== # -# Copyright 2017-2023 Patrick Lehmann - Boetzingen, Germany # -# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -# ==================================================================================================================== # -# -from typing import Any - -from pyTooling.Decorators import export - -from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, IndentationToken -from pyVHDLParser.Token.Keywords import AssertKeyword, EndKeyword, ProcessKeyword, ReportKeyword, IfKeyword, ForKeyword, ReturnKeyword, NextKeyword, NullKeyword -from pyVHDLParser.Token.Keywords import ExitKeyword, UseKeyword, SignalKeyword, ConstantKeyword, SharedKeyword, FunctionKeyword, ProcedureKeyword -from pyVHDLParser.Token.Keywords import ImpureKeyword, PureKeyword, VariableKeyword, BeginKeyword, CaseKeyword -from pyVHDLParser.Blocks import BlockParserException, CommentBlock, TokenToBlockParser, MetaBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock, IndentationBlock -from pyVHDLParser.Blocks.Object.Variable import VariableDeclarationBlock -from pyVHDLParser.Blocks.Generic1 import EndBlock, BeginBlock - - -@export -class DeclarativeRegion(metaclass=MetaBlock): - """Base-class for all declarative region blocks.""" - - BEGIN_BLOCK: BeginBlock - END_BLOCK: EndBlock - - KEYWORDS: Any # TODO: what type? - - @classmethod - def __cls_init__(cls): - from pyVHDLParser.Blocks.Reference import Use - from pyVHDLParser.Blocks.Object.Constant import ConstantDeclarationBlock - from pyVHDLParser.Blocks.Sequential import Procedure, Function - - cls.KEYWORDS = { - # Keyword Transition - UseKeyword: Use.StartBlock.stateUseKeyword, - ConstantKeyword: ConstantDeclarationBlock.stateConstantKeyword, - FunctionKeyword: Function.NameBlock.stateFunctionKeyword, - ProcedureKeyword: Procedure.NameBlock.stateProcedureKeyword, - ImpureKeyword: Function.NameBlock.stateImpureKeyword, - PureKeyword: Function.NameBlock.statePureKeyword, - # AliasKeyword: Alias.NameBlock.stateAliasKeyword - } - - - @classmethod - def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, SpaceToken): - blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock - parserState.NewBlock = blockType(parserState.LastBlock, token) - parserState.TokenMarker = None - return - elif isinstance(token, LinebreakToken): - 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, WordToken): - tokenValue = token.Value.lower() - - for keyword in cls.KEYWORDS: - if tokenValue == keyword.__KEYWORD__: - newToken = keyword(fromExistingToken=token) - parserState.PushState = cls.KEYWORDS[keyword] - parserState.NewToken = newToken - parserState.TokenMarker = newToken - return - - if tokenValue == "begin": - parserState.NewToken = BeginKeyword(fromExistingToken=token) - parserState.NewBlock = cls.BEGIN_BLOCK(parserState.LastBlock, parserState.NewToken) - parserState.NextState = cls.BEGIN_BLOCK.stateStatementRegion - return - elif tokenValue == "end": - parserState.NewToken = EndKeyword(fromExistingToken=token) - parserState.NextState = cls.END_BLOCK.stateEndKeyword - return - - raise BlockParserException( - "Expected one of these keywords: BEGIN, END, {keywords}. Found: '{tokenValue}'.".format( - keywords=", ".join( - [kw.__KEYWORD__.upper() for kw in cls.KEYWORDS] - ), - tokenValue=token.Value - ), token) - - -@export -class ConcurrentDeclarativeRegion(DeclarativeRegion): - """Base-class for all concurrent declarative region blocks.""" - - @classmethod - def __cls_init__(cls): - super().__cls_init__() - - from pyVHDLParser.Blocks.Object.Signal import SignalDeclarationBlock - from pyVHDLParser.Blocks.Object.SharedVariable import SharedVariableDeclarationBlock - - cls.KEYWORDS.update({ - # Keyword Transition - SignalKeyword: SignalDeclarationBlock.stateSignalKeyword, - SharedKeyword: SharedVariableDeclarationBlock.stateSharedKeyword - }) - - -@export -class SequentialDeclarativeRegion(DeclarativeRegion): - """Base-class for all sequential declarative region blocks.""" - - @classmethod - def __cls_init__(cls): - super().__cls_init__() - - # TODO: use key assignment: a[b] = c - cls.KEYWORDS.update({ - # Keyword Transition - VariableKeyword: VariableDeclarationBlock.stateVariableKeyword - }) - - -@export -class ConcurrentBeginBlock(BeginBlock): - @classmethod - def __cls_init__(cls): - from pyVHDLParser.Blocks.Sequential import Process - from pyVHDLParser.Blocks.Reporting.Assert import AssertBlock - - cls.KEYWORDS = { - # Keyword Transition - AssertKeyword: AssertBlock.stateAssertKeyword, - ProcessKeyword: Process.OpenBlock.stateProcessKeyword, - } - - @classmethod - def stateStatementRegion(cls, parserState: TokenToBlockParser): - parserState.NextState = cls.stateConcurrentRegion - parserState.NextState(parserState) - - @classmethod - def stateConcurrentRegion(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, SpaceToken): - blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock - parserState.NewBlock = blockType(parserState.LastBlock, token) - parserState.TokenMarker = None - return - elif isinstance(token, (LinebreakToken, CommentToken)): - block = LinebreakBlock if isinstance(token, LinebreakToken) else CommentBlock - parserState.NewBlock = block(parserState.LastBlock, token) - parserState.TokenMarker = None - return - elif isinstance(token, WordToken): - tokenValue = token.Value.lower() - - for keyword in cls.KEYWORDS: - if tokenValue == keyword.__KEYWORD__: - newToken = keyword(fromExistingToken=token) - parserState.PushState = cls.KEYWORDS[keyword] - parserState.NewToken = newToken - parserState.TokenMarker = newToken - return - - if tokenValue == "end": - parserState.NewToken = EndKeyword(fromExistingToken=token) - parserState.NextState = cls.END_BLOCK.stateEndKeyword - return - - raise BlockParserException( - "Expected one of these keywords: END, {keywords}. Found: '{tokenValue}'.".format( - keywords=", ".join( - [kw.__KEYWORD__.upper() for kw in cls.KEYWORDS] - ), - tokenValue=token.Value - ), token) - - -@export -class SequentialBeginBlock(BeginBlock): - @classmethod - def __cls_init__(cls): - from pyVHDLParser.Blocks.ControlStructure.If import IfConditionBlock - from pyVHDLParser.Blocks.ControlStructure.Case import CaseBlock - from pyVHDLParser.Blocks.ControlStructure.Exit import ExitBlock - from pyVHDLParser.Blocks.ControlStructure.Next import NextBlock - from pyVHDLParser.Blocks.ControlStructure.Return import ReturnBlock - from pyVHDLParser.Blocks.ControlStructure.ForLoop import IteratorBlock - # from pyVHDLParser.Blocks.ControlStructure.WhileLoop import ConditionBlock - from pyVHDLParser.Blocks.Reporting.Report import ReportBlock - from pyVHDLParser.Blocks.ControlStructure.Null import NullBlock - - cls.KEYWORDS = { - # Keyword Transition - IfKeyword: IfConditionBlock.stateIfKeyword, - CaseKeyword: CaseBlock.stateCaseKeyword, - ForKeyword: IteratorBlock.stateForKeyword, - # WhileKeyword: ConditionBlock.stateWhileKeyword, - ReturnKeyword: ReturnBlock.stateReturnKeyword, - NextKeyword: NextBlock.stateNextKeyword, - ExitKeyword: ExitBlock.stateExitKeyword, - ReportKeyword: ReportBlock.stateReportKeyword, - NullKeyword: NullBlock.stateNullKeyword - } - - @classmethod - def stateStatementRegion(cls, parserState: TokenToBlockParser): - cls.stateAnyRegion(parserState) - - @classmethod - def stateSequentialRegion(cls, parserState: TokenToBlockParser): - cls.stateAnyRegion(parserState) - - @classmethod - def stateAnyRegion(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, SpaceToken): - blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock - parserState.NewBlock = blockType(parserState.LastBlock, token) - parserState.TokenMarker = None - return - elif isinstance(token, (LinebreakToken, CommentToken)): - block = LinebreakBlock if isinstance(token, LinebreakToken) else CommentBlock - parserState.NewBlock = block(parserState.LastBlock, token) - parserState.TokenMarker = None - return - elif isinstance(token, WordToken): - tokenValue = token.Value.lower() - - for keyword in cls.KEYWORDS: - if tokenValue == keyword.__KEYWORD__: - newToken = keyword(fromExistingToken=token) - parserState.PushState = cls.KEYWORDS[keyword] - parserState.NewToken = newToken - parserState.TokenMarker = newToken - return - - if tokenValue == "end": - parserState.NewToken = EndKeyword(fromExistingToken=token) - parserState.NextState = cls.END_BLOCK.stateEndKeyword - return - - raise BlockParserException( - "Expected one of these keywords: END, {keywords}. Found: '{tokenValue}' at line {tokenPositionRow}:{tokenPositionColumn}.".format( - keywords=", ".join( - [kw.__KEYWORD__.upper() for kw in cls.KEYWORDS] - ), - tokenValue=token.Value, - tokenPositionRow=token.Start.Row, - tokenPositionColumn=token.Start.Column - ), token) +# ==================================================================================================================== # +# __ ___ _ ____ _ ____ # +# _ __ _ \ \ / / | | | _ \| | | _ \ __ _ _ __ ___ ___ _ __ # +# | '_ \| | | \ \ / /| |_| | | | | | | |_) / _` | '__/ __|/ _ \ '__| # +# | |_) | |_| |\ V / | _ | |_| | |___| __/ (_| | | \__ \ __/ | # +# | .__/ \__, | \_/ |_| |_|____/|_____|_| \__,_|_| |___/\___|_| # +# |_| |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 Patrick Lehmann - Boetzingen, Germany # +# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# ==================================================================================================================== # +# +from typing import Any + +from pyTooling.Decorators import export + +from pyVHDLParser.Token import CharacterToken, SpaceToken, LinebreakToken, CommentToken, WordToken, MultiLineCommentToken, IndentationToken +from pyVHDLParser.Token import SingleLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token.Keywords import EndToken, BoundaryToken, LabelToken, IdentifierToken +from pyVHDLParser.Blocks import FinalBlock, TokenToBlockParser, CommentBlock, BlockParserException, Block +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock + + +@export +class EndBlock(FinalBlock): + KEYWORD = None + KEYWORD_IS_OPTIONAL = False + EXPECTED_NAME = "" + EXPECTED_NAME_KIND = "keyword" # keyword label + + @classmethod + def stateEndKeyword(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, CharacterToken): + if (cls.KEYWORD_IS_OPTIONAL is True) and (token == ";"): + parserState.NewToken = EndToken(fromExistingToken=token) + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) + parserState.Pop() + return + elif isinstance(token, SpaceToken): + parserState.NewToken = BoundaryToken(fromExistingToken=token) + parserState.NextState = cls.stateWhitespace1 + return + elif isinstance(token, LinebreakToken): + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) + parserState.TokenMarker = None + parserState.NextState = cls.stateWhitespace1 + return + elif isinstance(token, CommentToken): + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) + _ = CommentBlock(parserState.NewBlock, token) + parserState.TokenMarker = None + parserState.NextState = cls.stateWhitespace1 + return + + raise BlockParserException("Expected ';' or whitespace.", token) + + @classmethod + def stateWhitespace1(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, CharacterToken): + if (cls.KEYWORD_IS_OPTIONAL is True) and (token == ";"): + parserState.NewToken = EndToken(fromExistingToken=token) + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) + parserState.Pop() + return + elif isinstance(token, WordToken): + IS_SINGLE_KEYWORD = isinstance(cls.KEYWORD, tuple) + KW = cls.KEYWORD[0] if IS_SINGLE_KEYWORD else cls.KEYWORD + if token <= KW.__KEYWORD__: + parserState.NewToken = KW(fromExistingToken=token) + parserState.NextState = cls.stateKeyword1 + elif cls.EXPECTED_NAME_KIND == "label": + parserState.NewToken = LabelToken(fromExistingToken=token) + parserState.NextState = cls.stateSimpleName + else: + parserState.NewToken = IdentifierToken(fromExistingToken=token) + parserState.NextState = cls.stateSimpleName + 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 = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) + _ = CommentBlock(parserState.NewBlock, 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(fromExistingToken=token) + parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) + parserState.TokenMarker = None + return + + if cls.KEYWORD_IS_OPTIONAL is True: + if cls.EXPECTED_NAME_KIND == "label": + errorMessage = "Expected ';', {0} keyword or {1} label.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) + else: + errorMessage = "Expected ';', {0} keyword or {1} name.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) + else: + if cls.EXPECTED_NAME_KIND == "label": + errorMessage = "Expected {0} keyword or {1} label.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) + else: + errorMessage = "Expected {0} keyword or {1} name.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) + + raise BlockParserException(errorMessage, token) + + @classmethod + def stateKeyword1(cls, parserState: TokenToBlockParser): + IS_DOUBLE_KEYWORD = isinstance(cls.KEYWORD, tuple) + nextState = cls.stateWhitespace2 if IS_DOUBLE_KEYWORD else cls.stateWhitespace3; + token = parserState.Token + if isinstance(token, CharacterToken): + if not isinstance(cls.KEYWORD, tuple) and (token == ";"): + parserState.NewToken = EndToken(fromExistingToken=token) + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) + parserState.Pop() + return + elif isinstance(token, SpaceToken): + parserState.NewToken = BoundaryToken(fromExistingToken=token) + parserState.NextState = nextState + return + elif isinstance(token, LinebreakToken): + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) + parserState.TokenMarker = None + parserState.NextState = cls.stateWhitespace3 + return + elif isinstance(token, CommentToken): + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) + _ = CommentBlock(parserState.NewBlock, token) + parserState.TokenMarker = None + parserState.NextState = cls.stateWhitespace3 + return + + raise BlockParserException("Expected ';' or whitespace.", token) + + @classmethod + def stateWhitespace2(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, CharacterToken): + if (cls.KEYWORD_IS_OPTIONAL is True) and (not isinstance(cls.KEYWORD, tuple)) and (token == ";"): + parserState.NewToken = EndToken(fromExistingToken=token) + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) + parserState.Pop() + return + elif isinstance(token, WordToken) and (token <= cls.KEYWORD[1].__KEYWORD__): + parserState.NewToken = cls.KEYWORD[1](fromExistingToken=token) + parserState.NextState = cls.stateKeyword2 + 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 = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) + _ = CommentBlock(parserState.NewBlock, 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(fromExistingToken=token) + parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) + parserState.TokenMarker = None + return + + if cls.KEYWORD_IS_OPTIONAL is True: + if cls.EXPECTED_NAME_KIND == "label": + errorMessage = "Expected ';', {0} keyword or {1} label.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) + else: + errorMessage = "Expected ';', {0} keyword or {1} name.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) + else: + if cls.EXPECTED_NAME_KIND == "label": + errorMessage = "Expected {0} keyword or {1} label.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) + else: + errorMessage = "Expected {0} keyword or {1} name.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) + + raise BlockParserException(errorMessage, token) + + @classmethod + def stateKeyword2(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, CharacterToken)and (token == ";"): + parserState.NewToken = EndToken(fromExistingToken=token) + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) + parserState.Pop() + return + elif isinstance(token, SpaceToken): + parserState.NewToken = BoundaryToken(fromExistingToken=token) + parserState.NextState = cls.stateWhitespace3 + return + elif isinstance(token, LinebreakToken): + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) + parserState.TokenMarker = None + parserState.NextState = cls.stateWhitespace3 + return + elif isinstance(token, CommentToken): + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) + _ = CommentBlock(parserState.NewBlock, token) + parserState.TokenMarker = None + parserState.NextState = cls.stateWhitespace3 + return + + raise BlockParserException("Expected ';' or whitespace.", token) + + @classmethod + def stateWhitespace3(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, CharacterToken): + if token == ";": + parserState.NewToken = EndToken(fromExistingToken=token) + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) + parserState.Pop() + return + elif isinstance(token, WordToken): + parserState.NewToken = IdentifierToken(fromExistingToken=token) + parserState.NextState = cls.stateSimpleName + return + elif isinstance(token, ExtendedIdentifier): + parserState.NextState = cls.stateSimpleName + 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 = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) + _ = CommentBlock(parserState.NewBlock, 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(fromExistingToken=token) + parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) + parserState.TokenMarker = None + return + + raise BlockParserException("Expected ';' or {0} name.".format(cls.EXPECTED_NAME), token) + + @classmethod + def stateSimpleName(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, CharacterToken) and (token == ";"): + parserState.NewToken = EndToken(fromExistingToken=token) + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) + parserState.Pop() + return + elif isinstance(token, SpaceToken): + parserState.NewToken = BoundaryToken(fromExistingToken=token) + parserState.NextState = cls.stateWhitespace4 + return + elif isinstance(token, LinebreakToken): + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) + parserState.TokenMarker = None + parserState.NextState = cls.stateWhitespace4 + return + elif isinstance(token, CommentToken): + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) + _ = CommentBlock(parserState.NewBlock, token) + parserState.TokenMarker = None + parserState.NextState = cls.stateWhitespace4 + return + + raise BlockParserException("Expected ';' or whitespace.", token) + + @classmethod + def stateWhitespace4(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, CharacterToken): + if token == ";": + parserState.NewToken = EndToken(fromExistingToken=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 = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) + _ = CommentBlock(parserState.NewBlock, 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(fromExistingToken=token) + parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) + parserState.TokenMarker = None + return + + raise BlockParserException("Expected ';'.", token) + + +@export +class BeginBlock(Block): + END_BLOCK: EndBlock + + KEYWORDS: Any # TODO: what type? + + @classmethod + def stateStatementRegion(cls, parserState: TokenToBlockParser): + pass + + +@export +class CloseBlock(Block): + @classmethod + def stateClosingParenthesis(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, CharacterToken) and (token == ";"): + parserState.NewToken = EndToken(fromExistingToken=token) + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) + parserState.Pop() + return + elif isinstance(token, SpaceToken): + parserState.NextState = cls.stateWhitespace1 + 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.stateWhitespace1 + return + + raise BlockParserException("Expected ';' or whitespace.", token) + + @classmethod + def stateWhitespace1(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, CharacterToken)and (token == ";"): + parserState.NewToken = EndToken(fromExistingToken=token) + parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) + parserState.Pop() + return + elif isinstance(token, LinebreakToken): + # TODO: review this linebreak case + parserState.NewBlock = LinebreakBlock(parserState.LastBlock, token) + parserState.TokenMarker = None + return + elif isinstance(token, CommentToken): + parserState.NewBlock = CommentBlock(parserState.LastBlock, token) + parserState.TokenMarker = token + 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(fromExistingToken=token) + parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) + parserState.TokenMarker = None + return + + raise BlockParserException("Expected ';'.", token) + + +@export +class EndOfStatementBlock(Block): + pass diff --git a/pyVHDLParser/Blocks/Generic1.py b/pyVHDLParser/Blocks/Generic1.py deleted file mode 100644 index 0b4bec812..000000000 --- a/pyVHDLParser/Blocks/Generic1.py +++ /dev/null @@ -1,395 +0,0 @@ -# ==================================================================================================================== # -# __ ___ _ ____ _ ____ # -# _ __ _ \ \ / / | | | _ \| | | _ \ __ _ _ __ ___ ___ _ __ # -# | '_ \| | | \ \ / /| |_| | | | | | | |_) / _` | '__/ __|/ _ \ '__| # -# | |_) | |_| |\ V / | _ | |_| | |___| __/ (_| | | \__ \ __/ | # -# | .__/ \__, | \_/ |_| |_|____/|_____|_| \__,_|_| |___/\___|_| # -# |_| |___/ # -# ==================================================================================================================== # -# Authors: # -# Patrick Lehmann # -# # -# License: # -# ==================================================================================================================== # -# Copyright 2017-2023 Patrick Lehmann - Boetzingen, Germany # -# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -# ==================================================================================================================== # -# -from typing import Any - -from pyTooling.Decorators import export - -from pyVHDLParser.Token import CharacterToken, SpaceToken, LinebreakToken, CommentToken, WordToken, MultiLineCommentToken, IndentationToken -from pyVHDLParser.Token import SingleLineCommentToken, ExtendedIdentifier -from pyVHDLParser.Token.Keywords import EndToken, BoundaryToken, LabelToken, IdentifierToken -from pyVHDLParser.Blocks import FinalBlock, TokenToBlockParser, CommentBlock, BlockParserException, Block -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock - - -@export -class EndBlock(FinalBlock): - KEYWORD = None - KEYWORD_IS_OPTIONAL = False - EXPECTED_NAME = "" - EXPECTED_NAME_KIND = "keyword" # keyword label - - @classmethod - def stateEndKeyword(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, CharacterToken): - if (cls.KEYWORD_IS_OPTIONAL is True) and (token == ";"): - parserState.NewToken = EndToken(fromExistingToken=token) - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) - parserState.Pop() - return - elif isinstance(token, SpaceToken): - parserState.NewToken = BoundaryToken(fromExistingToken=token) - parserState.NextState = cls.stateWhitespace1 - return - elif isinstance(token, LinebreakToken): - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) - parserState.TokenMarker = None - parserState.NextState = cls.stateWhitespace1 - return - elif isinstance(token, CommentToken): - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) - _ = CommentBlock(parserState.NewBlock, token) - parserState.TokenMarker = None - parserState.NextState = cls.stateWhitespace1 - return - - raise BlockParserException("Expected ';' or whitespace.", token) - - @classmethod - def stateWhitespace1(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, CharacterToken): - if (cls.KEYWORD_IS_OPTIONAL is True) and (token == ";"): - parserState.NewToken = EndToken(fromExistingToken=token) - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) - parserState.Pop() - return - elif isinstance(token, WordToken): - IS_SINGLE_KEYWORD = isinstance(cls.KEYWORD, tuple) - KW = cls.KEYWORD[0] if IS_SINGLE_KEYWORD else cls.KEYWORD - if token <= KW.__KEYWORD__: - parserState.NewToken = KW(fromExistingToken=token) - parserState.NextState = cls.stateKeyword1 - elif cls.EXPECTED_NAME_KIND == "label": - parserState.NewToken = LabelToken(fromExistingToken=token) - parserState.NextState = cls.stateSimpleName - else: - parserState.NewToken = IdentifierToken(fromExistingToken=token) - parserState.NextState = cls.stateSimpleName - 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 = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) - _ = CommentBlock(parserState.NewBlock, 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(fromExistingToken=token) - parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) - parserState.TokenMarker = None - return - - if cls.KEYWORD_IS_OPTIONAL is True: - if cls.EXPECTED_NAME_KIND == "label": - errorMessage = "Expected ';', {0} keyword or {1} label.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) - else: - errorMessage = "Expected ';', {0} keyword or {1} name.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) - else: - if cls.EXPECTED_NAME_KIND == "label": - errorMessage = "Expected {0} keyword or {1} label.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) - else: - errorMessage = "Expected {0} keyword or {1} name.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) - - raise BlockParserException(errorMessage, token) - - @classmethod - def stateKeyword1(cls, parserState: TokenToBlockParser): - IS_DOUBLE_KEYWORD = isinstance(cls.KEYWORD, tuple) - nextState = cls.stateWhitespace2 if IS_DOUBLE_KEYWORD else cls.stateWhitespace3; - token = parserState.Token - if isinstance(token, CharacterToken): - if not isinstance(cls.KEYWORD, tuple) and (token == ";"): - parserState.NewToken = EndToken(fromExistingToken=token) - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) - parserState.Pop() - return - elif isinstance(token, SpaceToken): - parserState.NewToken = BoundaryToken(fromExistingToken=token) - parserState.NextState = nextState - return - elif isinstance(token, LinebreakToken): - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) - parserState.TokenMarker = None - parserState.NextState = cls.stateWhitespace3 - return - elif isinstance(token, CommentToken): - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) - _ = CommentBlock(parserState.NewBlock, token) - parserState.TokenMarker = None - parserState.NextState = cls.stateWhitespace3 - return - - raise BlockParserException("Expected ';' or whitespace.", token) - - @classmethod - def stateWhitespace2(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, CharacterToken): - if (cls.KEYWORD_IS_OPTIONAL is True) and (not isinstance(cls.KEYWORD, tuple)) and (token == ";"): - parserState.NewToken = EndToken(fromExistingToken=token) - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) - parserState.Pop() - return - elif isinstance(token, WordToken) and (token <= cls.KEYWORD[1].__KEYWORD__): - parserState.NewToken = cls.KEYWORD[1](fromExistingToken=token) - parserState.NextState = cls.stateKeyword2 - 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 = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) - _ = CommentBlock(parserState.NewBlock, 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(fromExistingToken=token) - parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) - parserState.TokenMarker = None - return - - if cls.KEYWORD_IS_OPTIONAL is True: - if cls.EXPECTED_NAME_KIND == "label": - errorMessage = "Expected ';', {0} keyword or {1} label.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) - else: - errorMessage = "Expected ';', {0} keyword or {1} name.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) - else: - if cls.EXPECTED_NAME_KIND == "label": - errorMessage = "Expected {0} keyword or {1} label.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) - else: - errorMessage = "Expected {0} keyword or {1} name.".format(cls.EXPECTED_NAME.upper(), cls.EXPECTED_NAME) - - raise BlockParserException(errorMessage, token) - - @classmethod - def stateKeyword2(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, CharacterToken)and (token == ";"): - parserState.NewToken = EndToken(fromExistingToken=token) - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) - parserState.Pop() - return - elif isinstance(token, SpaceToken): - parserState.NewToken = BoundaryToken(fromExistingToken=token) - parserState.NextState = cls.stateWhitespace3 - return - elif isinstance(token, LinebreakToken): - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) - parserState.TokenMarker = None - parserState.NextState = cls.stateWhitespace3 - return - elif isinstance(token, CommentToken): - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) - _ = CommentBlock(parserState.NewBlock, token) - parserState.TokenMarker = None - parserState.NextState = cls.stateWhitespace3 - return - - raise BlockParserException("Expected ';' or whitespace.", token) - - @classmethod - def stateWhitespace3(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, CharacterToken): - if token == ";": - parserState.NewToken = EndToken(fromExistingToken=token) - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) - parserState.Pop() - return - elif isinstance(token, WordToken): - parserState.NewToken = IdentifierToken(fromExistingToken=token) - parserState.NextState = cls.stateSimpleName - return - elif isinstance(token, ExtendedIdentifier): - parserState.NextState = cls.stateSimpleName - 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 = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) - _ = CommentBlock(parserState.NewBlock, 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(fromExistingToken=token) - parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) - parserState.TokenMarker = None - return - - raise BlockParserException("Expected ';' or {0} name.".format(cls.EXPECTED_NAME), token) - - @classmethod - def stateSimpleName(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, CharacterToken) and (token == ";"): - parserState.NewToken = EndToken(fromExistingToken=token) - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) - parserState.Pop() - return - elif isinstance(token, SpaceToken): - parserState.NewToken = BoundaryToken(fromExistingToken=token) - parserState.NextState = cls.stateWhitespace4 - return - elif isinstance(token, LinebreakToken): - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) - parserState.TokenMarker = None - parserState.NextState = cls.stateWhitespace4 - return - elif isinstance(token, CommentToken): - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) - _ = CommentBlock(parserState.NewBlock, token) - parserState.TokenMarker = None - parserState.NextState = cls.stateWhitespace4 - return - - raise BlockParserException("Expected ';' or whitespace.", token) - - @classmethod - def stateWhitespace4(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, CharacterToken): - if token == ";": - parserState.NewToken = EndToken(fromExistingToken=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 = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token.PreviousToken, multiPart=True) - _ = CommentBlock(parserState.NewBlock, 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(fromExistingToken=token) - parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) - parserState.TokenMarker = None - return - - raise BlockParserException("Expected ';'.", token) - - -@export -class BeginBlock(Block): - END_BLOCK: EndBlock - - KEYWORDS: Any # TODO: what type? - - @classmethod - def stateStatementRegion(cls, parserState: TokenToBlockParser): - pass - - -@export -class CloseBlock(Block): - @classmethod - def stateClosingParenthesis(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, CharacterToken) and (token == ";"): - parserState.NewToken = EndToken(fromExistingToken=token) - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) - parserState.Pop() - return - elif isinstance(token, SpaceToken): - parserState.NextState = cls.stateWhitespace1 - 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.stateWhitespace1 - return - - raise BlockParserException("Expected ';' or whitespace.", token) - - @classmethod - def stateWhitespace1(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, CharacterToken)and (token == ";"): - parserState.NewToken = EndToken(fromExistingToken=token) - parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) - parserState.Pop() - return - elif isinstance(token, LinebreakToken): - # TODO: review this linebreak case - parserState.NewBlock = LinebreakBlock(parserState.LastBlock, token) - parserState.TokenMarker = None - return - elif isinstance(token, CommentToken): - parserState.NewBlock = CommentBlock(parserState.LastBlock, token) - parserState.TokenMarker = token - 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(fromExistingToken=token) - parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) - parserState.TokenMarker = None - return - - raise BlockParserException("Expected ';'.", token) - - -@export -class EndOfStatementBlock(Block): - pass diff --git a/pyVHDLParser/Blocks/Instantiation/EntityInstantiation.py b/pyVHDLParser/Blocks/Instantiation/EntityInstantiation.py index 80abfef21..52f0e973f 100644 --- a/pyVHDLParser/Blocks/Instantiation/EntityInstantiation.py +++ b/pyVHDLParser/Blocks/Instantiation/EntityInstantiation.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, FinalBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/Instantiation/FunctionInstantiation.py b/pyVHDLParser/Blocks/Instantiation/FunctionInstantiation.py index 2caee7f68..5b1ed595c 100644 --- a/pyVHDLParser/Blocks/Instantiation/FunctionInstantiation.py +++ b/pyVHDLParser/Blocks/Instantiation/FunctionInstantiation.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, FinalBlock, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/Instantiation/PackageInstantiation.py b/pyVHDLParser/Blocks/Instantiation/PackageInstantiation.py index 2caee7f68..5b1ed595c 100644 --- a/pyVHDLParser/Blocks/Instantiation/PackageInstantiation.py +++ b/pyVHDLParser/Blocks/Instantiation/PackageInstantiation.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, FinalBlock, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/Instantiation/ProcedureInstantiation.py b/pyVHDLParser/Blocks/Instantiation/ProcedureInstantiation.py index 2caee7f68..5b1ed595c 100644 --- a/pyVHDLParser/Blocks/Instantiation/ProcedureInstantiation.py +++ b/pyVHDLParser/Blocks/Instantiation/ProcedureInstantiation.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, FinalBlock, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/InterfaceObject.py b/pyVHDLParser/Blocks/InterfaceObject.py index b7c3e6fc9..2052f839d 100644 --- a/pyVHDLParser/Blocks/InterfaceObject.py +++ b/pyVHDLParser/Blocks/InterfaceObject.py @@ -36,7 +36,7 @@ from pyVHDLParser.Token.Keywords import InKeyword, VariableAssignmentKeyword, OutKeyword, InoutKeyword, BufferKeyword, LinkageKeyword from pyVHDLParser.Token.Keywords import IdentifierToken, BoundaryToken, DelimiterToken from pyVHDLParser.Blocks import Block, TokenToBlockParser, CommentBlock, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedByCharORClosingRoundBracket diff --git a/pyVHDLParser/Blocks/List/GenericList.py b/pyVHDLParser/Blocks/List/GenericList.py index 86676f1ac..9ced704d4 100644 --- a/pyVHDLParser/Blocks/List/GenericList.py +++ b/pyVHDLParser/Blocks/List/GenericList.py @@ -34,8 +34,8 @@ from pyVHDLParser.Token.Keywords import IdentifierToken from pyVHDLParser.Token.Parser import SpaceToken, WordToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic1 import CloseBlock as CloseBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Generic import CloseBlock as CloseBlockBase from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedByCharORClosingRoundBracket from pyVHDLParser.Blocks.InterfaceObject import InterfaceConstantBlock, InterfaceTypeBlock diff --git a/pyVHDLParser/Blocks/List/GenericMapList.py b/pyVHDLParser/Blocks/List/GenericMapList.py index 5b29a2efb..e83b2c548 100644 --- a/pyVHDLParser/Blocks/List/GenericMapList.py +++ b/pyVHDLParser/Blocks/List/GenericMapList.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, IndentationToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, DelimiterToken, OpeningRoundBracketToken, ClosingRoundBracketToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/List/ParameterList.py b/pyVHDLParser/Blocks/List/ParameterList.py index 7a67dbbe6..0ac856542 100644 --- a/pyVHDLParser/Blocks/List/ParameterList.py +++ b/pyVHDLParser/Blocks/List/ParameterList.py @@ -33,8 +33,8 @@ from pyVHDLParser.Token.Keywords import BoundaryToken, DelimiterToken, ClosingRoundBracketToken, IdentifierToken from pyVHDLParser.Token.Keywords import ConstantKeyword, SignalKeyword, VariableKeyword, TypeKeyword from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic1 import CloseBlock as CloseBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Generic import CloseBlock as CloseBlockBase from pyVHDLParser.Blocks.InterfaceObject import InterfaceSignalBlock, InterfaceConstantBlock, InterfaceVariableBlock diff --git a/pyVHDLParser/Blocks/List/PortList.py b/pyVHDLParser/Blocks/List/PortList.py index 2f4728b1e..73533db0f 100644 --- a/pyVHDLParser/Blocks/List/PortList.py +++ b/pyVHDLParser/Blocks/List/PortList.py @@ -33,8 +33,8 @@ from pyVHDLParser.Token.Keywords import BoundaryToken, SignalKeyword, DelimiterToken from pyVHDLParser.Token.Keywords import IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic1 import CloseBlock as CloseBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Generic import CloseBlock as CloseBlockBase from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedByCharORClosingRoundBracket from pyVHDLParser.Blocks.InterfaceObject import InterfaceSignalBlock diff --git a/pyVHDLParser/Blocks/List/PortMapList.py b/pyVHDLParser/Blocks/List/PortMapList.py index 4a91a8c3f..ca0b3e796 100644 --- a/pyVHDLParser/Blocks/List/PortMapList.py +++ b/pyVHDLParser/Blocks/List/PortMapList.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, IndentationToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, DelimiterToken, OpeningRoundBracketToken, ClosingRoundBracketToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/List/SensitivityList.py b/pyVHDLParser/Blocks/List/SensitivityList.py index 4f3db0c62..05084c564 100644 --- a/pyVHDLParser/Blocks/List/SensitivityList.py +++ b/pyVHDLParser/Blocks/List/SensitivityList.py @@ -34,7 +34,7 @@ from pyVHDLParser.Token.Keywords import BoundaryToken, DelimiterToken, OpeningRoundBracketToken, ClosingRoundBracketToken from pyVHDLParser.Token.Keywords import IdentifierToken, AllKeyword from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock @export diff --git a/pyVHDLParser/Blocks/Object/Constant.py b/pyVHDLParser/Blocks/Object/Constant.py index 07b023410..7d76a74a9 100644 --- a/pyVHDLParser/Blocks/Object/Constant.py +++ b/pyVHDLParser/Blocks/Object/Constant.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken from pyVHDLParser.Token.Keywords import BoundaryToken from pyVHDLParser.Blocks import TokenToBlockParser, CommentBlock, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedBySemicolon from pyVHDLParser.Blocks.Object import ObjectDeclarationEndMarkerBlock, ObjectDeclarationBlock diff --git a/pyVHDLParser/Blocks/Object/SharedVariable.py b/pyVHDLParser/Blocks/Object/SharedVariable.py index f5f67ec87..1186ed3ba 100644 --- a/pyVHDLParser/Blocks/Object/SharedVariable.py +++ b/pyVHDLParser/Blocks/Object/SharedVariable.py @@ -30,7 +30,7 @@ from pyTooling.Decorators import export from pyVHDLParser.Blocks import TokenToBlockParser, CommentBlock, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Object import ObjectDeclarationEndMarkerBlock, ObjectDeclarationBlock from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken, WordToken from pyVHDLParser.Token import ExtendedIdentifier, MultiLineCommentToken, CharacterToken diff --git a/pyVHDLParser/Blocks/Object/Signal.py b/pyVHDLParser/Blocks/Object/Signal.py index 780ed06fd..339ae847b 100644 --- a/pyVHDLParser/Blocks/Object/Signal.py +++ b/pyVHDLParser/Blocks/Object/Signal.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken from pyVHDLParser.Token.Keywords import BoundaryToken from pyVHDLParser.Blocks import TokenToBlockParser, CommentBlock, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedBySemicolon from pyVHDLParser.Blocks.Object import ObjectDeclarationEndMarkerBlock, ObjectDeclarationBlock diff --git a/pyVHDLParser/Blocks/Object/Variable.py b/pyVHDLParser/Blocks/Object/Variable.py index d4bd920d1..db5f525cc 100644 --- a/pyVHDLParser/Blocks/Object/Variable.py +++ b/pyVHDLParser/Blocks/Object/Variable.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken from pyVHDLParser.Token.Keywords import BoundaryToken from pyVHDLParser.Blocks import TokenToBlockParser, CommentBlock, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock from pyVHDLParser.Blocks.Expression import ExpressionBlockEndedBySemicolon from pyVHDLParser.Blocks.Object import ObjectDeclarationEndMarkerBlock, ObjectDeclarationBlock diff --git a/pyVHDLParser/Blocks/Object/__init__.py b/pyVHDLParser/Blocks/Object/__init__.py index c2c2072cf..5b9b37a28 100644 --- a/pyVHDLParser/Blocks/Object/__init__.py +++ b/pyVHDLParser/Blocks/Object/__init__.py @@ -33,8 +33,8 @@ from pyVHDLParser.Token import CommentToken, SpaceToken, CharacterToken, FusedCharacterToken from pyVHDLParser.Token.Keywords import IdentifierToken, BoundaryToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser, CommentBlock, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic1 import EndOfStatementBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Generic import EndOfStatementBlock @export diff --git a/pyVHDLParser/Blocks/Reference/Context.py b/pyVHDLParser/Blocks/Reference/Context.py index db7d2a83d..de0158b9d 100644 --- a/pyVHDLParser/Blocks/Reference/Context.py +++ b/pyVHDLParser/Blocks/Reference/Context.py @@ -32,8 +32,8 @@ from pyVHDLParser.Token import CommentToken, SpaceToken, LinebreakToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, IdentifierToken, IsKeyword, UseKeyword, EndKeyword, ContextKeyword, LibraryKeyword from pyVHDLParser.Blocks import Block, CommentBlock, BlockParserException, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import EndBlock as EndBlockBase @export diff --git a/pyVHDLParser/Blocks/Reference/Library.py b/pyVHDLParser/Blocks/Reference/Library.py index 53f2b6834..aac242aba 100644 --- a/pyVHDLParser/Blocks/Reference/Library.py +++ b/pyVHDLParser/Blocks/Reference/Library.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, CommentToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, DelimiterToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, FinalBlock, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @export diff --git a/pyVHDLParser/Blocks/Reference/Use.py b/pyVHDLParser/Blocks/Reference/Use.py index b15fc303b..2342476c7 100644 --- a/pyVHDLParser/Blocks/Reference/Use.py +++ b/pyVHDLParser/Blocks/Reference/Use.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, DelimiterToken, EndToken, AllKeyword from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, FinalBlock, SkipableBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @export diff --git a/pyVHDLParser/Blocks/Region.py b/pyVHDLParser/Blocks/Region.py new file mode 100644 index 000000000..b184b06da --- /dev/null +++ b/pyVHDLParser/Blocks/Region.py @@ -0,0 +1,278 @@ +# ==================================================================================================================== # +# __ ___ _ ____ _ ____ # +# _ __ _ \ \ / / | | | _ \| | | _ \ __ _ _ __ ___ ___ _ __ # +# | '_ \| | | \ \ / /| |_| | | | | | | |_) / _` | '__/ __|/ _ \ '__| # +# | |_) | |_| |\ V / | _ | |_| | |___| __/ (_| | | \__ \ __/ | # +# | .__/ \__, | \_/ |_| |_|____/|_____|_| \__,_|_| |___/\___|_| # +# |_| |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 Patrick Lehmann - Boetzingen, Germany # +# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# ==================================================================================================================== # +# +from typing import Any + +from pyTooling.Decorators import export + +from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, IndentationToken +from pyVHDLParser.Token.Keywords import AssertKeyword, EndKeyword, ProcessKeyword, ReportKeyword, IfKeyword, ForKeyword, ReturnKeyword, NextKeyword, NullKeyword +from pyVHDLParser.Token.Keywords import ExitKeyword, UseKeyword, SignalKeyword, ConstantKeyword, SharedKeyword, FunctionKeyword, ProcedureKeyword +from pyVHDLParser.Token.Keywords import ImpureKeyword, PureKeyword, VariableKeyword, BeginKeyword, CaseKeyword +from pyVHDLParser.Blocks import BlockParserException, CommentBlock, TokenToBlockParser, MetaBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Object.Variable import VariableDeclarationBlock +from pyVHDLParser.Blocks.Generic import EndBlock, BeginBlock + + +@export +class DeclarativeRegion(metaclass=MetaBlock): + """Base-class for all declarative region blocks.""" + + BEGIN_BLOCK: BeginBlock + END_BLOCK: EndBlock + + KEYWORDS: Any # TODO: what type? + + @classmethod + def __cls_init__(cls): + from pyVHDLParser.Blocks.Reference import Use + from pyVHDLParser.Blocks.Object.Constant import ConstantDeclarationBlock + from pyVHDLParser.Blocks.Sequential import Procedure, Function + + cls.KEYWORDS = { + # Keyword Transition + UseKeyword: Use.StartBlock.stateUseKeyword, + ConstantKeyword: ConstantDeclarationBlock.stateConstantKeyword, + FunctionKeyword: Function.NameBlock.stateFunctionKeyword, + ProcedureKeyword: Procedure.NameBlock.stateProcedureKeyword, + ImpureKeyword: Function.NameBlock.stateImpureKeyword, + PureKeyword: Function.NameBlock.statePureKeyword, + # AliasKeyword: Alias.NameBlock.stateAliasKeyword + } + + + @classmethod + def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, SpaceToken): + blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock + parserState.NewBlock = blockType(parserState.LastBlock, token) + parserState.TokenMarker = None + return + elif isinstance(token, LinebreakToken): + 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, WordToken): + tokenValue = token.Value.lower() + + for keyword in cls.KEYWORDS: + if tokenValue == keyword.__KEYWORD__: + newToken = keyword(fromExistingToken=token) + parserState.PushState = cls.KEYWORDS[keyword] + parserState.NewToken = newToken + parserState.TokenMarker = newToken + return + + if tokenValue == "begin": + parserState.NewToken = BeginKeyword(fromExistingToken=token) + parserState.NewBlock = cls.BEGIN_BLOCK(parserState.LastBlock, parserState.NewToken) + parserState.NextState = cls.BEGIN_BLOCK.stateStatementRegion + return + elif tokenValue == "end": + parserState.NewToken = EndKeyword(fromExistingToken=token) + parserState.NextState = cls.END_BLOCK.stateEndKeyword + return + + raise BlockParserException( + "Expected one of these keywords: BEGIN, END, {keywords}. Found: '{tokenValue}'.".format( + keywords=", ".join( + [kw.__KEYWORD__.upper() for kw in cls.KEYWORDS] + ), + tokenValue=token.Value + ), token) + + +@export +class ConcurrentDeclarativeRegion(DeclarativeRegion): + """Base-class for all concurrent declarative region blocks.""" + + @classmethod + def __cls_init__(cls): + super().__cls_init__() + + from pyVHDLParser.Blocks.Object.Signal import SignalDeclarationBlock + from pyVHDLParser.Blocks.Object.SharedVariable import SharedVariableDeclarationBlock + + cls.KEYWORDS.update({ + # Keyword Transition + SignalKeyword: SignalDeclarationBlock.stateSignalKeyword, + SharedKeyword: SharedVariableDeclarationBlock.stateSharedKeyword + }) + + +@export +class SequentialDeclarativeRegion(DeclarativeRegion): + """Base-class for all sequential declarative region blocks.""" + + @classmethod + def __cls_init__(cls): + super().__cls_init__() + + # TODO: use key assignment: a[b] = c + cls.KEYWORDS.update({ + # Keyword Transition + VariableKeyword: VariableDeclarationBlock.stateVariableKeyword + }) + + +@export +class ConcurrentBeginBlock(BeginBlock): + @classmethod + def __cls_init__(cls): + from pyVHDLParser.Blocks.Sequential import Process + from pyVHDLParser.Blocks.Reporting.Assert import AssertBlock + + cls.KEYWORDS = { + # Keyword Transition + AssertKeyword: AssertBlock.stateAssertKeyword, + ProcessKeyword: Process.OpenBlock.stateProcessKeyword, + } + + @classmethod + def stateStatementRegion(cls, parserState: TokenToBlockParser): + parserState.NextState = cls.stateConcurrentRegion + parserState.NextState(parserState) + + @classmethod + def stateConcurrentRegion(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, SpaceToken): + blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock + parserState.NewBlock = blockType(parserState.LastBlock, token) + parserState.TokenMarker = None + return + elif isinstance(token, (LinebreakToken, CommentToken)): + block = LinebreakBlock if isinstance(token, LinebreakToken) else CommentBlock + parserState.NewBlock = block(parserState.LastBlock, token) + parserState.TokenMarker = None + return + elif isinstance(token, WordToken): + tokenValue = token.Value.lower() + + for keyword in cls.KEYWORDS: + if tokenValue == keyword.__KEYWORD__: + newToken = keyword(fromExistingToken=token) + parserState.PushState = cls.KEYWORDS[keyword] + parserState.NewToken = newToken + parserState.TokenMarker = newToken + return + + if tokenValue == "end": + parserState.NewToken = EndKeyword(fromExistingToken=token) + parserState.NextState = cls.END_BLOCK.stateEndKeyword + return + + raise BlockParserException( + "Expected one of these keywords: END, {keywords}. Found: '{tokenValue}'.".format( + keywords=", ".join( + [kw.__KEYWORD__.upper() for kw in cls.KEYWORDS] + ), + tokenValue=token.Value + ), token) + + +@export +class SequentialBeginBlock(BeginBlock): + @classmethod + def __cls_init__(cls): + from pyVHDLParser.Blocks.ControlStructure.If import IfConditionBlock + from pyVHDLParser.Blocks.ControlStructure.Case import CaseBlock + from pyVHDLParser.Blocks.ControlStructure.Exit import ExitBlock + from pyVHDLParser.Blocks.ControlStructure.Next import NextBlock + from pyVHDLParser.Blocks.ControlStructure.Return import ReturnBlock + from pyVHDLParser.Blocks.ControlStructure.ForLoop import IteratorBlock + # from pyVHDLParser.Blocks.ControlStructure.WhileLoop import ConditionBlock + from pyVHDLParser.Blocks.Reporting.Report import ReportBlock + from pyVHDLParser.Blocks.ControlStructure.Null import NullBlock + + cls.KEYWORDS = { + # Keyword Transition + IfKeyword: IfConditionBlock.stateIfKeyword, + CaseKeyword: CaseBlock.stateCaseKeyword, + ForKeyword: IteratorBlock.stateForKeyword, + # WhileKeyword: ConditionBlock.stateWhileKeyword, + ReturnKeyword: ReturnBlock.stateReturnKeyword, + NextKeyword: NextBlock.stateNextKeyword, + ExitKeyword: ExitBlock.stateExitKeyword, + ReportKeyword: ReportBlock.stateReportKeyword, + NullKeyword: NullBlock.stateNullKeyword + } + + @classmethod + def stateStatementRegion(cls, parserState: TokenToBlockParser): + cls.stateAnyRegion(parserState) + + @classmethod + def stateSequentialRegion(cls, parserState: TokenToBlockParser): + cls.stateAnyRegion(parserState) + + @classmethod + def stateAnyRegion(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, SpaceToken): + blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock + parserState.NewBlock = blockType(parserState.LastBlock, token) + parserState.TokenMarker = None + return + elif isinstance(token, (LinebreakToken, CommentToken)): + block = LinebreakBlock if isinstance(token, LinebreakToken) else CommentBlock + parserState.NewBlock = block(parserState.LastBlock, token) + parserState.TokenMarker = None + return + elif isinstance(token, WordToken): + tokenValue = token.Value.lower() + + for keyword in cls.KEYWORDS: + if tokenValue == keyword.__KEYWORD__: + newToken = keyword(fromExistingToken=token) + parserState.PushState = cls.KEYWORDS[keyword] + parserState.NewToken = newToken + parserState.TokenMarker = newToken + return + + if tokenValue == "end": + parserState.NewToken = EndKeyword(fromExistingToken=token) + parserState.NextState = cls.END_BLOCK.stateEndKeyword + return + + raise BlockParserException( + "Expected one of these keywords: END, {keywords}. Found: '{tokenValue}' at line {tokenPositionRow}:{tokenPositionColumn}.".format( + keywords=", ".join( + [kw.__KEYWORD__.upper() for kw in cls.KEYWORDS] + ), + tokenValue=token.Value, + tokenPositionRow=token.Start.Row, + tokenPositionColumn=token.Start.Column + ), token) diff --git a/pyVHDLParser/Blocks/Reporting/Assert.py b/pyVHDLParser/Blocks/Reporting/Assert.py index 10a677a36..3719d4a0d 100644 --- a/pyVHDLParser/Blocks/Reporting/Assert.py +++ b/pyVHDLParser/Blocks/Reporting/Assert.py @@ -33,7 +33,7 @@ from pyVHDLParser.Token import CommentToken, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, ReportKeyword, EndToken, SeverityKeyword from pyVHDLParser.Blocks import Block, CommentBlock, TokenToBlockParser, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @export diff --git a/pyVHDLParser/Blocks/Reporting/Report.py b/pyVHDLParser/Blocks/Reporting/Report.py index c3c179bb5..ace2d2ae9 100644 --- a/pyVHDLParser/Blocks/Reporting/Report.py +++ b/pyVHDLParser/Blocks/Reporting/Report.py @@ -33,7 +33,7 @@ from pyVHDLParser.Token import CommentToken, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, SeverityKeyword from pyVHDLParser.Blocks import Block, CommentBlock, TokenToBlockParser, BlockParserException -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @export diff --git a/pyVHDLParser/Blocks/Sequential/Function.py b/pyVHDLParser/Blocks/Sequential/Function.py index 074a1c885..9d1c3b159 100644 --- a/pyVHDLParser/Blocks/Sequential/Function.py +++ b/pyVHDLParser/Blocks/Sequential/Function.py @@ -34,9 +34,9 @@ from pyVHDLParser.Token.Keywords import ReturnKeyword, GenericKeyword, ParameterKeyword, FunctionKeyword, EndKeyword from pyVHDLParser.Token.Keywords import UseKeyword, ConstantKeyword, VariableKeyword, IsKeyword, EndToken, BeginKeyword, ProcedureKeyword, ReportKeyword from pyVHDLParser.Blocks import Block, BlockParserException, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import SequentialBeginBlock, SequentialDeclarativeRegion -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import SequentialBeginBlock, SequentialDeclarativeRegion +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase from pyVHDLParser.Blocks.List import GenericList, ParameterList diff --git a/pyVHDLParser/Blocks/Sequential/Package.py b/pyVHDLParser/Blocks/Sequential/Package.py index 96112520e..93c4749c9 100644 --- a/pyVHDLParser/Blocks/Sequential/Package.py +++ b/pyVHDLParser/Blocks/Sequential/Package.py @@ -34,9 +34,9 @@ from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Token.Keywords import ConstantKeyword, SharedKeyword, ProcedureKeyword, FunctionKeyword, PureKeyword, ImpureKeyword from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import SequentialDeclarativeRegion -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import SequentialDeclarativeRegion +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase from pyVHDLParser.Blocks.Sequential import PackageBody from pyVHDLParser.Blocks.List import GenericList diff --git a/pyVHDLParser/Blocks/Sequential/PackageBody.py b/pyVHDLParser/Blocks/Sequential/PackageBody.py index 6495a2251..86fb5d8d1 100644 --- a/pyVHDLParser/Blocks/Sequential/PackageBody.py +++ b/pyVHDLParser/Blocks/Sequential/PackageBody.py @@ -34,9 +34,9 @@ from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Token.Keywords import ConstantKeyword, SharedKeyword, ProcedureKeyword, FunctionKeyword, PureKeyword, ImpureKeyword from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import SequentialDeclarativeRegion -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import SequentialDeclarativeRegion +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase @export diff --git a/pyVHDLParser/Blocks/Sequential/Procedure.py b/pyVHDLParser/Blocks/Sequential/Procedure.py index 1669e0283..6051dd901 100644 --- a/pyVHDLParser/Blocks/Sequential/Procedure.py +++ b/pyVHDLParser/Blocks/Sequential/Procedure.py @@ -33,10 +33,10 @@ from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, IdentifierToken, GenericKeyword, ParameterKeyword, ProcedureKeyword, EndKeyword, ImpureKeyword, PureKeyword from pyVHDLParser.Token.Keywords import UseKeyword, ConstantKeyword, VariableKeyword, IsKeyword, EndToken, BeginKeyword, FunctionKeyword, ReportKeyword from pyVHDLParser.Blocks import Block, BlockParserException, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock # from pyVHDLParser.Blocks.ControlStructure import If, Case, ForLoop, WhileLoop, Return -from pyVHDLParser.Blocks.Generic import SequentialBeginBlock, SequentialDeclarativeRegion -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Region import SequentialBeginBlock, SequentialDeclarativeRegion +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase from pyVHDLParser.Blocks.List import GenericList, ParameterList diff --git a/pyVHDLParser/Blocks/Sequential/Process.py b/pyVHDLParser/Blocks/Sequential/Process.py index f00d3e77b..e7dda76b8 100644 --- a/pyVHDLParser/Blocks/Sequential/Process.py +++ b/pyVHDLParser/Blocks/Sequential/Process.py @@ -33,10 +33,10 @@ from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, IsKeyword, UseKeyword, ConstantKeyword, ImpureKeyword, PureKeyword from pyVHDLParser.Token.Keywords import VariableKeyword, ProcessKeyword, BeginKeyword, FunctionKeyword, ProcedureKeyword from pyVHDLParser.Blocks import Block, CommentBlock, BlockParserException, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock # from pyVHDLParser.Blocks.ControlStructure import If, Case, ForLoop, WhileLoop -from pyVHDLParser.Blocks.Generic import SequentialBeginBlock, SequentialDeclarativeRegion -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Region import SequentialBeginBlock, SequentialDeclarativeRegion +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase from pyVHDLParser.Blocks.List import SensitivityList diff --git a/pyVHDLParser/Blocks/Structural/Architecture.py b/pyVHDLParser/Blocks/Structural/Architecture.py index 73951f2aa..4d9170120 100644 --- a/pyVHDLParser/Blocks/Structural/Architecture.py +++ b/pyVHDLParser/Blocks/Structural/Architecture.py @@ -32,9 +32,9 @@ from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import ArchitectureKeyword, IsKeyword, OfKeyword, BoundaryToken, IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import ConcurrentBeginBlock, ConcurrentDeclarativeRegion -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import ConcurrentBeginBlock, ConcurrentDeclarativeRegion +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase @export diff --git a/pyVHDLParser/Blocks/Structural/Block.py b/pyVHDLParser/Blocks/Structural/Block.py index e02fe58f9..0ae02f1c8 100644 --- a/pyVHDLParser/Blocks/Structural/Block.py +++ b/pyVHDLParser/Blocks/Structural/Block.py @@ -34,9 +34,9 @@ from pyVHDLParser.Token.Keywords import SignalKeyword, ConstantKeyword, VariableKeyword, SharedKeyword, ProcessKeyword, AssertKeyword, BlockKeyword from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, BlockKeyword, BeginKeyword from pyVHDLParser.Blocks import Block, BlockParserException, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock -from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase, ConcurrentDeclarativeRegion, ConcurrentBeginBlock +from pyVHDLParser.Blocks.Region import EndBlock as EndBlockBase, ConcurrentDeclarativeRegion, ConcurrentBeginBlock from pyVHDLParser.Blocks.List import PortList from pyVHDLParser.Blocks.Reporting import Assert from pyVHDLParser.Blocks.Sequential import Process diff --git a/pyVHDLParser/Blocks/Structural/Component.py b/pyVHDLParser/Blocks/Structural/Component.py index 526e55593..e98845f7e 100644 --- a/pyVHDLParser/Blocks/Structural/Component.py +++ b/pyVHDLParser/Blocks/Structural/Component.py @@ -33,8 +33,8 @@ from pyVHDLParser.Token.Keywords import ComponentKeyword, IsKeyword, EndKeyword, GenericKeyword, PortKeyword, UseKeyword, BeginKeyword from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import EndBlock as EndBlockBase @export diff --git a/pyVHDLParser/Blocks/Structural/Configuration.py b/pyVHDLParser/Blocks/Structural/Configuration.py index 361da99f9..4aef1ef6d 100644 --- a/pyVHDLParser/Blocks/Structural/Configuration.py +++ b/pyVHDLParser/Blocks/Structural/Configuration.py @@ -33,8 +33,8 @@ from pyVHDLParser.Token.Keywords import ConfigurationKeyword, IsKeyword, EndKeyword, GenericKeyword, PortKeyword, UseKeyword, BeginKeyword from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import ConcurrentBeginBlock, EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import ConcurrentBeginBlock, EndBlock as EndBlockBase @export diff --git a/pyVHDLParser/Blocks/Structural/Entity.py b/pyVHDLParser/Blocks/Structural/Entity.py index 0c00feb18..e61d3eeb4 100644 --- a/pyVHDLParser/Blocks/Structural/Entity.py +++ b/pyVHDLParser/Blocks/Structural/Entity.py @@ -33,9 +33,9 @@ from pyVHDLParser.Token.Keywords import EntityKeyword, IsKeyword, GenericKeyword, PortKeyword from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock -from pyVHDLParser.Blocks.Generic import ConcurrentBeginBlock, ConcurrentDeclarativeRegion -from pyVHDLParser.Blocks.Generic1 import EndBlock as EndBlockBase +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Region import ConcurrentBeginBlock, ConcurrentDeclarativeRegion +from pyVHDLParser.Blocks.Generic import EndBlock as EndBlockBase @export diff --git a/pyVHDLParser/Blocks/Type/Subtype.py b/pyVHDLParser/Blocks/Type/Subtype.py index 94f5a8b40..0e37d9c3d 100644 --- a/pyVHDLParser/Blocks/Type/Subtype.py +++ b/pyVHDLParser/Blocks/Type/Subtype.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, WordToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/Type/Type.py b/pyVHDLParser/Blocks/Type/Type.py index d3c393e6e..cf9e2ae10 100644 --- a/pyVHDLParser/Blocks/Type/Type.py +++ b/pyVHDLParser/Blocks/Type/Type.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, WordToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser -from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock diff --git a/pyVHDLParser/Blocks/Common.py b/pyVHDLParser/Blocks/Whitespace.py similarity index 98% rename from pyVHDLParser/Blocks/Common.py rename to pyVHDLParser/Blocks/Whitespace.py index 22124b08e..9173f794a 100644 --- a/pyVHDLParser/Blocks/Common.py +++ b/pyVHDLParser/Blocks/Whitespace.py @@ -1,90 +1,90 @@ -# ==================================================================================================================== # -# __ ___ _ ____ _ ____ # -# _ __ _ \ \ / / | | | _ \| | | _ \ __ _ _ __ ___ ___ _ __ # -# | '_ \| | | \ \ / /| |_| | | | | | | |_) / _` | '__/ __|/ _ \ '__| # -# | |_) | |_| |\ V / | _ | |_| | |___| __/ (_| | | \__ \ __/ | # -# | .__/ \__, | \_/ |_| |_|____/|_____|_| \__,_|_| |___/\___|_| # -# |_| |___/ # -# ==================================================================================================================== # -# Authors: # -# Patrick Lehmann # -# # -# License: # -# ==================================================================================================================== # -# Copyright 2017-2023 Patrick Lehmann - Boetzingen, Germany # -# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -# ==================================================================================================================== # -# -from pyTooling.Decorators import export - -from pyVHDLParser.Token import SpaceToken, IndentationToken -from pyVHDLParser.Blocks import TokenToBlockParser, SkipableBlock - - -@export -class WhitespaceBlock(SkipableBlock): - def __init__(self, previousBlock, startToken): - super().__init__(previousBlock, startToken, startToken) - - def __repr__(self): - return "[{blockName: <50s} {stream} at {start!s} .. {end!s}]".format( - blockName=type(self).__name__, - stream=" "*61, - start=self.StartToken.Start, - end=self.EndToken.End - ) - - -@export -class LinebreakBlock(WhitespaceBlock): - @classmethod - def stateLinebreak(cls, parserState: TokenToBlockParser): - token = parserState.Token - if isinstance(token, SpaceToken): - parserState.NewToken = IndentationToken(fromExistingToken=token) - parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) - parserState.Pop() - # print(" {GREEN}continue: {0!s}{NOCOLOR}".format(parserState, **Console.Foreground)) - else: - parserState.Pop() - if parserState.TokenMarker is None: - # print(" {DARK_GREEN}set marker: {GREEN}LinebreakBlock.stateLinebreak {DARK_GREEN}marker {GREEN}{0!s}{NOCOLOR}".format(token, **Console.Foreground)) - parserState.TokenMarker = token - # print(" {DARK_GREEN}re-issue: {GREEN}{state!s: <20s} {DARK_GREEN}token {GREEN}{token}{NOCOLOR}".format(state=parserState, token=parserState.Token, **Console.Foreground)) - parserState.NextState(parserState) - - -@export -class EmptyLineBlock(LinebreakBlock): - pass - - -@export -class IndentationBlock(WhitespaceBlock): - __TABSIZE__ = 2 - - def __repr__(self): - length = len(self.StartToken.Value) - actual = sum([(self.__TABSIZE__ if (c == "\t") else 1) for c in self.StartToken.Value]) - - return "[{blockName: <50s} length={len: <53} at {start!s} .. {end!s}]".format( - blockName=type(self).__name__, - len="{len} ({actual}) ".format( - len=length, - actual=actual - ), - start=self.StartToken.Start, - end=self.EndToken.End - ) +# ==================================================================================================================== # +# __ ___ _ ____ _ ____ # +# _ __ _ \ \ / / | | | _ \| | | _ \ __ _ _ __ ___ ___ _ __ # +# | '_ \| | | \ \ / /| |_| | | | | | | |_) / _` | '__/ __|/ _ \ '__| # +# | |_) | |_| |\ V / | _ | |_| | |___| __/ (_| | | \__ \ __/ | # +# | .__/ \__, | \_/ |_| |_|____/|_____|_| \__,_|_| |___/\___|_| # +# |_| |___/ # +# ==================================================================================================================== # +# Authors: # +# Patrick Lehmann # +# # +# License: # +# ==================================================================================================================== # +# Copyright 2017-2023 Patrick Lehmann - Boetzingen, Germany # +# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# ==================================================================================================================== # +# +from pyTooling.Decorators import export + +from pyVHDLParser.Token import SpaceToken, IndentationToken +from pyVHDLParser.Blocks import TokenToBlockParser, SkipableBlock + + +@export +class WhitespaceBlock(SkipableBlock): + def __init__(self, previousBlock, startToken): + super().__init__(previousBlock, startToken, startToken) + + def __repr__(self): + return "[{blockName: <50s} {stream} at {start!s} .. {end!s}]".format( + blockName=type(self).__name__, + stream=" "*61, + start=self.StartToken.Start, + end=self.EndToken.End + ) + + +@export +class LinebreakBlock(WhitespaceBlock): + @classmethod + def stateLinebreak(cls, parserState: TokenToBlockParser): + token = parserState.Token + if isinstance(token, SpaceToken): + parserState.NewToken = IndentationToken(fromExistingToken=token) + parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) + parserState.Pop() + # print(" {GREEN}continue: {0!s}{NOCOLOR}".format(parserState, **Console.Foreground)) + else: + parserState.Pop() + if parserState.TokenMarker is None: + # print(" {DARK_GREEN}set marker: {GREEN}LinebreakBlock.stateLinebreak {DARK_GREEN}marker {GREEN}{0!s}{NOCOLOR}".format(token, **Console.Foreground)) + parserState.TokenMarker = token + # print(" {DARK_GREEN}re-issue: {GREEN}{state!s: <20s} {DARK_GREEN}token {GREEN}{token}{NOCOLOR}".format(state=parserState, token=parserState.Token, **Console.Foreground)) + parserState.NextState(parserState) + + +@export +class EmptyLineBlock(LinebreakBlock): + pass + + +@export +class IndentationBlock(WhitespaceBlock): + __TABSIZE__ = 2 + + def __repr__(self): + length = len(self.StartToken.Value) + actual = sum([(self.__TABSIZE__ if (c == "\t") else 1) for c in self.StartToken.Value]) + + return "[{blockName: <50s} length={len: <53} at {start!s} .. {end!s}]".format( + blockName=type(self).__name__, + len="{len} ({actual}) ".format( + len=length, + actual=actual + ), + start=self.StartToken.Start, + end=self.EndToken.End + ) diff --git a/pyVHDLParser/Blocks/__init__.py b/pyVHDLParser/Blocks/__init__.py index e074b7d88..9f0ec9b86 100644 --- a/pyVHDLParser/Blocks/__init__.py +++ b/pyVHDLParser/Blocks/__init__.py @@ -151,7 +151,7 @@ def Pop(self, n: int = 1, tokenMarker: Token = None) -> None: def __call__(self) -> Generator['Block', Token, None]: from pyVHDLParser.Token import EndOfDocumentToken - from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock + from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock for token in self._iterator: # set parserState.Token to current token @@ -478,7 +478,7 @@ class StartOfDocumentBlock(StartOfBlock, StartOfDocument): @classmethod def __cls_init__(cls): - from pyVHDLParser.Blocks.Common import IndentationBlock, WhitespaceBlock, LinebreakBlock + from pyVHDLParser.Blocks.Whitespace import IndentationBlock, WhitespaceBlock, LinebreakBlock from pyVHDLParser.Blocks.Reference import Library, Use, Context from pyVHDLParser.Blocks.Sequential import Package from pyVHDLParser.Blocks.Structural import Entity, Architecture @@ -495,7 +495,7 @@ def __cls_init__(cls): @classmethod def stateDocument(cls, parserState: TokenToBlockParser): - from pyVHDLParser.Blocks.Common import IndentationBlock, WhitespaceBlock, LinebreakBlock + from pyVHDLParser.Blocks.Whitespace import IndentationBlock, WhitespaceBlock, LinebreakBlock token = parserState.Token if isinstance(token, SpaceToken): diff --git a/pyVHDLParser/CLI/Block.py b/pyVHDLParser/CLI/Block.py index c44041a72..3a3347323 100644 --- a/pyVHDLParser/CLI/Block.py +++ b/pyVHDLParser/CLI/Block.py @@ -36,7 +36,7 @@ from ..Token import Token, StartOfDocumentToken, EndOfDocumentToken from ..Token.Parser import Tokenizer from ..Blocks import Block, TokenToBlockParser, StartOfDocumentBlock, EndOfDocumentBlock, CommentBlock -from ..Blocks.Common import LinebreakBlock, IndentationBlock +from ..Blocks.Whitespace import LinebreakBlock, IndentationBlock from ..Blocks.List import GenericList, PortList from ..Blocks.InterfaceObject import InterfaceConstantBlock, InterfaceSignalBlock from ..Blocks.Structural import Entity diff --git a/pyVHDLParser/Filters/Comment.py b/pyVHDLParser/Filters/Comment.py index 40b99ad6e..0c617a588 100644 --- a/pyVHDLParser/Filters/Comment.py +++ b/pyVHDLParser/Filters/Comment.py @@ -30,7 +30,7 @@ from typing import Generator, Any from pyVHDLParser.Blocks import BlockParserException, CommentBlock, Block -from pyVHDLParser.Blocks.Common import IndentationBlock, LinebreakBlock, WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import IndentationBlock, LinebreakBlock, WhitespaceBlock # from pyVHDLParser.Blocks.Document import CommentBlock diff --git a/pyVHDLParser/Groups/Comment.py b/pyVHDLParser/Groups/Comment.py index b13190a1e..b6e138832 100644 --- a/pyVHDLParser/Groups/Comment.py +++ b/pyVHDLParser/Groups/Comment.py @@ -30,7 +30,7 @@ from pyTooling.Decorators import export from pyVHDLParser.Blocks import CommentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock, LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock, LinebreakBlock, IndentationBlock from pyVHDLParser.Groups import BlockToGroupParser, GroupParserException, Group diff --git a/pyVHDLParser/Groups/DesignUnit.py b/pyVHDLParser/Groups/DesignUnit.py index f98a67e2b..29d5d01fd 100644 --- a/pyVHDLParser/Groups/DesignUnit.py +++ b/pyVHDLParser/Groups/DesignUnit.py @@ -33,7 +33,7 @@ from pyTooling.Decorators import export from pyVHDLParser.Blocks import CommentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.List import GenericList, ParameterList, PortList from pyVHDLParser.Blocks.Object.Signal import SignalDeclarationBlock from pyVHDLParser.Blocks.Object.Constant import ConstantDeclarationBlock diff --git a/pyVHDLParser/Groups/List.py b/pyVHDLParser/Groups/List.py index 4870d510a..152d1c9f8 100644 --- a/pyVHDLParser/Groups/List.py +++ b/pyVHDLParser/Groups/List.py @@ -30,7 +30,7 @@ from pyTooling.Decorators import export from pyVHDLParser.Blocks import CommentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock import pyVHDLParser.Blocks.InterfaceObject from pyVHDLParser.Blocks.List import GenericList, ParameterList, PortList, SensitivityList from pyVHDLParser.Groups import BlockToGroupParser, GroupParserException, Group, EndOfDocumentGroup diff --git a/pyVHDLParser/Groups/Sequential/Function.py b/pyVHDLParser/Groups/Sequential/Function.py index 887c1d104..cfd86c85f 100644 --- a/pyVHDLParser/Groups/Sequential/Function.py +++ b/pyVHDLParser/Groups/Sequential/Function.py @@ -34,7 +34,7 @@ from pyVHDLParser.Token.Keywords import EndToken from pyVHDLParser.Blocks import CommentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.List import GenericList, ParameterList from pyVHDLParser.Blocks.Object.Variable import VariableDeclarationBlock from pyVHDLParser.Blocks.Object.Constant import ConstantDeclarationBlock diff --git a/pyVHDLParser/Groups/Sequential/Procedure.py b/pyVHDLParser/Groups/Sequential/Procedure.py index 4b9ff15c6..2a8b18eb9 100644 --- a/pyVHDLParser/Groups/Sequential/Procedure.py +++ b/pyVHDLParser/Groups/Sequential/Procedure.py @@ -33,7 +33,7 @@ from pyTooling.Decorators import export from pyVHDLParser.Blocks import CommentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.List import GenericList, ParameterList from pyVHDLParser.Blocks.Object.Variable import VariableDeclarationBlock from pyVHDLParser.Blocks.Object.Constant import ConstantDeclarationBlock diff --git a/pyVHDLParser/Groups/Sequential/Process.py b/pyVHDLParser/Groups/Sequential/Process.py index 0b8ce55b5..bfa42fbce 100644 --- a/pyVHDLParser/Groups/Sequential/Process.py +++ b/pyVHDLParser/Groups/Sequential/Process.py @@ -33,7 +33,7 @@ from pyTooling.Decorators import export from pyVHDLParser.Blocks import CommentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.List import SensitivityList, GenericList, ParameterList from pyVHDLParser.Blocks.Object.Variable import VariableDeclarationBlock from pyVHDLParser.Blocks.Object.Constant import ConstantDeclarationBlock diff --git a/pyVHDLParser/Groups/__init__.py b/pyVHDLParser/Groups/__init__.py index 9f3b96c04..ac16b684b 100644 --- a/pyVHDLParser/Groups/__init__.py +++ b/pyVHDLParser/Groups/__init__.py @@ -38,7 +38,7 @@ from pyVHDLParser import StartOfDocument, EndOfDocument, StartOfSnippet, EndOfSnippet from pyVHDLParser.Base import ParserException from pyVHDLParser.Blocks import Block, CommentBlock, StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.Reference import Context, Library, Use from pyVHDLParser.Blocks.Sequential import Package, PackageBody from pyVHDLParser.Blocks.Structural import Entity, Architecture, Configuration diff --git a/pyVHDLParser/__init__.py b/pyVHDLParser/__init__.py index ad4ab1c75..c869033e0 100644 --- a/pyVHDLParser/__init__.py +++ b/pyVHDLParser/__init__.py @@ -37,6 +37,8 @@ __version__ = "0.9.0" __keywords__ = ["parser", "vhdl", "code generator", "hdl"] +from typing import Any + from pyTooling.Decorators import export from pyTooling.MetaClasses import ExtendedType diff --git a/test/BlockParserTests/ArchitectureTest.py b/test/BlockParserTests/ArchitectureTest.py index acbdd6816..0beb8cc58 100644 --- a/test/BlockParserTests/ArchitectureTest.py +++ b/test/BlockParserTests/ArchitectureTest.py @@ -26,7 +26,7 @@ # ============================================================================== # # load dependencies -from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Structural import Architecture from test.TestCase import TestCase as TestCaseBase diff --git a/test/BlockParserTests/EntityTest.py b/test/BlockParserTests/EntityTest.py index 7926a5165..cb0de21ed 100644 --- a/test/BlockParserTests/EntityTest.py +++ b/test/BlockParserTests/EntityTest.py @@ -26,7 +26,7 @@ # ============================================================================== # # load dependencies -from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Structural import Entity diff --git a/test/BlockParserTests/GenericListTest.py b/test/BlockParserTests/GenericListTest.py index cc1d979ed..a4ba5ac0c 100644 --- a/test/BlockParserTests/GenericListTest.py +++ b/test/BlockParserTests/GenericListTest.py @@ -27,7 +27,7 @@ # # load dependencies import pyVHDLParser.Blocks.InterfaceObject -from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Structural import Entity diff --git a/test/BlockParserTests/LibraryTest.py b/test/BlockParserTests/LibraryTest.py index 2ea05fbcb..9662e7440 100644 --- a/test/BlockParserTests/LibraryTest.py +++ b/test/BlockParserTests/LibraryTest.py @@ -26,7 +26,7 @@ # ============================================================================== # # load dependencies -from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock, CommentBlock from pyVHDLParser.Blocks.Reference import Library from test.TestCase import TestCase as TestCaseBase diff --git a/test/BlockParserTests/PackageBodyTest.py b/test/BlockParserTests/PackageBodyTest.py index c9c747989..88f74d231 100644 --- a/test/BlockParserTests/PackageBodyTest.py +++ b/test/BlockParserTests/PackageBodyTest.py @@ -26,7 +26,7 @@ # ============================================================================== # # load dependencies -from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Sequential import PackageBody diff --git a/test/BlockParserTests/PackageTest.py b/test/BlockParserTests/PackageTest.py index c3f6641b4..f2707dc03 100644 --- a/test/BlockParserTests/PackageTest.py +++ b/test/BlockParserTests/PackageTest.py @@ -26,7 +26,7 @@ # ============================================================================== # # load dependencies -from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Sequential import Package diff --git a/test/BlockParserTests/PortListTest.py b/test/BlockParserTests/PortListTest.py index 935379d60..06e52a007 100644 --- a/test/BlockParserTests/PortListTest.py +++ b/test/BlockParserTests/PortListTest.py @@ -27,7 +27,7 @@ # # load dependencies import pyVHDLParser.Blocks.InterfaceObject -from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Structural import Entity diff --git a/test/BlockParserTests/ProcessTest.py b/test/BlockParserTests/ProcessTest.py index cb2f89ea1..1d433bd40 100644 --- a/test/BlockParserTests/ProcessTest.py +++ b/test/BlockParserTests/ProcessTest.py @@ -26,7 +26,7 @@ # ============================================================================== # # load dependencies -from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Structural import Architecture diff --git a/test/BlockParserTests/UseTest.py b/test/BlockParserTests/UseTest.py index ab084a8e5..2d6c9a46f 100644 --- a/test/BlockParserTests/UseTest.py +++ b/test/BlockParserTests/UseTest.py @@ -27,7 +27,7 @@ # # load dependencies from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, EmptyLineBlock, WhitespaceBlock, IndentationBlock from pyVHDLParser.Blocks.Reference import Use from test.TestCase import TestCase as TestCaseBase from test.Counter import Counter diff --git a/tests/unit/SimpleBlockSequences/Architecture.py b/tests/unit/SimpleBlockSequences/Architecture.py index 80916051f..d1057f693 100644 --- a/tests/unit/SimpleBlockSequences/Architecture.py +++ b/tests/unit/SimpleBlockSequences/Architecture.py @@ -31,7 +31,7 @@ from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken, MultiLineCommentToken, SingleLineCommentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock, CommentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock, IndentationBlock, LinebreakBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock, IndentationBlock, LinebreakBlock from pyVHDLParser.Blocks.Structural import Architecture from tests.unit.Common import Result, Initializer, ExpectedTokenStream, ExpectedBlockStream, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence diff --git a/tests/unit/SimpleBlockSequences/Assert.py b/tests/unit/SimpleBlockSequences/Assert.py index 897c22dc4..f6fbd023c 100644 --- a/tests/unit/SimpleBlockSequences/Assert.py +++ b/tests/unit/SimpleBlockSequences/Assert.py @@ -31,7 +31,7 @@ from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken, StringLiteralToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Reporting import Assert from pyVHDLParser.Blocks.Structural import Architecture diff --git a/tests/unit/SimpleBlockSequences/Constant.py b/tests/unit/SimpleBlockSequences/Constant.py index a1faa9ea2..3e298114a 100644 --- a/tests/unit/SimpleBlockSequences/Constant.py +++ b/tests/unit/SimpleBlockSequences/Constant.py @@ -30,7 +30,7 @@ from unittest import TestCase from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Object import Constant from pyVHDLParser.Blocks.Structural import Architecture from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken, IntegerLiteralToken diff --git a/tests/unit/SimpleBlockSequences/Context.py b/tests/unit/SimpleBlockSequences/Context.py index 13ced3cc4..67b336a5b 100644 --- a/tests/unit/SimpleBlockSequences/Context.py +++ b/tests/unit/SimpleBlockSequences/Context.py @@ -29,7 +29,7 @@ # from unittest import TestCase -from pyVHDLParser.Blocks.Common import WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Reference import Use, Context from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock diff --git a/tests/unit/SimpleBlockSequences/Entity.py b/tests/unit/SimpleBlockSequences/Entity.py index 407be8f03..2d1c9b6d6 100644 --- a/tests/unit/SimpleBlockSequences/Entity.py +++ b/tests/unit/SimpleBlockSequences/Entity.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock, LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock, LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.Structural import Entity from pyVHDLParser.Blocks.List import GenericList diff --git a/tests/unit/SimpleBlockSequences/Function.py b/tests/unit/SimpleBlockSequences/Function.py index 4e09acfbf..ab00a2eab 100644 --- a/tests/unit/SimpleBlockSequences/Function.py +++ b/tests/unit/SimpleBlockSequences/Function.py @@ -31,7 +31,7 @@ from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Sequential import Package, Function from tests.unit.Common import Initializer, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence, ExpectedTokenStream, ExpectedBlockStream diff --git a/tests/unit/SimpleBlockSequences/Package.py b/tests/unit/SimpleBlockSequences/Package.py index f8835d6ee..598c74005 100644 --- a/tests/unit/SimpleBlockSequences/Package.py +++ b/tests/unit/SimpleBlockSequences/Package.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock, LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock, LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.List import GenericList from pyVHDLParser.Blocks.Sequential import Package diff --git a/tests/unit/SimpleBlockSequences/PackageBody.py b/tests/unit/SimpleBlockSequences/PackageBody.py index 548da4626..88f7d5c1e 100644 --- a/tests/unit/SimpleBlockSequences/PackageBody.py +++ b/tests/unit/SimpleBlockSequences/PackageBody.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock, LinebreakBlock, IndentationBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock, LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.List import GenericList from pyVHDLParser.Blocks.Sequential import PackageBody diff --git a/tests/unit/SimpleBlockSequences/PortList.py b/tests/unit/SimpleBlockSequences/PortList.py index ea5342c26..3ff158dd3 100644 --- a/tests/unit/SimpleBlockSequences/PortList.py +++ b/tests/unit/SimpleBlockSequences/PortList.py @@ -33,7 +33,7 @@ from pyVHDLParser.Blocks.List.PortList import PortListInterfaceSignalBlock from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Structural import Entity from tests.unit.Common import Initializer, ExpectedDataMixin, LinkingTests, TokenLinking, TokenSequence, BlockSequence, ExpectedTokenStream, ExpectedBlockStream diff --git a/tests/unit/SimpleBlockSequences/Procedure.py b/tests/unit/SimpleBlockSequences/Procedure.py index 2277d064d..8cc78c1ed 100644 --- a/tests/unit/SimpleBlockSequences/Procedure.py +++ b/tests/unit/SimpleBlockSequences/Procedure.py @@ -31,7 +31,7 @@ from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Sequential import Package, Procedure from tests.unit.Common import Initializer, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence, ExpectedTokenStream, ExpectedBlockStream diff --git a/tests/unit/SimpleBlockSequences/Process.py b/tests/unit/SimpleBlockSequences/Process.py index 142fbf3e1..6cabcbc84 100644 --- a/tests/unit/SimpleBlockSequences/Process.py +++ b/tests/unit/SimpleBlockSequences/Process.py @@ -31,7 +31,7 @@ from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Structural import Architecture from pyVHDLParser.Blocks.Sequential import Process diff --git a/tests/unit/SimpleBlockSequences/Signal.py b/tests/unit/SimpleBlockSequences/Signal.py index 3278ce4d7..4fa5000f9 100644 --- a/tests/unit/SimpleBlockSequences/Signal.py +++ b/tests/unit/SimpleBlockSequences/Signal.py @@ -31,7 +31,7 @@ from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import WhitespaceBlock +from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Object import Signal from pyVHDLParser.Blocks.Structural import Architecture diff --git a/tests/unit/SimpleBlockSequences/Use.py b/tests/unit/SimpleBlockSequences/Use.py index 103975f00..c849555d0 100644 --- a/tests/unit/SimpleBlockSequences/Use.py +++ b/tests/unit/SimpleBlockSequences/Use.py @@ -31,7 +31,7 @@ from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock -from pyVHDLParser.Blocks.Common import LinebreakBlock +from pyVHDLParser.Blocks.Whitespace import LinebreakBlock from pyVHDLParser.Blocks.Reference import Use from tests.unit.Common import Initializer, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence, ExpectedTokenStream, ExpectedBlockStream From c1e526ed770ec7e60a76401d0c22bb7be1b613cd Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 2 Apr 2023 22:04:50 +0200 Subject: [PATCH 04/15] Reworked token documentation. --- pyVHDLParser/Token/__init__.py | 434 ++++++++++++++++++++++++++------- 1 file changed, 350 insertions(+), 84 deletions(-) diff --git a/pyVHDLParser/Token/__init__.py b/pyVHDLParser/Token/__init__.py index c1d5dea42..dfb84862e 100644 --- a/pyVHDLParser/Token/__init__.py +++ b/pyVHDLParser/Token/__init__.py @@ -27,10 +27,10 @@ # limitations under the License. # # ==================================================================================================================== # # -from typing import Iterator +from typing import Iterator, Optional as Nullable from pyTooling.Decorators import export -from pyTooling.MetaClasses import ExtendedType +from pyTooling.MetaClasses import ExtendedType from pyVHDLParser import SourceCodePosition, StartOfDocument, EndOfDocument, StartOfSnippet, EndOfSnippet from pyVHDLParser.Base import ParserException @@ -73,113 +73,221 @@ def CharacterTranslation(value: str, oneLiner: bool = False) -> str: @export class TokenIterator(metaclass=ExtendedType, useSlots=True): - startToken: 'Token' - currentToken: 'Token' - stopToken: 'Token' - inclusiveStopToken: bool + """A token iterator to iterate tokens in ascending/forward order.""" - state: int #: internal states: 0 = normal, 1 = reached stopToken, 2 = reached EndOfToken + _startToken: 'Token' #: First token for the iteration. + _currentToken: 'Token' #: Next token to return. + _stopToken: Nullable['Token'] #: Token to stop iteration at or before. + _inclusiveStartToken: bool #: If true, the first returned token is the start token, otherwise one token after. + _inclusiveStopToken: bool #: If true, the last returned token is the stop token, otherwise one token before. + + state: int #: Internal states: 0 = normal, 1 = reached stopToken, 2 = reached EndOfToken def __init__(self, startToken: 'Token', inclusiveStartToken: bool=False, inclusiveStopToken: bool=True, stopToken: 'Token'=None): - self.startToken = startToken - self.currentToken = startToken if inclusiveStartToken else startToken.NextToken - self.stopToken = stopToken - self.inclusiveStopToken = inclusiveStopToken + """ + Initializes an ascending/forward iterator for a double-linked chain of tokens. - self.state = 0 + :param startToken: First token to start the iteration at or after. + :param inclusiveStartToken: If true, the first returned token is the start token, otherwise one token after. + :param inclusiveStopToken: If true, the last returned token is the stop token, otherwise one token before. + :param stopToken: Token to stop iteration at or before. + """ + self._startToken = startToken + self._currentToken = startToken if inclusiveStartToken else startToken.NextToken + self._stopToken = stopToken + self._inclusiveStartToken = inclusiveStartToken + self._inclusiveStopToken = inclusiveStopToken + + self.state = 0 def __iter__(self) -> 'TokenIterator': + """ + Return itself to fulfil the iterator protocol. + + :returns: Itself. + """ return self def __next__(self) -> 'Token': + """ + Returns the next token in the token-chain. + + :returns: Next token. + """ # in last call of '__next__', the last token in the sequence was returned if self.state > 0: raise StopIteration(self.state) - token = self.currentToken - if token is self.stopToken: - if not self.inclusiveStopToken: + token = self._currentToken + if token is self._stopToken: + if not self._inclusiveStopToken: raise StopIteration(1) else: - self.currentToken = None + self._currentToken = None self.state = 1 - elif isinstance(self.currentToken, EndOfToken): - if not self.inclusiveStopToken: + elif isinstance(self._currentToken, EndOfToken): + if not self._inclusiveStopToken: raise StopIteration(2) else: - self.currentToken = None + self._currentToken = None self.state = 2 else: - self.currentToken = token.NextToken - if self.currentToken is None: + self._currentToken = token.NextToken + if self._currentToken is None: raise ParserException("Found open end while iterating token sequence.") # FIXME: how to append last token? return token + @property + def StartToken(self) -> 'Token': + """ + A read-only property to return the iterators start token. + + :return: First token of the iterator. + """ + return self._startToken + + @property + def CurrentToken(self) -> 'Token': + """ + A read-only property to return the iterators current token. + + :return: Current token of the iterator. + """ + return self._currentToken + + @property + def StopToken(self) -> 'Token': + """ + A read-only property to return the iterators stop token. + + :return: Last token of the iterator. + """ + return self._stopToken + + def Reset(self) -> None: + self._currentToken = self._startToken if self._inclusiveStartToken else self._startToken.NextToken + @export class TokenReverseIterator(metaclass=ExtendedType, useSlots=True): - startToken: 'Token' - currentToken: 'Token' - stopToken: 'Token' - inclusiveStopToken: bool + """A token iterator to iterate tokens in descending/backward order.""" + + _startToken: 'Token' #: First token for the iteration. + _currentToken: 'Token' #: Next token to return. + _stopToken: Nullable['Token'] #: Token to stop iteration at or before. + _inclusiveStartToken: bool #: If true, the first returned token is the start token, otherwise one token after. + _inclusiveStopToken: bool #: If true, the last returned token is the stop token, otherwise one token before. - state: int #: internal states: 0 = normal, 1 = reached stopToken, 2 = reached StartOfToken + state: int #: Internal states: 0 = normal, 1 = reached stopToken, 2 = reached StartOfToken def __init__(self, startToken: 'Token', inclusiveStartToken: bool=False, inclusiveStopToken: bool=True, stopToken: 'Token'=None): - self.startToken = startToken - self.currentToken = startToken if inclusiveStartToken else startToken.PreviousToken - self.stopToken = stopToken - self.inclusiveStopToken = inclusiveStopToken + """ + Initializes a descending/backward iterator for a double-linked chain of tokens. + + :param startToken: First token to start the iteration at or after. + :param inclusiveStartToken: If true, the first returned token is the start token, otherwise one token after. + :param inclusiveStopToken: If true, the last returned token is the stop token, otherwise one token before. + :param stopToken: Token to stop iteration at or before. + """ + self._startToken = startToken + self._currentToken = startToken if inclusiveStartToken else startToken.PreviousToken + self._stopToken = stopToken + self._inclusiveStartToken = inclusiveStartToken + self._inclusiveStopToken = inclusiveStopToken - self.state = 0 + self.state = 0 def __iter__(self) -> 'TokenReverseIterator': + """ + Return itself to fulfil the iterator protocol. + + :returns: Itself. + """ return self def __next__(self) -> 'Token': + """ + Returns the previous token in the token-chain. + + :returns: Previous token. + """ # in last call of '__next__', the last token in the sequence was returned if self.state > 0: raise StopIteration(self.state) - token = self.currentToken - if token is self.stopToken: + token = self._currentToken + if token is self._stopToken: self.state = 1 - if not self.inclusiveStopToken: + if not self._inclusiveStopToken: raise StopIteration(self.state) else: - self.currentToken = None - elif isinstance(self.currentToken, EndOfToken): + self._currentToken = None + elif isinstance(self._currentToken, EndOfToken): self.state = 2 - if not self.inclusiveStopToken: + if not self._inclusiveStopToken: raise StopIteration(self.state) else: - self.currentToken = None + self._currentToken = None else: - self.currentToken = token.PreviousToken - if self.currentToken is None: + self._currentToken = token.PreviousToken + if self._currentToken is None: raise ParserException("Found open end while iterating token sequence.") # FIXME: how to append last token? return token + @property + def StartToken(self) -> 'Token': + """ + A read-only property to return the iterators start token. + + :return: First token of the iterator. + """ + return self._startToken + + @property + def CurrentToken(self) -> 'Token': + """ + A read-only property to return the iterators current token. + + :return: Current token of the iterator. + """ + return self._currentToken + + @property + def StopToken(self) -> 'Token': + """ + A read-only property to return the iterators stop token. + + :return: Last token of the iterator. + """ + return self._stopToken + + def Reset(self) -> None: + self._currentToken = self._startToken if self._inclusiveStartToken else self._startToken.PreviousToken + @export class Token(metaclass=ExtendedType, useSlots=True): """Base-class for all token classes.""" - _previousToken: 'Token' #: Reference to the previous token - NextToken: 'Token' #: Reference to the next token - Start: SourceCodePosition #: Position for the token start - End: SourceCodePosition #: Position for the token end + _previousToken: 'Token' #: Reference to the previous token (backward pointer) + NextToken: Nullable['Token'] #: Reference to the next token (forward pointer) + Start: SourceCodePosition #: Position in the file for the token start + End: SourceCodePosition #: Position in the file for the token end - def __init__(self, previousToken: 'Token', start: SourceCodePosition, end: SourceCodePosition = None): + def __init__(self, previousToken: 'Token', start: SourceCodePosition, end: SourceCodePosition): """ - Initializes a token object. + Initializes a new token object and links it with the previous token. While initialization, the following additional tasks are done: * link this token to previous token. * link previous token to this token. + + :param previousToken: The previous token, so the double-linked list can be created. + :param start: The source code position for the token's first character. + :param end: The source code position for the token's last character. """ previousToken.NextToken = self self._previousToken = previousToken @@ -188,12 +296,39 @@ def __init__(self, previousToken: 'Token', start: SourceCodePosition, end: Sourc self.End = end def __len__(self) -> int: + """ + Returns the length of a token in characters. + + :return: Length of the token. + """ return self.End.Absolute - self.Start.Absolute + 1 def GetIterator(self, inclusiveStartToken: bool = False, inclusiveStopToken: bool = True, stopToken: 'Token' = None) -> Iterator['Token']: + """ + Creates an iterator to iterate tokens in ascending/forward order following the :data:`pyVHDLParser.Token.Token.NextToken` references. + + :param inclusiveStartToken: If true, the start token is also returned by the iterator. |br| + By default, it's excluded. + :param inclusiveStopToken: If true, the stop token is also returned by the iterator. |br| + By default, it's included. + :param stopToken: Optional stop token, where the iterator stops. |br| + By default, it iterates until :class:`pyVHDLParser.Token.EndOfToken` is found. + :return: An :class:`ascending/forward iterator ` on tokens. + """ return TokenIterator(self, inclusiveStartToken=inclusiveStartToken, inclusiveStopToken=inclusiveStopToken, stopToken=stopToken) def GetReverseIterator(self, inclusiveStartToken: bool = False, inclusiveStopToken: bool = True, stopToken: 'Token' = None) -> Iterator['Token']: + """ + Creates an iterator to iterate tokens in descending/backward order following the :data:`pyVHDLParser.Token.Token._previousToken` references. + + :param inclusiveStartToken: If true, the start token is also returned by the iterator. |br| + By default, it's excluded. + :param inclusiveStopToken: If true, the stop token is also returned by the iterator. |br| + By default, it's included. + :param stopToken: Optional stop token, where the iterator stops. |br| + By default, it iterates until :class:`pyVHDLParser.Token.StartOfToken` is found. + :return: A :class:`descending/backward iterator ` on tokens. + """ return TokenReverseIterator(self, inclusiveStartToken=inclusiveStartToken, inclusiveStopToken=inclusiveStopToken, stopToken=stopToken) @property @@ -207,7 +342,12 @@ def PreviousToken(self, value: 'Token'): @property def Length(self) -> int: - return len(self) + """ + A read-only property to return the length of the token. + + :return: Length of the token. + """ + return self.__len__() def __str__(self) -> str: return f"{self.__class__.__qualname__} at {self.Start!s}" @@ -224,23 +364,58 @@ class ValuedToken(Token): A ValuedToken contains a :attr:`Value` field for the underlying string from the source code file. """ - Value: str #: String value of this token. + Value: str #: String value of the token. + + def __init__(self, previousToken: Token, value: str, start: SourceCodePosition, end: SourceCodePosition): + """ + Initializes a new *valued* token object and links it with the previous token. + + While initialization, the following additional tasks are done: + + * link this token to previous token. + * link previous token to this token. - def __init__(self, previousToken: Token, value: str, start: SourceCodePosition, end: SourceCodePosition = None): - """Initializes a *valued* token object.""" + :param previousToken: The previous token, so the double-linked list can be created. + :param value: The string value of the token. + :param start: The source code position for the token's first character. + :param end: The source code position for the token's last character. + """ super().__init__(previousToken, start, end) self.Value = value def __iter__(self) -> Iterator[str]: + """ + Returns an iterator to iterate the token's internal value. + + :returns: Iterator to iterate the token's string value. + """ return iter(self.Value) def __eq__(self, other: str) -> bool: - """Return true if the internal value is equal to the second operand.""" - return self.Value == other + """ + Returns true, if the token's internal value is equal to the second operand. + + :param other: Parameter to compare against. + :returns: ``True``, if token's value and second operand are equal. + :raises TypeError: If second operand is not of type :py:class:`str`. + """ + if isinstance(other, str): + return self.Value == other + else: + raise TypeError(f"Second operand of type '{other.__class__.__name__}' is not supported by equal operator.") def __ne__(self, other: str) -> bool: - """Return true if the internal value is unequal to the second operand.""" - return self.Value != other + """ + Returns true, if the token's internal value is unequal to the second operand. + + :param other: Parameter to compare against. + :returns: ``True``, if token's value and second operand are unequal. + :raises TypeError: If second operand is not of type :py:class:`str`. + """ + if isinstance(other, str): + return self.Value != other + else: + raise TypeError(f"Second operand of type '{other.__class__.__name__}' is not supported by unequal operator.") def __hash__(self): return super().__hash__() @@ -258,14 +433,23 @@ class StartOfToken(Token): """Base-class for meta-tokens representing the start of a token stream.""" def __init__(self): - """Initializes a StartOfToken object.""" + """ + Initializes the first token object in a chain of tokens. + + As this is the first token in the token-chain, :data:`_previousToken` is set to ``None``, the :data:`Start` is set + to :pycode:`SourceCodePosition(1, 1, 1)` and :data:`End` is set to :data:`Start`. + """ self._previousToken = None self.NextToken = None self.Start = SourceCodePosition(1, 1, 1) - self.End = None + self.End = self.Start def __len__(self) -> int: - """Returns always 0.""" + """ + Returns the length of the meta-token. It's always 0. + + :return: Returns always 0. + """ return 0 def __str__(self) -> str: @@ -277,11 +461,22 @@ class EndOfToken(Token): """Base-class for meta-tokens representing the end of a token stream.""" def __init__(self, previousToken: Token, end: SourceCodePosition): - """Initializes a EndOfToken object.""" + """ + Initializes the last token object in a chain of tokens. + + As this is the last token in the token-chain, only the previous token and its end position are needed as parameters. + + :param previousToken: The previous token, so the double-linked list can be created. + :param end: The source code position for the token's last character. + """ super().__init__(previousToken, start=end, end=end) def __len__(self) -> int: - """Returns always 0.""" + """ + Returns the length of the meta-token. It's always 0. + + :return: Returns always 0. + """ return 0 def __str__(self) -> str: @@ -290,22 +485,26 @@ def __str__(self) -> str: @export class StartOfDocumentToken(StartOfToken, StartOfDocument): - pass + """ + A meta-token, that represents the start of a token-chain if the tokenizer was applied to a whole source code document. + """ @export class EndOfDocumentToken(EndOfToken, EndOfDocument): - pass + """ + A meta-token, that represents the end of a token-chain if the tokenizer was applied to a whole source code document. + """ @export class StartOfSnippetToken(StartOfToken, StartOfSnippet): - pass + """A meta-token, that represents the start of a token-chain if the tokenizer was applied to a source code snippet.""" @export class EndOfSnippetToken(EndOfToken, EndOfSnippet): - pass + """A meta-token, that represents the end of a token-chain if the tokenizer was applied to a source code snippet.""" @export @@ -313,6 +512,20 @@ class CharacterToken(ValuedToken): """Token representing a single character.""" def __init__(self, previousToken: Token, value: str, start: SourceCodePosition): + """ + Initializes a new *valued* token object and links it with the previous token. + + While initialization, the following additional tasks are done: + + * link this token to previous token. + * link previous token to this token. + + :param previousToken: The previous token, so the double-linked list can be created. + :param value: The string value of the token. + :param start: The source code position for the token's first character. + :param end: The source code position for the token's last character. + """ + """ Initializes a CharacterToken object. @@ -321,6 +534,11 @@ def __init__(self, previousToken: Token, value: str, start: SourceCodePosition): super().__init__(previousToken, value, start=start, end=start) def __len__(self) -> int: + """ + Returns the length of a character token. It's always 1. + + :return: Returns always 1. + """ return 1 def __repr__(self) -> str: @@ -333,13 +551,31 @@ class FusedCharacterToken(CharacterToken): """Token representing a double (or triple) character.""" def __init__(self, previousToken: Token, value: str, start: SourceCodePosition, end: SourceCodePosition): + """ + Initializes a new *valued* token object and links it with the previous token. + + While initialization, the following additional tasks are done: + + * link this token to previous token. + * link previous token to this token. + + :param previousToken: The previous token, so the double-linked list can be created. + :param value: The string value of the token. + :param start: The source code position for the token's first character. + :param end: The source code position for the token's last character. + """ """Initializes a FusedCharacterToken object.""" super().__init__(previousToken, value, start=start) self.End = end # FIXME: check if base-base class implementation could solve this question. def __len__(self) -> int: - return len(self.Value) + """ + Returns the length of a fused-character token. + + :return: Length of the token. + """ + return self.End.Absolute - self.Start.Absolute + 1 def __repr__(self) -> str: char = "'" + self.Value + "' " @@ -348,7 +584,7 @@ def __repr__(self) -> str: @export class SpaceToken(ValuedToken): - """Token representing a space (space or tab).""" + """Token representing a whitespace (space or tab).""" def __repr__(self) -> str: value = "'" + self.Value + "' " @@ -357,26 +593,65 @@ def __repr__(self) -> str: @export class WordToken(ValuedToken): - """Token representing a string.""" + """ + First-pass token representing a string. + + In a second pass, this token is replaced by an identifier token or keyword token. + """ + _lowerValue: str #: Pre-converted value to lower case string. + + def __init__(self, previousToken: Token, value: str, start: SourceCodePosition, end: SourceCodePosition): + """ + Initializes a new word-token object and links it with the previous token. + + While initialization, the following additional tasks are done: + + * link this token to previous token. + * link previous token to this token. + + :param previousToken: The previous token, so the double-linked list can be created. + :param value: The string value of the token. + :param start: The source code position for the token's first character. + :param end: The source code position for the token's last character. + """ + super().__init__(previousToken, value, start, end) + self._lowerValue = value.lower() def __eq__(self, other: str) -> bool: - """Return true if the internal value is equal to the second operand.""" + """ + Returns true, if the token's internal value is equal to the second operand. + + :param other: Parameter to compare against. + :returns: ``True``, if token's value and second operand are equal. + """ return self.Value == other def __ne__(self, other: str) -> bool: - """Return true if the internal value is unequal to the second operand.""" + """ + Returns true, if the token's internal value is unequal to the second operand. + + :param other: Parameter to compare against. + :returns: ``True``, if token's value and second operand are unequal. + """ return self.Value != other def __le__(self, other: str) -> bool: - """Return true if the internal value is equivalent (lower case, string compare) to the second operand.""" - return self.Value.lower() == other + """ + Returns true, if the token's internal value is equivalent (lower case, string compare) to the second operand. - def __ge__(self, other: str) -> bool: - """Return true if the internal value is equivalent (upper case, string compare) to the second operand.""" - return self.Value.upper() == other + :param other: Parameter to compare against. + :returns: ``True``, if token's lower case value and second operand are equal. + """ + return self._lowerValue == other - def __hash__(self): - return super().__hash__() + # def __ge__(self, other: str) -> bool: + # """ + # Returns true, if the token's internal value is equivalent (upper case, string compare) to the second operand. + # + # :param other: Parameter to compare against. + # :returns: ``True``, if token's upper case value and second operand are equal. + # """ + # return self.Value.upper() == other def __repr__(self) -> str: value = "'" + self.Value + "' " @@ -415,15 +690,6 @@ class MultiLineCommentToken(CommentToken): class LiteralToken(VHDLToken): """Base-class for all literals in VHDL.""" - def __eq__(self, other: str): - return self.Value == other - - def __ne__(self, other: str): - return self.Value != other - - def __hash__(self): - return super().__hash__() - def __repr__(self) -> str: value = self.Value + " " return f"<{self.__class__.__name__: <50} {value:.<59} at {self.Start!r}>" From 787ab5727c0c0f57fe6f4a5c4ed9addda6c32fc8 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 2 Apr 2023 22:40:30 +0200 Subject: [PATCH 05/15] Renamed SpaceToken to WhitespaceToken. --- pyVHDLParser/ANTLR4/__init__.py | 4 +- .../Blocks/Assignment/SignalAssignment.py | 10 +- .../Blocks/Assignment/VariableAssignment.py | 10 +- .../Blocks/Attribute/AttributeDeclaration.py | 22 +- .../Attribute/AttributeSpecification.py | 22 +- pyVHDLParser/Blocks/Comment.py | 4 +- pyVHDLParser/Blocks/ControlStructure/Case.py | 14 +- pyVHDLParser/Blocks/ControlStructure/Exit.py | 14 +- .../Blocks/ControlStructure/ForLoop.py | 14 +- pyVHDLParser/Blocks/ControlStructure/If.py | 10 +- pyVHDLParser/Blocks/ControlStructure/Next.py | 14 +- pyVHDLParser/Blocks/ControlStructure/Null.py | 6 +- .../Blocks/ControlStructure/Return.py | 6 +- .../Blocks/ControlStructure/WhileLoop.py | 12 +- pyVHDLParser/Blocks/Expression.py | 24 +- pyVHDLParser/Blocks/Generate/CaseGenerate.py | 12 +- pyVHDLParser/Blocks/Generate/ForGenerate.py | 14 +- pyVHDLParser/Blocks/Generate/IfGenerate.py | 38 +-- pyVHDLParser/Blocks/Generic.py | 22 +- .../Instantiation/EntityInstantiation.py | 10 +- .../Instantiation/FunctionInstantiation.py | 10 +- .../Instantiation/PackageInstantiation.py | 10 +- .../Instantiation/ProcedureInstantiation.py | 10 +- pyVHDLParser/Blocks/InterfaceObject.py | 34 +-- pyVHDLParser/Blocks/List/GenericList.py | 10 +- pyVHDLParser/Blocks/List/GenericMapList.py | 14 +- pyVHDLParser/Blocks/List/ParameterList.py | 10 +- pyVHDLParser/Blocks/List/PortList.py | 10 +- pyVHDLParser/Blocks/List/PortMapList.py | 14 +- pyVHDLParser/Blocks/List/SensitivityList.py | 10 +- pyVHDLParser/Blocks/Object/Constant.py | 4 +- pyVHDLParser/Blocks/Object/SharedVariable.py | 12 +- pyVHDLParser/Blocks/Object/Signal.py | 4 +- pyVHDLParser/Blocks/Object/Variable.py | 4 +- pyVHDLParser/Blocks/Object/__init__.py | 16 +- pyVHDLParser/Blocks/Reference/Context.py | 12 +- pyVHDLParser/Blocks/Reference/Library.py | 14 +- pyVHDLParser/Blocks/Reference/Use.py | 30 +- pyVHDLParser/Blocks/Region.py | 8 +- pyVHDLParser/Blocks/Reporting/Assert.py | 26 +- pyVHDLParser/Blocks/Reporting/Report.py | 18 +- pyVHDLParser/Blocks/Sequential/Function.py | 30 +- pyVHDLParser/Blocks/Sequential/Package.py | 10 +- pyVHDLParser/Blocks/Sequential/PackageBody.py | 10 +- pyVHDLParser/Blocks/Sequential/Procedure.py | 14 +- pyVHDLParser/Blocks/Sequential/Process.py | 10 +- .../Blocks/Structural/Architecture.py | 18 +- pyVHDLParser/Blocks/Structural/Block.py | 10 +- pyVHDLParser/Blocks/Structural/Component.py | 12 +- .../Blocks/Structural/Configuration.py | 12 +- pyVHDLParser/Blocks/Structural/Entity.py | 10 +- pyVHDLParser/Blocks/Type/Subtype.py | 22 +- pyVHDLParser/Blocks/Type/Type.py | 22 +- pyVHDLParser/Blocks/Whitespace.py | 4 +- pyVHDLParser/Blocks/__init__.py | 4 +- pyVHDLParser/CLI/Group.py | 4 +- pyVHDLParser/CLI/Token.py | 4 +- pyVHDLParser/CLI/__init__.py | 4 +- pyVHDLParser/Token/Parser.py | 24 +- pyVHDLParser/Token/__init__.py | 4 +- .../unit/SimpleBlockSequences/Architecture.py | 78 ++--- tests/unit/SimpleBlockSequences/Assert.py | 22 +- tests/unit/SimpleBlockSequences/Constant.py | 26 +- tests/unit/SimpleBlockSequences/Context.py | 14 +- tests/unit/SimpleBlockSequences/Entity.py | 274 ++++++++--------- tests/unit/SimpleBlockSequences/Function.py | 16 +- tests/unit/SimpleBlockSequences/Library.py | 14 +- tests/unit/SimpleBlockSequences/Package.py | 274 ++++++++--------- .../unit/SimpleBlockSequences/PackageBody.py | 284 ++++++++--------- tests/unit/SimpleBlockSequences/PortList.py | 38 +-- tests/unit/SimpleBlockSequences/Procedure.py | 12 +- tests/unit/SimpleBlockSequences/Process.py | 22 +- tests/unit/SimpleBlockSequences/Signal.py | 22 +- tests/unit/SimpleBlockSequences/Use.py | 20 +- tests/unit/Tokenizer/Tokens.py | 288 +++++++++--------- 75 files changed, 1097 insertions(+), 1097 deletions(-) diff --git a/pyVHDLParser/ANTLR4/__init__.py b/pyVHDLParser/ANTLR4/__init__.py index 7b789ba16..07395b9c2 100644 --- a/pyVHDLParser/ANTLR4/__init__.py +++ b/pyVHDLParser/ANTLR4/__init__.py @@ -4,7 +4,7 @@ from .. import SourceCodePosition from ..Token import Token, StartOfDocumentToken, EndOfDocumentToken, FusedCharacterToken, IntegerLiteralToken, \ - IndentationToken, LinebreakToken, SpaceToken, SingleLineCommentToken, MultiLineCommentToken, CharacterToken, \ + IndentationToken, LinebreakToken, WhitespaceToken, SingleLineCommentToken, MultiLineCommentToken, CharacterToken, \ StringLiteralToken, BitStringLiteralToken from ..Token.Keywords import * @@ -188,7 +188,7 @@ def ConvertToTokenChain(self, tokenStream: CommonTokenStream) -> List[Token]: elif aToken.type == VHDLLexer.LIT_BIT_STRING: lastToken = BitStringLiteralToken(lastToken, aToken.text, start, start) elif aToken.type == VHDLLexer.WHITESPACE: - tokenType = IndentationToken if isinstance(lastToken, LinebreakToken) else SpaceToken + tokenType = IndentationToken if isinstance(lastToken, LinebreakToken) else WhitespaceToken lastToken = tokenType(lastToken, aToken.text, start) elif aToken.type == VHDLLexer.LINEBREAK: lastToken = LinebreakToken(lastToken, aToken.text, start) diff --git a/pyVHDLParser/Blocks/Assignment/SignalAssignment.py b/pyVHDLParser/Blocks/Assignment/SignalAssignment.py index 3050cdb8a..6817c2754 100644 --- a/pyVHDLParser/Blocks/Assignment/SignalAssignment.py +++ b/pyVHDLParser/Blocks/Assignment/SignalAssignment.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateSignalAssignmentKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateSignalAssignmentName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -143,7 +143,7 @@ def stateSignalAssignmentName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -181,7 +181,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Assignment/VariableAssignment.py b/pyVHDLParser/Blocks/Assignment/VariableAssignment.py index 3050cdb8a..6817c2754 100644 --- a/pyVHDLParser/Blocks/Assignment/VariableAssignment.py +++ b/pyVHDLParser/Blocks/Assignment/VariableAssignment.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateSignalAssignmentKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateSignalAssignmentName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -143,7 +143,7 @@ def stateSignalAssignmentName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -181,7 +181,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Attribute/AttributeDeclaration.py b/pyVHDLParser/Blocks/Attribute/AttributeDeclaration.py index 35850a8c6..8a4a7b4aa 100644 --- a/pyVHDLParser/Blocks/Attribute/AttributeDeclaration.py +++ b/pyVHDLParser/Blocks/Attribute/AttributeDeclaration.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, WordToken +from pyVHDLParser.Token import CharacterToken, LinebreakToken, WhitespaceToken, WordToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock @@ -65,7 +65,7 @@ def stateAttributeDeclarationKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateAttributeDeclarationName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -142,7 +142,7 @@ def stateAttributeDeclarationName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -183,7 +183,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateColon1() return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -218,7 +218,7 @@ def stateColon1(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -260,7 +260,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateTypeMarkName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -299,7 +299,7 @@ def stateTypeMarkName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace4 return @@ -336,7 +336,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -382,7 +382,7 @@ def stateVariableAssignment(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace5 return @@ -418,7 +418,7 @@ def stateWhitespace5(cls, parserState: TokenToBlockParser): elif isinstance(token, WordToken): parserState.NextState = cls.stateExpressionEnd return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Attribute/AttributeSpecification.py b/pyVHDLParser/Blocks/Attribute/AttributeSpecification.py index f1915cad6..ee3461eba 100644 --- a/pyVHDLParser/Blocks/Attribute/AttributeSpecification.py +++ b/pyVHDLParser/Blocks/Attribute/AttributeSpecification.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, WordToken +from pyVHDLParser.Token import CharacterToken, LinebreakToken, WhitespaceToken, WordToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateAttributeSpecificationKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateAttributeSpecificationName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -142,7 +142,7 @@ def stateAttributeSpecificationName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -183,7 +183,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateColon1() return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -218,7 +218,7 @@ def stateColon1(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -260,7 +260,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateTypeMarkName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -299,7 +299,7 @@ def stateTypeMarkName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace4 return @@ -336,7 +336,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -382,7 +382,7 @@ def stateVariableAssignment(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace5 return @@ -418,7 +418,7 @@ def stateWhitespace5(cls, parserState: TokenToBlockParser): elif isinstance(token, WordToken): parserState.NextState = cls.stateExpressionEnd return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Comment.py b/pyVHDLParser/Blocks/Comment.py index c85729d03..586ae140b 100644 --- a/pyVHDLParser/Blocks/Comment.py +++ b/pyVHDLParser/Blocks/Comment.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, IndentationToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, IndentationToken from pyVHDLParser.Token.Keywords import SingleLineCommentKeyword, MultiLineCommentStartKeyword, MultiLineCommentEndKeyword from pyVHDLParser.Blocks import CommentBlock, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import IndentationBlock @@ -61,7 +61,7 @@ def stateConsumeComment(cls, parserState: TokenToBlockParser): @classmethod def stateLinebreak(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) parserState.Pop() diff --git a/pyVHDLParser/Blocks/ControlStructure/Case.py b/pyVHDLParser/Blocks/ControlStructure/Case.py index 31698d617..33275b514 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Case.py +++ b/pyVHDLParser/Blocks/ControlStructure/Case.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken +from pyVHDLParser.Token import CharacterToken, LinebreakToken, WhitespaceToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, CaseKeyword, WhenKeyword, IsKeyword, EndKeyword, MapAssociationKeyword from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock @@ -86,7 +86,7 @@ def stateWhenKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = ArrowBlock.stateArrowKeyword parserState.PushState = WhenExpressionBlock.stateExpression return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -123,7 +123,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -144,7 +144,7 @@ class IsBlock(SequentialBeginBlock): @classmethod def stateIsKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) parserState.TokenMarker = None @@ -189,7 +189,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -216,7 +216,7 @@ def stateCaseKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = IsBlock.stateIsKeyword parserState.PushState = CaseExpressionBlock.stateExpression return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -253,7 +253,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/ControlStructure/Exit.py b/pyVHDLParser/Blocks/ControlStructure/Exit.py index aa0e22204..309907907 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Exit.py +++ b/pyVHDLParser/Blocks/ControlStructure/Exit.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token import WordToken, ExtendedIdentifier, CharacterToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, WhenKeyword from pyVHDLParser.Blocks import Block, TokenToBlockParser, CommentBlock, BlockParserException @@ -58,7 +58,7 @@ def stateExitKeyword(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) # parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken, multiPart=True) # parserState.TokenMarker = None @@ -102,7 +102,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -118,7 +118,7 @@ def stateExitLoopLabel(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) # parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) # parserState.TokenMarker = None @@ -153,7 +153,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -177,7 +177,7 @@ def stateWhenKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = EndBlock.stateError parserState.PushState = ExitConditionBlock.stateExpression return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -214,7 +214,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): return elif isinstance(token, IndentationToken) and isinstance(token.PreviousToken, (LinebreakToken, SingleLineCommentToken)): return - elif (isinstance(token, SpaceToken) and ( + elif (isinstance(token, WhitespaceToken) and ( isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken))): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) diff --git a/pyVHDLParser/Blocks/ControlStructure/ForLoop.py b/pyVHDLParser/Blocks/ControlStructure/ForLoop.py index 51cb66a12..df57c1761 100644 --- a/pyVHDLParser/Blocks/ControlStructure/ForLoop.py +++ b/pyVHDLParser/Blocks/ControlStructure/ForLoop.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import LinebreakToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier, CharacterToken, SpaceToken +from pyVHDLParser.Token import LinebreakToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier, CharacterToken, WhitespaceToken from pyVHDLParser.Token.Keywords import InKeyword, ForKeyword, LoopKeyword, BoundaryToken, IdentifierToken, WordToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -43,7 +43,7 @@ class IteratorBlock(Block): @classmethod def stateForKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -82,7 +82,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -93,7 +93,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def stateIteratorName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -131,7 +131,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -149,7 +149,7 @@ def stateInKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = LoopBlock.stateSequentialRegion parserState.PushState = ExpressionBlockEndedByLoopORToORDownto.stateExpression return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -181,7 +181,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/ControlStructure/If.py b/pyVHDLParser/Blocks/ControlStructure/If.py index fb10e1947..47e526096 100644 --- a/pyVHDLParser/Blocks/ControlStructure/If.py +++ b/pyVHDLParser/Blocks/ControlStructure/If.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken +from pyVHDLParser.Token import CharacterToken, LinebreakToken, WhitespaceToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, IfKeyword, ThenKeyword, ElsIfKeyword, ElseKeyword from pyVHDLParser.Blocks import Block, CommentBlock, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -102,7 +102,7 @@ def stateIfKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = ThenBlock.stateThenKeyword parserState.PushState = ExpressionBlockEndedByThen.stateExpression return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -139,7 +139,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -165,7 +165,7 @@ def stateElsIfKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = ThenBlock.stateThenKeyword parserState.PushState = ExpressionBlockEndedByThen.stateExpression return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -202,7 +202,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/ControlStructure/Next.py b/pyVHDLParser/Blocks/ControlStructure/Next.py index 1efa27b25..cda555435 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Next.py +++ b/pyVHDLParser/Blocks/ControlStructure/Next.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token import WordToken, ExtendedIdentifier, CharacterToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, WhenKeyword from pyVHDLParser.Blocks import Block, TokenToBlockParser, CommentBlock, BlockParserException @@ -58,7 +58,7 @@ def stateNextKeyword(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) # parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken, multiPart=True) # parserState.TokenMarker = None @@ -102,7 +102,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -118,7 +118,7 @@ def stateNextLoopLabel(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) # parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=token, multiPart=True) # parserState.TokenMarker = None @@ -153,7 +153,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -177,7 +177,7 @@ def stateWhenKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = EndBlock.stateError parserState.PushState = NextConditionBlock.stateExpression return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -214,7 +214,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): return elif isinstance(token, IndentationToken) and isinstance(token.PreviousToken, (LinebreakToken, SingleLineCommentToken)): return - elif (isinstance(token, SpaceToken) and ( + elif (isinstance(token, WhitespaceToken) and ( isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken))): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) diff --git a/pyVHDLParser/Blocks/ControlStructure/Null.py b/pyVHDLParser/Blocks/ControlStructure/Null.py index f2d9deb45..3bbcf6389 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Null.py +++ b/pyVHDLParser/Blocks/ControlStructure/Null.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token import CharacterToken from pyVHDLParser.Token.Keywords import BoundaryToken, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser, CommentBlock, BlockParserException @@ -52,7 +52,7 @@ def stateNullKeyword(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -80,7 +80,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/ControlStructure/Return.py b/pyVHDLParser/Blocks/ControlStructure/Return.py index 9bb3733c8..8040058e1 100644 --- a/pyVHDLParser/Blocks/ControlStructure/Return.py +++ b/pyVHDLParser/Blocks/ControlStructure/Return.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CommentToken, CharacterToken, SpaceToken, LinebreakToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken +from pyVHDLParser.Token import CommentToken, CharacterToken, WhitespaceToken, LinebreakToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import BoundaryToken, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser, BlockParserException, CommentBlock from pyVHDLParser.Blocks.Generic import EndOfStatementBlock @@ -65,7 +65,7 @@ def stateReturnKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = EndBlock.stateError parserState.PushState = ReturnExpressionBlock.stateExpression return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -102,7 +102,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): return elif isinstance(token, IndentationToken) and isinstance(token.PreviousToken, (LinebreakToken, SingleLineCommentToken)): return - elif (isinstance(token, SpaceToken) and ( + elif (isinstance(token, WhitespaceToken) and ( isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken))): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) diff --git a/pyVHDLParser/Blocks/ControlStructure/WhileLoop.py b/pyVHDLParser/Blocks/ControlStructure/WhileLoop.py index 0aae452e3..bfa9884f9 100644 --- a/pyVHDLParser/Blocks/ControlStructure/WhileLoop.py +++ b/pyVHDLParser/Blocks/ControlStructure/WhileLoop.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, LinebreakToken, IndentationToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, LoopKeyword from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, GenericKeyword, PortKeyword -from pyVHDLParser.Token.Parser import SpaceToken, WordToken +from pyVHDLParser.Token.Parser import WhitespaceToken, WordToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock @@ -69,7 +69,7 @@ def stateWhileKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -107,7 +107,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateWhileName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -142,7 +142,7 @@ def stateWhileName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -180,7 +180,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewBlock = ConditionBlock(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.NextState = cls.stateDeclarativeRegion return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -206,7 +206,7 @@ def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) return diff --git a/pyVHDLParser/Blocks/Expression.py b/pyVHDLParser/Blocks/Expression.py index fd6f17202..aaa778c0f 100644 --- a/pyVHDLParser/Blocks/Expression.py +++ b/pyVHDLParser/Blocks/Expression.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import FusedCharacterToken, CharacterToken, WordToken, LiteralToken, SpaceToken, LinebreakToken +from pyVHDLParser.Token import FusedCharacterToken, CharacterToken, WordToken, LiteralToken, WhitespaceToken, LinebreakToken from pyVHDLParser.Token import CommentToken, Token, MultiLineCommentToken, IndentationToken, SingleLineCommentToken from pyVHDLParser.Token.Keywords import EqualOperator, PlusOperator, MinusOperator, MultiplyOperator, DivideOperator, ConcatOperator, LessThanOperator from pyVHDLParser.Token.Keywords import GreaterThanOperator, DelimiterToken, PowerOperator, UnequalOperator, LessThanOrEqualOperator @@ -125,7 +125,7 @@ def stateBeforeExpression(cls, parserState: TokenToBlockParser): return elif isinstance(token, IndentationToken) and isinstance(token.PreviousToken, (LinebreakToken, SingleLineCommentToken)): return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return @@ -183,7 +183,7 @@ def stateExpression(cls, parserState: TokenToBlockParser): return elif isinstance(token, LiteralToken): return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -273,7 +273,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -320,7 +320,7 @@ def stateExpression(cls, parserState: TokenToBlockParser): return elif isinstance(token, LiteralToken): return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -390,7 +390,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -447,7 +447,7 @@ def stateExpression(cls, parserState: TokenToBlockParser): return elif isinstance(token, LiteralToken): return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -528,7 +528,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -592,7 +592,7 @@ def stateExpression(cls, parserState: TokenToBlockParser): return elif isinstance(token, LiteralToken): return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -679,7 +679,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -730,7 +730,7 @@ def stateExpression(cls, parserState: TokenToBlockParser): return elif isinstance(token, LiteralToken): return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -805,7 +805,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Generate/CaseGenerate.py b/pyVHDLParser/Blocks/Generate/CaseGenerate.py index 887c07756..0bce968a6 100644 --- a/pyVHDLParser/Blocks/Generate/CaseGenerate.py +++ b/pyVHDLParser/Blocks/Generate/CaseGenerate.py @@ -31,7 +31,7 @@ from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, BeginKeyword from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, GenericKeyword, PortKeyword -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, IndentationToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken, IndentationToken from pyVHDLParser.Blocks import Block, BlockParserException, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock @@ -68,7 +68,7 @@ def stateGenerateKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -106,7 +106,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateGenerateName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -141,7 +141,7 @@ def stateGenerateName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -179,7 +179,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewBlock = CaseBlock(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.NextState = cls.stateDeclarativeRegion return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -205,7 +205,7 @@ def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) return diff --git a/pyVHDLParser/Blocks/Generate/ForGenerate.py b/pyVHDLParser/Blocks/Generate/ForGenerate.py index 6868a9a62..003f6bfea 100644 --- a/pyVHDLParser/Blocks/Generate/ForGenerate.py +++ b/pyVHDLParser/Blocks/Generate/ForGenerate.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, IndentationToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken, IndentationToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, BeginKeyword, ProcessKeyword, AssertKeyword from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, GenericKeyword, PortKeyword from pyVHDLParser.Blocks import Block, BlockParserException, TokenToBlockParser @@ -70,7 +70,7 @@ def stateGenerateKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -108,7 +108,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateGenerateName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -143,7 +143,7 @@ def stateGenerateName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -181,7 +181,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewBlock = RangeBlock(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.NextState = cls.stateDeclarativeRegion return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -207,7 +207,7 @@ def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) return @@ -257,7 +257,7 @@ def stateBeginKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): return # parserState.NewToken = IndentationToken(fromExistingToken=token) # parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) diff --git a/pyVHDLParser/Blocks/Generate/IfGenerate.py b/pyVHDLParser/Blocks/Generate/IfGenerate.py index c5ffd145b..ff43c76c5 100644 --- a/pyVHDLParser/Blocks/Generate/IfGenerate.py +++ b/pyVHDLParser/Blocks/Generate/IfGenerate.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, IndentationToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken, IndentationToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Token.Keywords import BeginKeyword, ProcessKeyword, AssertKeyword from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, GenericKeyword, PortKeyword @@ -71,7 +71,7 @@ def stateGenerateKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -109,7 +109,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateGenerateName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -144,7 +144,7 @@ def stateGenerateName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -182,7 +182,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewBlock = IfConditionBlock(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.NextState = cls.stateDeclarativeRegion return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -208,7 +208,7 @@ def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) return @@ -258,7 +258,7 @@ def stateBeginKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): return # parserState.NewToken = IndentationToken(fromExistingToken=token) # parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) @@ -313,7 +313,7 @@ def stateGenerateKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -351,7 +351,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateGenerateName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -386,7 +386,7 @@ def stateGenerateName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -424,7 +424,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewBlock = ElsIfConditionBlock(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.NextState = cls.stateDeclarativeRegion return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -450,7 +450,7 @@ def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) return @@ -500,7 +500,7 @@ def stateBeginKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): return # parserState.NewToken = IndentationToken(fromExistingToken=token) # parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) @@ -555,7 +555,7 @@ def stateGenerateKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -593,7 +593,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateGenerateName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -628,7 +628,7 @@ def stateGenerateName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -666,7 +666,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewBlock = ElseGenerateBlock(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.NextState = cls.stateDeclarativeRegion return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -692,7 +692,7 @@ def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) return @@ -742,7 +742,7 @@ def stateBeginKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): return # parserState.NewToken = IndentationToken(fromExistingToken=token) # parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) diff --git a/pyVHDLParser/Blocks/Generic.py b/pyVHDLParser/Blocks/Generic.py index 9bea11015..0345bfd05 100644 --- a/pyVHDLParser/Blocks/Generic.py +++ b/pyVHDLParser/Blocks/Generic.py @@ -31,7 +31,7 @@ from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, LinebreakToken, CommentToken, WordToken, MultiLineCommentToken, IndentationToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, LinebreakToken, CommentToken, WordToken, MultiLineCommentToken, IndentationToken from pyVHDLParser.Token import SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import EndToken, BoundaryToken, LabelToken, IdentifierToken from pyVHDLParser.Blocks import FinalBlock, TokenToBlockParser, CommentBlock, BlockParserException, Block @@ -54,7 +54,7 @@ def stateEndKeyword(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -109,7 +109,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -139,7 +139,7 @@ def stateKeyword1(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = nextState return @@ -185,7 +185,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -212,7 +212,7 @@ def stateKeyword2(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -261,7 +261,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -277,7 +277,7 @@ def stateSimpleName(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace4 return @@ -319,7 +319,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -349,7 +349,7 @@ def stateClosingParenthesis(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -381,7 +381,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Instantiation/EntityInstantiation.py b/pyVHDLParser/Blocks/Instantiation/EntityInstantiation.py index 52f0e973f..d2ee3cf32 100644 --- a/pyVHDLParser/Blocks/Instantiation/EntityInstantiation.py +++ b/pyVHDLParser/Blocks/Instantiation/EntityInstantiation.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, FinalBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateEntityInstantiationKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateEntityInstantiationName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -143,7 +143,7 @@ def stateEntityInstantiationName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -181,7 +181,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Instantiation/FunctionInstantiation.py b/pyVHDLParser/Blocks/Instantiation/FunctionInstantiation.py index 5b1ed595c..8633696e9 100644 --- a/pyVHDLParser/Blocks/Instantiation/FunctionInstantiation.py +++ b/pyVHDLParser/Blocks/Instantiation/FunctionInstantiation.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, FinalBlock, SkipableBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateEntityInstantiationKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateEntityInstantiationName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -143,7 +143,7 @@ def stateEntityInstantiationName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -181,7 +181,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Instantiation/PackageInstantiation.py b/pyVHDLParser/Blocks/Instantiation/PackageInstantiation.py index 5b1ed595c..8633696e9 100644 --- a/pyVHDLParser/Blocks/Instantiation/PackageInstantiation.py +++ b/pyVHDLParser/Blocks/Instantiation/PackageInstantiation.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, FinalBlock, SkipableBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateEntityInstantiationKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateEntityInstantiationName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -143,7 +143,7 @@ def stateEntityInstantiationName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -181,7 +181,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Instantiation/ProcedureInstantiation.py b/pyVHDLParser/Blocks/Instantiation/ProcedureInstantiation.py index 5b1ed595c..8633696e9 100644 --- a/pyVHDLParser/Blocks/Instantiation/ProcedureInstantiation.py +++ b/pyVHDLParser/Blocks/Instantiation/ProcedureInstantiation.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, FinalBlock, SkipableBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateEntityInstantiationKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateEntityInstantiationName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -143,7 +143,7 @@ def stateEntityInstantiationName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -181,7 +181,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/InterfaceObject.py b/pyVHDLParser/Blocks/InterfaceObject.py index 2052f839d..ef13ae1a6 100644 --- a/pyVHDLParser/Blocks/InterfaceObject.py +++ b/pyVHDLParser/Blocks/InterfaceObject.py @@ -31,7 +31,7 @@ from pyVHDLParser.Blocks.Type.ResolutionIndication import RecordResolutionIndicationBlock, \ SimpleResolutionIndicationBlock -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken, WordToken, ExtendedIdentifier, MultiLineCommentToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken, WordToken, ExtendedIdentifier, MultiLineCommentToken from pyVHDLParser.Token import IndentationToken, SingleLineCommentToken, CharacterToken, FusedCharacterToken from pyVHDLParser.Token.Keywords import InKeyword, VariableAssignmentKeyword, OutKeyword, InoutKeyword, BufferKeyword, LinkageKeyword from pyVHDLParser.Token.Keywords import IdentifierToken, BoundaryToken, DelimiterToken @@ -71,7 +71,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -82,7 +82,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def stateObjectName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -121,7 +121,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -141,7 +141,7 @@ def stateColon1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateSubtypeIndication return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -185,7 +185,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -196,7 +196,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): @classmethod def stateModeKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NextState = cls.stateSubtypeIndication parserState.PushState = SimpleResolutionIndicationBlock.stateResolutionFunction return @@ -238,7 +238,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -278,7 +278,7 @@ def stateSubtypeIndication(cls, parserState: TokenToBlockParser): parserState.Pop(2) parserState.TokenMarker = parserState.NewToken return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace5 return @@ -330,7 +330,7 @@ def stateWhitespace5(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -349,7 +349,7 @@ class InterfaceConstantBlock(InterfaceObjectBlock): @classmethod def stateConstantKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -375,7 +375,7 @@ class InterfaceVariableBlock(InterfaceObjectBlock): @classmethod def stateVariableKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -403,7 +403,7 @@ class InterfaceSignalBlock(InterfaceObjectBlock): @classmethod def stateSignalKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -424,7 +424,7 @@ class InterfaceTypeBlock(Block): @classmethod def stateTypeKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -461,7 +461,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -485,7 +485,7 @@ def stateTypeName(cls, parserState: TokenToBlockParser): parserState.Pop(2) parserState.TokenMarker = parserState.NewToken return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -529,7 +529,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/List/GenericList.py b/pyVHDLParser/Blocks/List/GenericList.py index 9ced704d4..136baf2bc 100644 --- a/pyVHDLParser/Blocks/List/GenericList.py +++ b/pyVHDLParser/Blocks/List/GenericList.py @@ -32,7 +32,7 @@ from pyVHDLParser.Token import CharacterToken, LinebreakToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import BoundaryToken, ConstantKeyword, TypeKeyword, DelimiterToken from pyVHDLParser.Token.Keywords import IdentifierToken -from pyVHDLParser.Token.Parser import SpaceToken, WordToken +from pyVHDLParser.Token.Parser import WhitespaceToken, WordToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, SkipableBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock from pyVHDLParser.Blocks.Generic import CloseBlock as CloseBlockBase @@ -77,7 +77,7 @@ def stateItemDelimiter(cls, parserState: TokenToBlockParser): elif isinstance(token, ExtendedIdentifier): parserState.NextState = GenericListInterfaceConstantBlock.stateObjectName return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = OpenBlock.stateOpeningParenthesis return elif isinstance(token, LinebreakToken): @@ -124,7 +124,7 @@ def stateGenericKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = CloseBlock.stateClosingParenthesis parserState.PushState = cls.stateOpeningParenthesis return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -161,7 +161,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -207,7 +207,7 @@ def stateOpeningParenthesis(cls, parserState: TokenToBlockParser): elif isinstance(token, ExtendedIdentifier): parserState.NextState = GenericListInterfaceConstantBlock.stateObjectName return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) return diff --git a/pyVHDLParser/Blocks/List/GenericMapList.py b/pyVHDLParser/Blocks/List/GenericMapList.py index e83b2c548..fade456c8 100644 --- a/pyVHDLParser/Blocks/List/GenericMapList.py +++ b/pyVHDLParser/Blocks/List/GenericMapList.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, IndentationToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken, IndentationToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, DelimiterToken, OpeningRoundBracketToken, ClosingRoundBracketToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, SkipableBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock @@ -72,7 +72,7 @@ def stateGenericKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return @@ -115,7 +115,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -150,7 +150,7 @@ def stateOpeningParenthesis(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) return @@ -208,7 +208,7 @@ def stateItemDelimiter(cls, parserState: TokenToBlockParser): parserState.NextState = OpenBlock.stateOpeningParenthesis parserState.PushState = LinebreakBlock.stateLinebreak return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = OpenBlock.stateOpeningParenthesis return elif isinstance(token, WordToken): @@ -251,7 +251,7 @@ def stateClosingParenthesis(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return @@ -285,7 +285,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/List/ParameterList.py b/pyVHDLParser/Blocks/List/ParameterList.py index 0ac856542..660666454 100644 --- a/pyVHDLParser/Blocks/List/ParameterList.py +++ b/pyVHDLParser/Blocks/List/ParameterList.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, WordToken, SpaceToken, LinebreakToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token import CharacterToken, WordToken, WhitespaceToken, LinebreakToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import BoundaryToken, DelimiterToken, ClosingRoundBracketToken, IdentifierToken from pyVHDLParser.Token.Keywords import ConstantKeyword, SignalKeyword, VariableKeyword, TypeKeyword from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, SkipableBlock @@ -50,7 +50,7 @@ def stateParameterKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = cls.stateOpeningParenthesis parserState.Counter = 1 return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -87,7 +87,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -125,7 +125,7 @@ def stateOpeningParenthesis(cls, parserState: TokenToBlockParser): elif isinstance(token, ExtendedIdentifier): parserState.NextState = ParameterListInterfaceConstantBlock.stateObjectName return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) return @@ -218,7 +218,7 @@ def stateItemDelimiter(cls, parserState: TokenToBlockParser): elif isinstance(token, ExtendedIdentifier): parserState.NextState = ParameterListInterfaceConstantBlock.stateObjectName return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.TokenMarker = token parserState.NextState = ItemBlock.stateItemRemainder return diff --git a/pyVHDLParser/Blocks/List/PortList.py b/pyVHDLParser/Blocks/List/PortList.py index 73533db0f..c4481cc93 100644 --- a/pyVHDLParser/Blocks/List/PortList.py +++ b/pyVHDLParser/Blocks/List/PortList.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, WordToken, SpaceToken, LinebreakToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token import CharacterToken, WordToken, WhitespaceToken, LinebreakToken, IndentationToken, CommentToken, MultiLineCommentToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import BoundaryToken, SignalKeyword, DelimiterToken from pyVHDLParser.Token.Keywords import IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, SkipableBlock @@ -63,7 +63,7 @@ def stateItemDelimiter(cls, parserState: TokenToBlockParser): elif isinstance(token, ExtendedIdentifier): parserState.NextState = PortListInterfaceSignalBlock.stateObjectName return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = OpenBlock.stateOpeningParenthesis return elif isinstance(token, LinebreakToken): @@ -105,7 +105,7 @@ def statePortKeyword(cls, parserState: TokenToBlockParser): parserState.NextState = CloseBlock.stateClosingParenthesis parserState.PushState = cls.stateOpeningParenthesis return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -142,7 +142,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -175,7 +175,7 @@ def stateOpeningParenthesis(cls, parserState: TokenToBlockParser): elif isinstance(token, ExtendedIdentifier): parserState.NextState = PortListInterfaceSignalBlock.stateObjectName return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) return diff --git a/pyVHDLParser/Blocks/List/PortMapList.py b/pyVHDLParser/Blocks/List/PortMapList.py index ca0b3e796..afe9df08b 100644 --- a/pyVHDLParser/Blocks/List/PortMapList.py +++ b/pyVHDLParser/Blocks/List/PortMapList.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, IndentationToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken, IndentationToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, DelimiterToken, OpeningRoundBracketToken, ClosingRoundBracketToken from pyVHDLParser.Blocks import BlockParserException, Block, TokenToBlockParser, SkipableBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock @@ -72,7 +72,7 @@ def statePortKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return @@ -116,7 +116,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -150,7 +150,7 @@ def stateOpeningParenthesis(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) return @@ -211,7 +211,7 @@ def stateItemDelimiter(cls, parserState: TokenToBlockParser): parserState.NextState = OpenBlock.stateOpeningParenthesis parserState.PushState = LinebreakBlock.stateLinebreak return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = OpenBlock.stateOpeningParenthesis return elif isinstance(token, WordToken): @@ -254,7 +254,7 @@ def stateClosingParenthesis(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return @@ -288,7 +288,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/List/SensitivityList.py b/pyVHDLParser/Blocks/List/SensitivityList.py index 05084c564..bd068c118 100644 --- a/pyVHDLParser/Blocks/List/SensitivityList.py +++ b/pyVHDLParser/Blocks/List/SensitivityList.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, WordToken, SpaceToken, LinebreakToken, IndentationToken, ExtendedIdentifier +from pyVHDLParser.Token import CharacterToken, WordToken, WhitespaceToken, LinebreakToken, IndentationToken, ExtendedIdentifier from pyVHDLParser.Token import CommentToken, MultiLineCommentToken, SingleLineCommentToken from pyVHDLParser.Token.Keywords import BoundaryToken, DelimiterToken, OpeningRoundBracketToken, ClosingRoundBracketToken from pyVHDLParser.Token.Keywords import IdentifierToken, AllKeyword @@ -56,7 +56,7 @@ def stateOpeningParenthesis(cls, parserState: TokenToBlockParser): elif isinstance(token, ExtendedIdentifier): parserState.NextState = ItemBlock.stateItemRemainder return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) parserState.TokenMarker = None @@ -118,7 +118,7 @@ def stateItemDelimiter(cls, parserState: TokenToBlockParser): elif isinstance(token, ExtendedIdentifier): parserState.NextState = ItemBlock.stateItemRemainder return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = OpenBlock.stateOpeningParenthesis return elif isinstance(token, LinebreakToken): @@ -145,7 +145,7 @@ def stateAllKeyword(cls, parserState: TokenToBlockParser): parserState.NewBlock = CloseBlock(parserState.LastBlock, parserState.NewToken, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -182,7 +182,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Object/Constant.py b/pyVHDLParser/Blocks/Object/Constant.py index 7d76a74a9..2670c69ed 100644 --- a/pyVHDLParser/Blocks/Object/Constant.py +++ b/pyVHDLParser/Blocks/Object/Constant.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken from pyVHDLParser.Token.Keywords import BoundaryToken from pyVHDLParser.Blocks import TokenToBlockParser, CommentBlock, BlockParserException from pyVHDLParser.Blocks.Whitespace import LinebreakBlock @@ -56,7 +56,7 @@ class ConstantDeclarationBlock(ObjectDeclarationBlock): @classmethod def stateConstantKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return diff --git a/pyVHDLParser/Blocks/Object/SharedVariable.py b/pyVHDLParser/Blocks/Object/SharedVariable.py index 1186ed3ba..62d3ef92b 100644 --- a/pyVHDLParser/Blocks/Object/SharedVariable.py +++ b/pyVHDLParser/Blocks/Object/SharedVariable.py @@ -32,7 +32,7 @@ from pyVHDLParser.Blocks import TokenToBlockParser, CommentBlock, BlockParserException from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock from pyVHDLParser.Blocks.Object import ObjectDeclarationEndMarkerBlock, ObjectDeclarationBlock -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken, WordToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken, WordToken from pyVHDLParser.Token import ExtendedIdentifier, MultiLineCommentToken, CharacterToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken @@ -50,7 +50,7 @@ class SharedVariableDeclarationBlock(ObjectDeclarationBlock): @classmethod def stateSharedKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace0 return @@ -86,7 +86,7 @@ def stateWhitespace0(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -97,7 +97,7 @@ def stateWhitespace0(cls, parserState: TokenToBlockParser): @classmethod def stateVariableKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -120,7 +120,7 @@ def stateSubtypeIndication(cls, parserState: TokenToBlockParser): _ = cls.END_BLOCK(parserState.NewBlock, parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace4 return @@ -154,7 +154,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Object/Signal.py b/pyVHDLParser/Blocks/Object/Signal.py index 339ae847b..cf28a68f8 100644 --- a/pyVHDLParser/Blocks/Object/Signal.py +++ b/pyVHDLParser/Blocks/Object/Signal.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken from pyVHDLParser.Token.Keywords import BoundaryToken from pyVHDLParser.Blocks import TokenToBlockParser, CommentBlock, BlockParserException from pyVHDLParser.Blocks.Whitespace import LinebreakBlock @@ -56,7 +56,7 @@ class SignalDeclarationBlock(ObjectDeclarationBlock): @classmethod def stateSignalKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return diff --git a/pyVHDLParser/Blocks/Object/Variable.py b/pyVHDLParser/Blocks/Object/Variable.py index db5f525cc..51b5e0711 100644 --- a/pyVHDLParser/Blocks/Object/Variable.py +++ b/pyVHDLParser/Blocks/Object/Variable.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken from pyVHDLParser.Token.Keywords import BoundaryToken from pyVHDLParser.Blocks import TokenToBlockParser, CommentBlock, BlockParserException from pyVHDLParser.Blocks.Whitespace import LinebreakBlock @@ -56,7 +56,7 @@ class VariableDeclarationBlock(ObjectDeclarationBlock): @classmethod def stateVariableKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return diff --git a/pyVHDLParser/Blocks/Object/__init__.py b/pyVHDLParser/Blocks/Object/__init__.py index 5b9b37a28..d3789351c 100644 --- a/pyVHDLParser/Blocks/Object/__init__.py +++ b/pyVHDLParser/Blocks/Object/__init__.py @@ -30,7 +30,7 @@ from pyTooling.Decorators import export from pyVHDLParser.Token import WordToken, ExtendedIdentifier, LinebreakToken, MultiLineCommentToken -from pyVHDLParser.Token import CommentToken, SpaceToken, CharacterToken, FusedCharacterToken +from pyVHDLParser.Token import CommentToken, WhitespaceToken, CharacterToken, FusedCharacterToken from pyVHDLParser.Token.Keywords import IdentifierToken, BoundaryToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser, CommentBlock, BlockParserException from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -80,7 +80,7 @@ def stateObjectName(cls, parserState: TokenToBlockParser): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateColon1 return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -113,7 +113,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -128,7 +128,7 @@ def stateColon1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateSubtypeIndication return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -161,7 +161,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -185,7 +185,7 @@ def stateSubtypeIndication(cls, parserState: TokenToBlockParser): _ = cls.END_BLOCK(parserState.NewBlock, parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace4 return @@ -226,7 +226,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Reference/Context.py b/pyVHDLParser/Blocks/Reference/Context.py index de0158b9d..fe063fa9d 100644 --- a/pyVHDLParser/Blocks/Reference/Context.py +++ b/pyVHDLParser/Blocks/Reference/Context.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CommentToken, SpaceToken, LinebreakToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token import CommentToken, WhitespaceToken, LinebreakToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, IdentifierToken, IsKeyword, UseKeyword, EndKeyword, ContextKeyword, LibraryKeyword from pyVHDLParser.Blocks import Block, CommentBlock, BlockParserException, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, IndentationBlock, WhitespaceBlock @@ -52,7 +52,7 @@ def __cls_init__(cls): @classmethod def stateContextKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -91,7 +91,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -102,7 +102,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def stateContextName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -139,7 +139,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -150,7 +150,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): @classmethod def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) return diff --git a/pyVHDLParser/Blocks/Reference/Library.py b/pyVHDLParser/Blocks/Reference/Library.py index aac242aba..05b65e145 100644 --- a/pyVHDLParser/Blocks/Reference/Library.py +++ b/pyVHDLParser/Blocks/Reference/Library.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, CommentToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken, CommentToken, IndentationToken, SingleLineCommentToken, MultiLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, DelimiterToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, FinalBlock, SkipableBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -40,7 +40,7 @@ class StartBlock(Block): @classmethod def stateLibraryKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.TokenMarker = None @@ -74,7 +74,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -101,7 +101,7 @@ def stateLibraryName(cls, parserState: TokenToBlockParser): _ = EndBlock(parserState.NewBlock, parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): #parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -142,7 +142,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -173,7 +173,7 @@ def stateDelimiter(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) # parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = parserState.NewToken @@ -200,7 +200,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Reference/Use.py b/pyVHDLParser/Blocks/Reference/Use.py index 2342476c7..9a6442a97 100644 --- a/pyVHDLParser/Blocks/Reference/Use.py +++ b/pyVHDLParser/Blocks/Reference/Use.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, DelimiterToken, EndToken, AllKeyword from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser, FinalBlock, SkipableBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -40,7 +40,7 @@ class StartBlock(Block): @classmethod def stateUseKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.TokenMarker = None @@ -74,7 +74,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -92,7 +92,7 @@ def stateLibraryName(cls, parserState: TokenToBlockParser): parserState.NewToken = DelimiterToken(fromExistingToken=token) parserState.NextState = cls.stateDot1 return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): #parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -132,7 +132,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -154,7 +154,7 @@ def stateDot1(cls, parserState: TokenToBlockParser): parserState.NewToken = DelimiterToken(fromExistingToken=token) parserState.NextState = cls.stateDot1 return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): #parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -198,7 +198,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -213,7 +213,7 @@ def statePackageName(cls, parserState: TokenToBlockParser): parserState.NewToken = DelimiterToken(fromExistingToken=token) parserState.NextState = cls.stateDot2 return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): #parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -253,7 +253,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -274,7 +274,7 @@ def stateDot2(cls, parserState: TokenToBlockParser): elif isinstance(token, ExtendedIdentifier): parserState.NextState = cls.stateObjectName return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace4 return @@ -316,7 +316,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -340,7 +340,7 @@ def stateObjectName(cls, parserState: TokenToBlockParser): _ = EndBlock(parserState.NewBlock, parserState.NewToken, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): # parserState.NewToken = WhitespaceBlock(parserState.LastBlock, token) parserState.NextState = cls.stateWhitespace5 return @@ -384,7 +384,7 @@ def stateWhitespace5(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -415,7 +415,7 @@ def stateDelimiter(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.TokenMarker = parserState.NewToken parserState.NextState = cls.stateWhitespace1 @@ -442,7 +442,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Region.py b/pyVHDLParser/Blocks/Region.py index b184b06da..7226221f2 100644 --- a/pyVHDLParser/Blocks/Region.py +++ b/pyVHDLParser/Blocks/Region.py @@ -31,7 +31,7 @@ from pyTooling.Decorators import export -from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, IndentationToken +from pyVHDLParser.Token import LinebreakToken, WordToken, WhitespaceToken, CommentToken, IndentationToken from pyVHDLParser.Token.Keywords import AssertKeyword, EndKeyword, ProcessKeyword, ReportKeyword, IfKeyword, ForKeyword, ReturnKeyword, NextKeyword, NullKeyword from pyVHDLParser.Token.Keywords import ExitKeyword, UseKeyword, SignalKeyword, ConstantKeyword, SharedKeyword, FunctionKeyword, ProcedureKeyword from pyVHDLParser.Token.Keywords import ImpureKeyword, PureKeyword, VariableKeyword, BeginKeyword, CaseKeyword @@ -71,7 +71,7 @@ def __cls_init__(cls): @classmethod def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) parserState.TokenMarker = None @@ -168,7 +168,7 @@ def stateStatementRegion(cls, parserState: TokenToBlockParser): @classmethod def stateConcurrentRegion(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) parserState.TokenMarker = None @@ -241,7 +241,7 @@ def stateSequentialRegion(cls, parserState: TokenToBlockParser): @classmethod def stateAnyRegion(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Reporting/Assert.py b/pyVHDLParser/Blocks/Reporting/Assert.py index 3719d4a0d..3d725f8f0 100644 --- a/pyVHDLParser/Blocks/Reporting/Assert.py +++ b/pyVHDLParser/Blocks/Reporting/Assert.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, WordToken, IndentationToken, CharacterToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, WordToken, IndentationToken, CharacterToken from pyVHDLParser.Token import CommentToken, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, ReportKeyword, EndToken, SeverityKeyword from pyVHDLParser.Blocks import Block, CommentBlock, TokenToBlockParser, BlockParserException @@ -41,7 +41,7 @@ class AssertBlock(Block): @classmethod def stateAssertKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -77,7 +77,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -88,7 +88,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def stateAssertion(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -124,7 +124,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -135,7 +135,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): @classmethod def stateReportKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -171,7 +171,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -187,7 +187,7 @@ def stateMessage(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace4 return @@ -228,7 +228,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -239,7 +239,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): @classmethod def stateSeverityKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace5 return @@ -275,7 +275,7 @@ def stateWhitespace5(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -291,7 +291,7 @@ def stateSeverityLevel(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace6 return @@ -328,7 +328,7 @@ def stateWhitespace6(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Reporting/Report.py b/pyVHDLParser/Blocks/Reporting/Report.py index ace2d2ae9..74c84d447 100644 --- a/pyVHDLParser/Blocks/Reporting/Report.py +++ b/pyVHDLParser/Blocks/Reporting/Report.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, WordToken, IndentationToken, CharacterToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, WordToken, IndentationToken, CharacterToken from pyVHDLParser.Token import CommentToken, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken, SeverityKeyword from pyVHDLParser.Blocks import Block, CommentBlock, TokenToBlockParser, BlockParserException @@ -41,7 +41,7 @@ class ReportBlock(Block): @classmethod def stateReportKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -77,7 +77,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -93,7 +93,7 @@ def stateMessage(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace4 return @@ -134,7 +134,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -145,7 +145,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): @classmethod def stateSeverityKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace5 return @@ -181,7 +181,7 @@ def stateWhitespace5(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -197,7 +197,7 @@ def stateSeverityLevel(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace6 return @@ -235,7 +235,7 @@ def stateWhitespace6(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Sequential/Function.py b/pyVHDLParser/Blocks/Sequential/Function.py index 9d1c3b159..5c6dc493a 100644 --- a/pyVHDLParser/Blocks/Sequential/Function.py +++ b/pyVHDLParser/Blocks/Sequential/Function.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken, CharacterToken, IndentationToken, MultiLineCommentToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken, CharacterToken, IndentationToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, IdentifierToken, PureKeyword, ImpureKeyword from pyVHDLParser.Token.Keywords import ReturnKeyword, GenericKeyword, ParameterKeyword, FunctionKeyword, EndKeyword from pyVHDLParser.Token.Keywords import UseKeyword, ConstantKeyword, VariableKeyword, IsKeyword, EndToken, BeginKeyword, ProcedureKeyword, ReportKeyword @@ -63,7 +63,7 @@ class NameBlock(Block): @classmethod def statePureKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace0 return @@ -80,7 +80,7 @@ def statePureKeyword(cls, parserState: TokenToBlockParser): @classmethod def stateImpureKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace0 return @@ -114,7 +114,7 @@ def stateWhitespace0(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -125,7 +125,7 @@ def stateWhitespace0(cls, parserState: TokenToBlockParser): @classmethod def stateFunctionKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -159,7 +159,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -179,7 +179,7 @@ def stateFunctionName(cls, parserState: TokenToBlockParser): parserState.PushState = ParameterList.OpenBlock.stateOpeningParenthesis parserState.Counter = 1 return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -238,7 +238,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -258,7 +258,7 @@ def stateAfterParameterList(cls, parserState: TokenToBlockParser): # parserState.NewBlock = NameBlock2(parserState.LastBlock, parserState.TokenMarker, parserState.NewToken) parserState.NextState = cls.stateReturnKeyword return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -291,7 +291,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -303,11 +303,11 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): def stateReturnKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token errorMessage = "Expected whitespace after keyword RETURN." - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -341,7 +341,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -358,7 +358,7 @@ def stateReturnType(cls, parserState: TokenToBlockParser): parserState.NewBlock = cls(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -398,7 +398,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Sequential/Package.py b/pyVHDLParser/Blocks/Sequential/Package.py index 93c4749c9..31c4cca8f 100644 --- a/pyVHDLParser/Blocks/Sequential/Package.py +++ b/pyVHDLParser/Blocks/Sequential/Package.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, MultiLineCommentToken +from pyVHDLParser.Token import LinebreakToken, WordToken, WhitespaceToken, CommentToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import PackageKeyword, IsKeyword, EndKeyword, GenericKeyword, BodyKeyword, UseKeyword, VariableKeyword, SignalKeyword from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Token.Keywords import ConstantKeyword, SharedKeyword, ProcedureKeyword, FunctionKeyword, PureKeyword, ImpureKeyword @@ -67,7 +67,7 @@ class NameBlock(Block): @classmethod def statePackageKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -106,7 +106,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -117,7 +117,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def statePackageName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -153,7 +153,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Sequential/PackageBody.py b/pyVHDLParser/Blocks/Sequential/PackageBody.py index 86fb5d8d1..d0a6b174d 100644 --- a/pyVHDLParser/Blocks/Sequential/PackageBody.py +++ b/pyVHDLParser/Blocks/Sequential/PackageBody.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, MultiLineCommentToken, IndentationToken +from pyVHDLParser.Token import LinebreakToken, WordToken, WhitespaceToken, CommentToken, MultiLineCommentToken, IndentationToken from pyVHDLParser.Token.Keywords import PackageKeyword, IsKeyword, EndKeyword, BodyKeyword, FunctionKeyword, SignalKeyword from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Token.Keywords import ConstantKeyword, SharedKeyword, ProcedureKeyword, FunctionKeyword, PureKeyword, ImpureKeyword @@ -56,7 +56,7 @@ class NameBlock(Block): @classmethod def stateBodyKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -90,7 +90,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -101,7 +101,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def statePackageName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -137,7 +137,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Sequential/Procedure.py b/pyVHDLParser/Blocks/Sequential/Procedure.py index 6051dd901..c492c8f70 100644 --- a/pyVHDLParser/Blocks/Sequential/Procedure.py +++ b/pyVHDLParser/Blocks/Sequential/Procedure.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, LinebreakToken, CommentToken, CharacterToken, IndentationToken, MultiLineCommentToken +from pyVHDLParser.Token import WhitespaceToken, LinebreakToken, CommentToken, CharacterToken, IndentationToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, IdentifierToken, GenericKeyword, ParameterKeyword, ProcedureKeyword, EndKeyword, ImpureKeyword, PureKeyword from pyVHDLParser.Token.Keywords import UseKeyword, ConstantKeyword, VariableKeyword, IsKeyword, EndToken, BeginKeyword, FunctionKeyword, ReportKeyword from pyVHDLParser.Blocks import Block, BlockParserException, CommentBlock, TokenToBlockParser @@ -63,7 +63,7 @@ class NameBlock(Block): @classmethod def stateProcedureKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -97,7 +97,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -124,7 +124,7 @@ def stateProcedureName(cls, parserState: TokenToBlockParser): # _ = EndBlock(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.Pop() return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -191,7 +191,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -216,7 +216,7 @@ def stateAfterParameterList(cls, parserState: TokenToBlockParser): parserState.NewBlock = VoidBlock(parserState.LastBlock, parserState.TokenMarker, parserState.NewToken) parserState.NextState = DeclarativeRegion.stateDeclarativeRegion return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -249,7 +249,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): _ = CommentBlock(parserState.NewBlock, token) parserState.TokenMarker = None return - elif isinstance(token, SpaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Sequential/Process.py b/pyVHDLParser/Blocks/Sequential/Process.py index e7dda76b8..69b5be3c2 100644 --- a/pyVHDLParser/Blocks/Sequential/Process.py +++ b/pyVHDLParser/Blocks/Sequential/Process.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, LinebreakToken, CommentToken, IndentationToken, MultiLineCommentToken, SingleLineCommentToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, LinebreakToken, CommentToken, IndentationToken, MultiLineCommentToken, SingleLineCommentToken from pyVHDLParser.Token.Keywords import WordToken, BoundaryToken, IsKeyword, UseKeyword, ConstantKeyword, ImpureKeyword, PureKeyword from pyVHDLParser.Token.Keywords import VariableKeyword, ProcessKeyword, BeginKeyword, FunctionKeyword, ProcedureKeyword from pyVHDLParser.Blocks import Block, CommentBlock, BlockParserException, TokenToBlockParser @@ -70,7 +70,7 @@ def stateProcessKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = SensitivityList.OpenBlock.stateOpeningParenthesis parserState.Counter = 1 return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace1 return elif isinstance(token, (LinebreakToken, CommentToken)): @@ -107,7 +107,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -187,7 +187,7 @@ def stateAfterSensitivityList(cls, parserState: TokenToBlockParser): parserState.TokenMarker = None parserState.NextState = DeclarativeRegion.stateDeclarativeRegion return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.TokenMarker = parserState.NewToken parserState.NextState = cls.stateWhitespace1 @@ -243,7 +243,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Structural/Architecture.py b/pyVHDLParser/Blocks/Structural/Architecture.py index 4d9170120..21de18d1f 100644 --- a/pyVHDLParser/Blocks/Structural/Architecture.py +++ b/pyVHDLParser/Blocks/Structural/Architecture.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token import LinebreakToken, WordToken, WhitespaceToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import ArchitectureKeyword, IsKeyword, OfKeyword, BoundaryToken, IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -60,7 +60,7 @@ class NameBlock(Block): @classmethod def stateArchitectureKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -99,7 +99,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -110,7 +110,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def stateArchitectureName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -146,7 +146,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -157,7 +157,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): @classmethod def stateOfKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -196,7 +196,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -207,7 +207,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): @classmethod def stateEntityName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace4 return @@ -245,7 +245,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Structural/Block.py b/pyVHDLParser/Blocks/Structural/Block.py index 0ae02f1c8..a4147fd9d 100644 --- a/pyVHDLParser/Blocks/Structural/Block.py +++ b/pyVHDLParser/Blocks/Structural/Block.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, IndentationToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken, IndentationToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, EndToken from pyVHDLParser.Token.Keywords import SignalKeyword, ConstantKeyword, VariableKeyword, SharedKeyword, ProcessKeyword, AssertKeyword, BlockKeyword from pyVHDLParser.Token.Keywords import IsKeyword, EndKeyword, BlockKeyword, BeginKeyword @@ -88,7 +88,7 @@ def stateBlockKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -127,7 +127,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateBlockName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -162,7 +162,7 @@ def stateBlockName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -200,7 +200,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewBlock = NameBlock(parserState.LastBlock, parserState.TokenMarker, endToken=parserState.NewToken) parserState.NextState = DeclarativeRegion.stateDeclarativeRegion return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Structural/Component.py b/pyVHDLParser/Blocks/Structural/Component.py index e98845f7e..43fe9b5f2 100644 --- a/pyVHDLParser/Blocks/Structural/Component.py +++ b/pyVHDLParser/Blocks/Structural/Component.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token import LinebreakToken, WordToken, WhitespaceToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import ComponentKeyword, IsKeyword, EndKeyword, GenericKeyword, PortKeyword, UseKeyword, BeginKeyword from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser @@ -54,7 +54,7 @@ def __cls_init__(cls): @classmethod def stateComponentKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -92,7 +92,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def stateComponentName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -141,7 +141,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -153,7 +153,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) return diff --git a/pyVHDLParser/Blocks/Structural/Configuration.py b/pyVHDLParser/Blocks/Structural/Configuration.py index 4aef1ef6d..444233ae1 100644 --- a/pyVHDLParser/Blocks/Structural/Configuration.py +++ b/pyVHDLParser/Blocks/Structural/Configuration.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token import LinebreakToken, WordToken, WhitespaceToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import ConfigurationKeyword, IsKeyword, EndKeyword, GenericKeyword, PortKeyword, UseKeyword, BeginKeyword from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser @@ -56,7 +56,7 @@ def __cls_init__(cls): @classmethod def stateConfigurationKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -94,7 +94,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -105,7 +105,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def stateConfigurationName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -143,7 +143,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -155,7 +155,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): def stateDeclarativeRegion(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) return diff --git a/pyVHDLParser/Blocks/Structural/Entity.py b/pyVHDLParser/Blocks/Structural/Entity.py index e61d3eeb4..59f813566 100644 --- a/pyVHDLParser/Blocks/Structural/Entity.py +++ b/pyVHDLParser/Blocks/Structural/Entity.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import LinebreakToken, WordToken, SpaceToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier +from pyVHDLParser.Token import LinebreakToken, WordToken, WhitespaceToken, CommentToken, MultiLineCommentToken, IndentationToken, SingleLineCommentToken, ExtendedIdentifier from pyVHDLParser.Token.Keywords import EntityKeyword, IsKeyword, GenericKeyword, PortKeyword from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken from pyVHDLParser.Blocks import BlockParserException, Block, CommentBlock, TokenToBlockParser @@ -74,7 +74,7 @@ class NameBlock(Block): @classmethod def stateEntityKeyword(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -113,7 +113,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -124,7 +124,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): @classmethod def stateEntityName(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace2 return @@ -162,7 +162,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): 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)): + elif isinstance(token, WhitespaceToken) and (isinstance(parserState.LastBlock, CommentBlock) and isinstance(parserState.LastBlock.StartToken, MultiLineCommentToken)): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Type/Subtype.py b/pyVHDLParser/Blocks/Type/Subtype.py index 0e37d9c3d..439473224 100644 --- a/pyVHDLParser/Blocks/Type/Subtype.py +++ b/pyVHDLParser/Blocks/Type/Subtype.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, WordToken +from pyVHDLParser.Token import CharacterToken, LinebreakToken, WhitespaceToken, WordToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateSubtypeKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateSubtypeName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -142,7 +142,7 @@ def stateSubtypeName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -183,7 +183,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateColon1() return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -218,7 +218,7 @@ def stateColon1(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -260,7 +260,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateTypeMarkName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -299,7 +299,7 @@ def stateTypeMarkName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace4 return @@ -336,7 +336,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -382,7 +382,7 @@ def stateVariableAssignment(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace5 return @@ -418,7 +418,7 @@ def stateWhitespace5(cls, parserState: TokenToBlockParser): elif isinstance(token, WordToken): parserState.NextState = cls.stateExpressionEnd return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Type/Type.py b/pyVHDLParser/Blocks/Type/Type.py index cf9e2ae10..d94e76ec9 100644 --- a/pyVHDLParser/Blocks/Type/Type.py +++ b/pyVHDLParser/Blocks/Type/Type.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import CharacterToken, LinebreakToken, SpaceToken, WordToken +from pyVHDLParser.Token import CharacterToken, LinebreakToken, WhitespaceToken, WordToken from pyVHDLParser.Token.Keywords import BoundaryToken, IdentifierToken, VariableAssignmentKeyword, EndToken from pyVHDLParser.Blocks import Block, TokenToBlockParser from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock @@ -65,7 +65,7 @@ def stateTypeKeyword(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace1 return @@ -103,7 +103,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateTypeName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -142,7 +142,7 @@ def stateTypeName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace2 return @@ -183,7 +183,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateColon1() return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -218,7 +218,7 @@ def stateColon1(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NextState = cls.stateWhitespace3 return @@ -260,7 +260,7 @@ def stateWhitespace3(cls, parserState: TokenToBlockParser): parserState.NewToken = IdentifierToken(fromExistingToken=token) parserState.NextState = cls.stateTypeMarkName return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -299,7 +299,7 @@ def stateTypeMarkName(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace4 return @@ -336,7 +336,7 @@ def stateWhitespace4(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None @@ -382,7 +382,7 @@ def stateVariableAssignment(cls, parserState: TokenToBlockParser): parserState.PushState = MultiLineCommentBlock.statePossibleCommentStart parserState.TokenMarker = token return - elif isinstance(token, SpaceToken): + elif isinstance(token, WhitespaceToken): parserState.NextState = cls.stateWhitespace5 return @@ -418,7 +418,7 @@ def stateWhitespace5(cls, parserState: TokenToBlockParser): elif isinstance(token, WordToken): parserState.NextState = cls.stateExpressionEnd return - elif isinstance(token, SpaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): + elif isinstance(token, WhitespaceToken) and isinstance(parserState.LastBlock, MultiLineCommentBlock): parserState.NewToken = BoundaryToken(fromExistingToken=token) parserState.NewBlock = WhitespaceBlock(parserState.LastBlock, parserState.NewToken) parserState.TokenMarker = None diff --git a/pyVHDLParser/Blocks/Whitespace.py b/pyVHDLParser/Blocks/Whitespace.py index 9173f794a..c6c3c2c8a 100644 --- a/pyVHDLParser/Blocks/Whitespace.py +++ b/pyVHDLParser/Blocks/Whitespace.py @@ -29,7 +29,7 @@ # from pyTooling.Decorators import export -from pyVHDLParser.Token import SpaceToken, IndentationToken +from pyVHDLParser.Token import WhitespaceToken, IndentationToken from pyVHDLParser.Blocks import TokenToBlockParser, SkipableBlock @@ -52,7 +52,7 @@ class LinebreakBlock(WhitespaceBlock): @classmethod def stateLinebreak(cls, parserState: TokenToBlockParser): token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): parserState.NewToken = IndentationToken(fromExistingToken=token) parserState.NewBlock = IndentationBlock(parserState.LastBlock, parserState.NewToken) parserState.Pop() diff --git a/pyVHDLParser/Blocks/__init__.py b/pyVHDLParser/Blocks/__init__.py index 9f0ec9b86..e6d4e797a 100644 --- a/pyVHDLParser/Blocks/__init__.py +++ b/pyVHDLParser/Blocks/__init__.py @@ -36,7 +36,7 @@ from pyVHDLParser import StartOfDocument, EndOfDocument, StartOfSnippet, EndOfSnippet from pyVHDLParser.Base import ParserException -from pyVHDLParser.Token import CharacterToken, Token, SpaceToken, IndentationToken, LinebreakToken, CommentToken, TokenIterator +from pyVHDLParser.Token import CharacterToken, Token, WhitespaceToken, IndentationToken, LinebreakToken, CommentToken, TokenIterator from pyVHDLParser.Token import WordToken, EndOfDocumentToken, StartOfDocumentToken from pyVHDLParser.Token.Keywords import LibraryKeyword, UseKeyword, ContextKeyword, EntityKeyword, ArchitectureKeyword, PackageKeyword @@ -498,7 +498,7 @@ def stateDocument(cls, parserState: TokenToBlockParser): from pyVHDLParser.Blocks.Whitespace import IndentationBlock, WhitespaceBlock, LinebreakBlock token = parserState.Token - if isinstance(token, SpaceToken): + if isinstance(token, WhitespaceToken): blockType = IndentationBlock if isinstance(token, IndentationToken) else WhitespaceBlock parserState.NewBlock = blockType(parserState.LastBlock, token) parserState.TokenMarker = None diff --git a/pyVHDLParser/CLI/Group.py b/pyVHDLParser/CLI/Group.py index 22dfbea39..01d1aa856 100644 --- a/pyVHDLParser/CLI/Group.py +++ b/pyVHDLParser/CLI/Group.py @@ -33,7 +33,7 @@ from .GraphML import GraphML from ..Base import ParserException -from ..Token import CharacterToken, SpaceToken, WordToken, LinebreakToken, CommentToken, IndentationToken +from ..Token import CharacterToken, WhitespaceToken, WordToken, LinebreakToken, CommentToken, IndentationToken from ..Token.Parser import Tokenizer from ..Token.Keywords import BoundaryToken, EndToken, KeywordToken, DelimiterToken from ..Blocks import TokenToBlockParser @@ -113,7 +113,7 @@ def HandleGroupStreaming(self : FrontEndProtocol, args): print("{DARK_GREEN} {block}{NOCOLOR}".format(block=block, **self.Foreground)) elif isinstance(block, KeywordToken): print("{DARK_CYAN} {block}{NOCOLOR}".format(block=block, **self.Foreground)) - elif isinstance(block, (WordToken, SpaceToken, CharacterToken)): + elif isinstance(block, (WordToken, WhitespaceToken, CharacterToken)): print("{DARK_GREEN} {block}{NOCOLOR}".format(block=block, **self.Foreground)) else: print("{YELLOW} {block}{NOCOLOR}".format(block=block, **self.Foreground)) diff --git a/pyVHDLParser/CLI/Token.py b/pyVHDLParser/CLI/Token.py index e35873771..c1d5e4241 100644 --- a/pyVHDLParser/CLI/Token.py +++ b/pyVHDLParser/CLI/Token.py @@ -35,7 +35,7 @@ from pyVHDLParser.Base import ParserException from pyVHDLParser.CLI.GraphML import GraphML -from pyVHDLParser.Token import StartOfDocumentToken, EndOfDocumentToken, CharacterToken, SpaceToken, WordToken, LinebreakToken, CommentToken, IndentationToken +from pyVHDLParser.Token import StartOfDocumentToken, EndOfDocumentToken, CharacterToken, WhitespaceToken, WordToken, LinebreakToken, CommentToken, IndentationToken from pyVHDLParser.Token import CharacterTranslation, SingleLineCommentToken from pyVHDLParser.Token.Parser import Tokenizer @@ -75,7 +75,7 @@ def HandleTokenize(self: FrontEndProtocol, args): try: tokenIterator = firstToken.GetIterator(inclusiveStopToken=False) for token in tokenIterator: - if isinstance(token, (LinebreakToken, SpaceToken, IndentationToken)): + if isinstance(token, (LinebreakToken, WhitespaceToken, IndentationToken)): print("{DARK_GRAY}{token!r}{NOCOLOR}".format(token=token, **self.Foreground)) elif isinstance(token, CommentToken): print("{DARK_GREEN}{token!r}{NOCOLOR}".format(token=token, **self.Foreground)) diff --git a/pyVHDLParser/CLI/__init__.py b/pyVHDLParser/CLI/__init__.py index 787193395..f75383b60 100644 --- a/pyVHDLParser/CLI/__init__.py +++ b/pyVHDLParser/CLI/__init__.py @@ -33,7 +33,7 @@ from pyAttributes.ArgParseAttributes import ArgumentAttribute, SwitchArgumentAttribute from pyVHDLParser.Token import LinebreakToken, IndentationToken, CommentToken, StringLiteralToken -from pyVHDLParser.Token import IntegerLiteralToken, WordToken, Token, SpaceToken, CharacterToken +from pyVHDLParser.Token import IntegerLiteralToken, WordToken, Token, WhitespaceToken, CharacterToken from pyVHDLParser.Token.Keywords import KeywordToken @@ -73,7 +73,7 @@ class FrontEndProtocol(Protocol): TOKENTYPE_TO_COLOR_TRANSLATION = { LinebreakToken: "black", IndentationToken: "grey", - SpaceToken: "lightblue1", + WhitespaceToken: "lightblue1", CharacterToken: "darkorange", CommentToken: "forestgreen", StringLiteralToken: "chocolate1", diff --git a/pyVHDLParser/Token/Parser.py b/pyVHDLParser/Token/Parser.py index 5126d1b70..6e89d8ff6 100644 --- a/pyVHDLParser/Token/Parser.py +++ b/pyVHDLParser/Token/Parser.py @@ -36,7 +36,7 @@ from pyVHDLParser.Base import ParserException from pyVHDLParser.Token import StartOfDocumentToken, EndOfDocumentToken, IndentationToken, FusedCharacterToken from pyVHDLParser.Token import CharacterLiteralToken, StringLiteralToken, ExtendedIdentifier, DirectiveToken, IntegerLiteralToken, RealLiteralToken -from pyVHDLParser.Token import CharacterToken, SpaceToken, WordToken, SingleLineCommentToken, MultiLineCommentToken, LinebreakToken +from pyVHDLParser.Token import CharacterToken, WhitespaceToken, WordToken, SingleLineCommentToken, MultiLineCommentToken, LinebreakToken @export @@ -105,7 +105,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): if isinstance(previousToken, (LinebreakToken, SingleLineCommentToken, StartOfDocumentToken)): previousToken = IndentationToken(previousToken, buffer, start, end) else: - previousToken = SpaceToken(previousToken, buffer, start, end) + previousToken = WhitespaceToken(previousToken, buffer, start, end) yield previousToken start = SourceCodePosition(row, column, absolute) @@ -125,7 +125,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): tokenKind = cls.TokenKind.FuseableCharacter elif char == ".": tokenKind = cls.TokenKind.PossibleRealLiteral elif char == "\\": tokenKind = cls.TokenKind.PossibleExtendedIdentifierStart - elif (char == "`") and isinstance(previousToken, (SpaceToken, LinebreakToken)): + elif (char == "`") and isinstance(previousToken, (WhitespaceToken, LinebreakToken)): tokenKind = cls.TokenKind.Directive else: previousToken = CharacterToken(previousToken, char, start) @@ -159,7 +159,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): buffer = char tokenKind = cls.TokenKind.FuseableCharacter elif char == "\\": tokenKind = cls.TokenKind.PossibleExtendedIdentifierStart - elif (char == "`") and isinstance(previousToken, (SpaceToken, LinebreakToken)): + elif (char == "`") and isinstance(previousToken, (WhitespaceToken, LinebreakToken)): tokenKind = cls.TokenKind.Directive else: previousToken = CharacterToken(previousToken, char, start) @@ -190,7 +190,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): buffer = char tokenKind = cls.TokenKind.FuseableCharacter elif char == "\\": tokenKind = cls.TokenKind.PossibleExtendedIdentifierStart - elif (char == "`") and isinstance(previousToken, (SpaceToken, LinebreakToken)): + elif (char == "`") and isinstance(previousToken, (WhitespaceToken, LinebreakToken)): tokenKind = cls.TokenKind.Directive else: previousToken = CharacterToken(previousToken, char, start) @@ -220,7 +220,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): buffer = char tokenKind = cls.TokenKind.FuseableCharacter elif char == "\\": tokenKind = cls.TokenKind.PossibleExtendedIdentifierStart - elif (char == "`") and isinstance(previousToken, (SpaceToken, LinebreakToken)): + elif (char == "`") and isinstance(previousToken, (WhitespaceToken, LinebreakToken)): tokenKind = cls.TokenKind.Directive else: previousToken = CharacterToken(previousToken, char, start) @@ -251,7 +251,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): buffer = char tokenKind = cls.TokenKind.FuseableCharacter elif char == "\\": tokenKind = cls.TokenKind.PossibleExtendedIdentifierStart - elif (char == "`") and isinstance(previousToken, (SpaceToken, LinebreakToken)): + elif (char == "`") and isinstance(previousToken, (WhitespaceToken, LinebreakToken)): tokenKind = cls.TokenKind.Directive else: previousToken = CharacterToken(previousToken, char, start) @@ -291,7 +291,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): buffer = char tokenKind = cls.TokenKind.FuseableCharacter elif char == "\\": tokenKind = cls.TokenKind.PossibleExtendedIdentifierStart - elif (char == "`") and isinstance(previousToken, (SpaceToken, LinebreakToken)): + elif (char == "`") and isinstance(previousToken, (WhitespaceToken, LinebreakToken)): tokenKind = cls.TokenKind.Directive else: previousToken = CharacterToken(previousToken, char, start) @@ -325,7 +325,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): buffer = char tokenKind = cls.TokenKind.FuseableCharacter elif char == "\\": tokenKind = cls.TokenKind.PossibleExtendedIdentifierStart - elif (char == "`") and isinstance(previousToken, (SpaceToken, LinebreakToken)): + elif (char == "`") and isinstance(previousToken, (WhitespaceToken, LinebreakToken)): tokenKind = cls.TokenKind.Directive else: previousToken = CharacterToken(previousToken, char, start) @@ -440,7 +440,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): elif char in __FUSEABLE_CHARS__: pass elif char == "\\": tokenKind = cls.TokenKind.PossibleExtendedIdentifierStart - elif (char == "`") and isinstance(previousToken, (SpaceToken, LinebreakToken)): + elif (char == "`") and isinstance(previousToken, (WhitespaceToken, LinebreakToken)): tokenKind = cls.TokenKind.Directive else: previousToken = CharacterToken(previousToken, char, start) @@ -465,7 +465,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): buffer = char tokenKind = cls.TokenKind.FuseableCharacter elif char == "\\": tokenKind = cls.TokenKind.PossibleExtendedIdentifierStart - elif (char == "`") and isinstance(previousToken, (SpaceToken, LinebreakToken)): + elif (char == "`") and isinstance(previousToken, (WhitespaceToken, LinebreakToken)): tokenKind = cls.TokenKind.Directive else: tokenKind = cls.TokenKind.OtherChars @@ -499,7 +499,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): if isinstance(previousToken, (LinebreakToken, SingleLineCommentToken, StartOfDocumentToken)): previousToken = IndentationToken(previousToken, buffer, start, end) else: - previousToken = SpaceToken(previousToken, buffer, start, end) + previousToken = WhitespaceToken(previousToken, buffer, start, end) yield previousToken elif tokenKind is cls.TokenKind.SingleLineComment: previousToken = SingleLineCommentToken(previousToken, buffer, start, SourceCodePosition(row, column, absolute)) diff --git a/pyVHDLParser/Token/__init__.py b/pyVHDLParser/Token/__init__.py index dfb84862e..c684ed0e0 100644 --- a/pyVHDLParser/Token/__init__.py +++ b/pyVHDLParser/Token/__init__.py @@ -583,7 +583,7 @@ def __repr__(self) -> str: @export -class SpaceToken(ValuedToken): +class WhitespaceToken(ValuedToken): """Token representing a whitespace (space or tab).""" def __repr__(self) -> str: @@ -775,7 +775,7 @@ def __repr__(self) -> str: @export -class IndentationToken(SpaceToken): +class IndentationToken(WhitespaceToken): """Token representing an indentation in a source code line.""" def __repr__(self) -> str: diff --git a/tests/unit/SimpleBlockSequences/Architecture.py b/tests/unit/SimpleBlockSequences/Architecture.py index d1057f693..92c1d95ad 100644 --- a/tests/unit/SimpleBlockSequences/Architecture.py +++ b/tests/unit/SimpleBlockSequences/Architecture.py @@ -29,7 +29,7 @@ # from unittest import TestCase -from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken, MultiLineCommentToken, SingleLineCommentToken +from pyVHDLParser.Token import StartOfDocumentToken, WordToken, WhitespaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken, MultiLineCommentToken, SingleLineCommentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock, CommentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock, IndentationBlock, LinebreakBlock from pyVHDLParser.Blocks.Structural import Architecture @@ -52,17 +52,17 @@ class SimpleArchitecture_OneLine_OnlyEnd(TestCase, ExpectedDataMixin, LinkingTes tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "of"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -85,19 +85,19 @@ class SimpleArchitecture_OneLine_EndWithKeyword(TestCase, ExpectedDataMixin, Lin tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "of"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "architecture"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -119,19 +119,19 @@ class SimpleArchitecture_OneLine_EndWithName(TestCase, ExpectedDataMixin, Linkin tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "of"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -153,21 +153,21 @@ class SimpleArchitecture_OneLine_EndWithKeywordAndName(TestCase, ExpectedDataMix tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "of"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -416,34 +416,34 @@ class SimpleArchitecture_SpacePlusSingleLineComments_EndWithKeywordAndName(TestC tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (WordToken, "of"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (SingleLineCommentToken, "-- comment\n"), (EndOfDocumentToken, None) ] diff --git a/tests/unit/SimpleBlockSequences/Assert.py b/tests/unit/SimpleBlockSequences/Assert.py index f6fbd023c..b331f75c1 100644 --- a/tests/unit/SimpleBlockSequences/Assert.py +++ b/tests/unit/SimpleBlockSequences/Assert.py @@ -29,7 +29,7 @@ # from unittest import TestCase -from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken, StringLiteralToken +from pyVHDLParser.Token import StartOfDocumentToken, WordToken, WhitespaceToken, CharacterToken, EndOfDocumentToken, StringLiteralToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Reporting import Assert @@ -53,26 +53,26 @@ class SimpleAssertInArchitecture_OneLine_OnlyAssert(TestCase, ExpectedDataMixin, tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "of"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "assert"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "true"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "report"), - (SpaceToken, " "), + (WhitespaceToken, " "), (StringLiteralToken, "error"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/Constant.py b/tests/unit/SimpleBlockSequences/Constant.py index 3e298114a..0763b49e2 100644 --- a/tests/unit/SimpleBlockSequences/Constant.py +++ b/tests/unit/SimpleBlockSequences/Constant.py @@ -33,7 +33,7 @@ from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Object import Constant from pyVHDLParser.Blocks.Structural import Architecture -from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken, IntegerLiteralToken +from pyVHDLParser.Token import StartOfDocumentToken, WordToken, WhitespaceToken, CharacterToken, EndOfDocumentToken, IntegerLiteralToken from tests.unit.Common import Initializer, ExpectedTokenStream, ExpectedBlockStream, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence @@ -53,30 +53,30 @@ class SimpleConstantInArchitecture_OneLine(TestCase, ExpectedDataMixin, LinkingT tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "of"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "constant"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "c"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "bit"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":="), - (SpaceToken, " "), + (WhitespaceToken, " "), (IntegerLiteralToken, "0"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/Context.py b/tests/unit/SimpleBlockSequences/Context.py index 67b336a5b..a0eea0650 100644 --- a/tests/unit/SimpleBlockSequences/Context.py +++ b/tests/unit/SimpleBlockSequences/Context.py @@ -31,7 +31,7 @@ from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Reference import Use, Context -from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken +from pyVHDLParser.Token import WordToken, StartOfDocumentToken, WhitespaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from tests.unit.Common import Initializer, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence, ExpectedTokenStream, ExpectedBlockStream @@ -51,22 +51,22 @@ class Library_OneLine_SingleLibrary(TestCase, ExpectedDataMixin, LinkingTests, T tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "context"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "ctx"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "use"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "lib0"), (CharacterToken, "."), (WordToken, "pkg0"), (CharacterToken, "."), (WordToken, "all"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "context"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/Entity.py b/tests/unit/SimpleBlockSequences/Entity.py index 2d1c9b6d6..1a6a28ca2 100644 --- a/tests/unit/SimpleBlockSequences/Entity.py +++ b/tests/unit/SimpleBlockSequences/Entity.py @@ -30,7 +30,7 @@ from textwrap import dedent from unittest import TestCase -from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken +from pyVHDLParser.Token import WordToken, StartOfDocumentToken, WhitespaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock, LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.Structural import Entity @@ -53,11 +53,11 @@ class SimpleEntity_OneLine_OnlyEnd(TestCase, ExpectedDataMixin, LinkingTests, To tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -75,19 +75,19 @@ class SimpleEntity_OneLine_OnlyEnd(TestCase, ExpectedDataMixin, LinkingTests, To class SimpleEntity_OneLine_EndWithKeyword(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence): code = "entity e is end entity;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "entity"), # entity - (SpaceToken, " "), # - (WordToken, "e"), # e - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "entity"), # entity - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "entity"), # entity + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -102,19 +102,19 @@ class SimpleEntity_OneLine_EndWithKeyword(TestCase, ExpectedDataMixin, LinkingTe 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) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -129,21 +129,21 @@ class SimpleEntity_OneLine_EndWithName(TestCase, ExpectedDataMixin, LinkingTests class SimpleEntity_OneLine_EndWithKeywordAndName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence): code = "entity e is end entity e;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "entity"), # entity - (SpaceToken, " "), # - (WordToken, "e"), # e - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "entity"), # entity - (SpaceToken, " "), # - (WordToken, "e"), # e - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -158,19 +158,19 @@ class SimpleEntity_OneLine_EndWithKeywordAndName(TestCase, ExpectedDataMixin, Li class SimpleEntity_OneLine_NoName_EndWithKeywordAndName(TestCase, ExpectedDataMixin, TokenLinking, TokenSequence, BlockSequenceWithParserError): code = "entity is end entity e;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "entity"), # entity - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "entity"), # entity - (SpaceToken, " "), # - (WordToken, "e"), # e - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -185,19 +185,19 @@ class SimpleEntity_OneLine_NoName_EndWithKeywordAndName(TestCase, ExpectedDataMi class SimpleEntity_OneLine_NoIs_EndWithKeywordAndName(TestCase, ExpectedDataMixin, TokenLinking, TokenSequence, BlockSequenceWithParserError): code = "entity e end entity e;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "entity"), # entity - (SpaceToken, " "), # - (WordToken, "e"), # e - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "entity"), # entity - (SpaceToken, " "), # - (WordToken, "e"), # e - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -212,19 +212,19 @@ class SimpleEntity_OneLine_NoIs_EndWithKeywordAndName(TestCase, ExpectedDataMixi 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) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -239,21 +239,21 @@ class SimpleEntity_OneLine_NoEnd_EndWithKeywordAndName(TestCase, ExpectedDataMix class SimpleEntity_OneLine_EndWithKeywordAndName_WrongName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence): code = "entity e is end entity a;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "entity"), # entity - (SpaceToken, " "), # - (WordToken, "e"), # e - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "entity"), # entity - (SpaceToken, " "), # - (WordToken, "a"), # a - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "e"), # e + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "entity"), # entity + (WhitespaceToken, " "), # + (WordToken, "a"), # a + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -273,17 +273,17 @@ class SimpleEntity_MultiLine_LongForm(TestCase, ExpectedDataMixin, LinkingTests, tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, "\n"), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ";"), (LinebreakToken, "\n"), (EndOfDocumentToken, None) @@ -354,21 +354,21 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric(TestCase, ExpectedDataMi tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), (WordToken, "generic"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "("), (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -376,9 +376,9 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric(TestCase, ExpectedDataMi (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), (CharacterToken, ";"), (LinebreakToken, None), @@ -416,9 +416,9 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric_NoGenericKeyword(TestCas tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -426,9 +426,9 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric_NoGenericKeyword(TestCas (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -436,9 +436,9 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric_NoGenericKeyword(TestCas (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -475,9 +475,9 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric_NoOpeningRoundBracket(Te tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -485,9 +485,9 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric_NoOpeningRoundBracket(Te (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -495,9 +495,9 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric_NoOpeningRoundBracket(Te (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -534,30 +534,30 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric_NoClosingRoundBracket(Te tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), (WordToken, "generic"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "("), (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -594,30 +594,30 @@ class SimpleEntity_MultiLine_LongForm_WithSingleGeneric_TypoInGeneric(TestCase, tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), (WordToken, "gen"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "("), (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/Function.py b/tests/unit/SimpleBlockSequences/Function.py index ab00a2eab..9869b7613 100644 --- a/tests/unit/SimpleBlockSequences/Function.py +++ b/tests/unit/SimpleBlockSequences/Function.py @@ -29,7 +29,7 @@ # from unittest import TestCase -from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken +from pyVHDLParser.Token import WordToken, StartOfDocumentToken, WhitespaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Sequential import Package, Function @@ -51,20 +51,20 @@ class SimpleFunctionInPackage_OneLine_NoParameter(TestCase, ExpectedDataMixin, L tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "function"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "f"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "return"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "bit"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/Library.py b/tests/unit/SimpleBlockSequences/Library.py index b49cf6a6e..7a634534c 100644 --- a/tests/unit/SimpleBlockSequences/Library.py +++ b/tests/unit/SimpleBlockSequences/Library.py @@ -30,7 +30,7 @@ from unittest import TestCase from pyVHDLParser.Blocks.Reference import Library -from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken +from pyVHDLParser.Token import WordToken, StartOfDocumentToken, WhitespaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from tests.unit.Common import Initializer, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence, ExpectedTokenStream, ExpectedBlockStream @@ -50,7 +50,7 @@ class Library_OneLine_SingleLibrary(TestCase, ExpectedDataMixin, LinkingTests, T tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "library"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "lib0"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -70,16 +70,16 @@ class Library_OneLine_TripleLibrary(TestCase, ExpectedDataMixin, LinkingTests, T tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "library"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "lib0"), (CharacterToken, ","), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "lib1"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ","), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "lib2"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ";"), (EndOfDocumentToken, None) ] diff --git a/tests/unit/SimpleBlockSequences/Package.py b/tests/unit/SimpleBlockSequences/Package.py index 598c74005..879edcf1d 100644 --- a/tests/unit/SimpleBlockSequences/Package.py +++ b/tests/unit/SimpleBlockSequences/Package.py @@ -30,7 +30,7 @@ from textwrap import dedent from unittest import TestCase -from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken +from pyVHDLParser.Token import WordToken, StartOfDocumentToken, WhitespaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock, LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.List import GenericList @@ -53,11 +53,11 @@ class SimplePackage_OneLine_OnlyEnd(TestCase, ExpectedDataMixin, LinkingTests, T tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -75,19 +75,19 @@ class SimplePackage_OneLine_OnlyEnd(TestCase, ExpectedDataMixin, LinkingTests, T 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) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # e + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -102,19 +102,19 @@ class SimplePackage_OneLine_EndWithKeyword(TestCase, ExpectedDataMixin, LinkingT class SimplePackage_OneLine_EndWithName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence): code = "package p is end p;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "p"), # p - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "p"), # p - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -129,21 +129,21 @@ class SimplePackage_OneLine_EndWithName(TestCase, ExpectedDataMixin, LinkingTest class SimplePackage_OneLine_EndWithKeywordAndName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence): code = "package p is end package p;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "p"), # p - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "p"), # p - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -158,19 +158,19 @@ class SimplePackage_OneLine_EndWithKeywordAndName(TestCase, ExpectedDataMixin, L class SimplePackage_OneLine_NoName_EndWithKeywordAndName(TestCase, ExpectedDataMixin, TokenLinking, TokenSequence, BlockSequenceWithParserError): code = "package is end package p;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "p"), # p - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -185,19 +185,19 @@ class SimplePackage_OneLine_NoName_EndWithKeywordAndName(TestCase, ExpectedDataM class SimplePackage_OneLine_NoIs_EndWithKeywordAndName(TestCase, ExpectedDataMixin, TokenLinking, TokenSequence, BlockSequenceWithParserError): code = "package p end package p;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "p"), # p - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "p"), # p - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -212,19 +212,19 @@ class SimplePackage_OneLine_NoIs_EndWithKeywordAndName(TestCase, ExpectedDataMix 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) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -239,21 +239,21 @@ class SimplePackage_OneLine_NoEnd_EndWithKeywordAndName(TestCase, ExpectedDataMi class SimplePackage_OneLine_EndWithKeywordAndName_WrongName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence): code = "package p is end package a;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "p"), # p - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "a"), # a - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "a"), # a + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -273,17 +273,17 @@ class SimplePackage_MultiLine_LongForm(TestCase, ExpectedDataMixin, LinkingTests tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, "\n"), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ";"), (LinebreakToken, "\n"), (EndOfDocumentToken, None) @@ -354,21 +354,21 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric(TestCase, ExpectedDataM tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), (WordToken, "generic"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "("), (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -376,9 +376,9 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric(TestCase, ExpectedDataM (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), (CharacterToken, ";"), (LinebreakToken, None), @@ -416,9 +416,9 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric_NoGenericKeyword(TestCa tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -426,9 +426,9 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric_NoGenericKeyword(TestCa (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -436,9 +436,9 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric_NoGenericKeyword(TestCa (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -465,9 +465,9 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric_NoOpeningRoundBracket(T tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -475,9 +475,9 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric_NoOpeningRoundBracket(T (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -485,9 +485,9 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric_NoOpeningRoundBracket(T (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -514,30 +514,30 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric_NoClosingRoundBracket(T tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), (WordToken, "generic"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "("), (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -564,21 +564,21 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric_TypoInGeneric(TestCase, tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), (WordToken, "gen"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "("), (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -586,9 +586,9 @@ class SimplePackage_MultiLine_LongForm_WithSingleGeneric_TypoInGeneric(TestCase, (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/PackageBody.py b/tests/unit/SimpleBlockSequences/PackageBody.py index 88f7d5c1e..f2a6e47f0 100644 --- a/tests/unit/SimpleBlockSequences/PackageBody.py +++ b/tests/unit/SimpleBlockSequences/PackageBody.py @@ -30,7 +30,7 @@ from textwrap import dedent from unittest import TestCase -from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken +from pyVHDLParser.Token import WordToken, StartOfDocumentToken, WhitespaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken, IndentationToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock, LinebreakBlock, IndentationBlock from pyVHDLParser.Blocks.List import GenericList @@ -53,13 +53,13 @@ class SimplePackageBody_OneLine_OnlyEnd(TestCase, ExpectedDataMixin, LinkingTest tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "body"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -77,23 +77,23 @@ class SimplePackageBody_OneLine_OnlyEnd(TestCase, ExpectedDataMixin, LinkingTest class SimplePackageBody_OneLine_EndWithKeyword(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence): code = "package body p is end package body;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "body"), # package - (SpaceToken, " "), # - (WordToken, "p"), # e - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "body"), # body - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # package + (WhitespaceToken, " "), # + (WordToken, "p"), # e + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -108,21 +108,21 @@ class SimplePackageBody_OneLine_EndWithKeyword(TestCase, ExpectedDataMixin, Link class SimplePackageBody_OneLine_EndWithName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence): code = "package body p is end p;" 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, "p"), # p - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -137,25 +137,25 @@ class SimplePackageBody_OneLine_EndWithName(TestCase, ExpectedDataMixin, Linking class SimplePackageBody_OneLine_EndWithKeywordAndName(TestCase, ExpectedDataMixin, LinkingTests, TokenSequence, BlockSequence): code = "package body p is end package body p;" 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, "p"), # p - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -170,23 +170,23 @@ class SimplePackageBody_OneLine_EndWithKeywordAndName(TestCase, ExpectedDataMixi class SimplePackageBody_OneLine_NoName_EndWithKeywordAndName(TestCase, ExpectedDataMixin, TokenLinking, TokenSequence, BlockSequenceWithParserError): code = "package body is end package body p;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "body"), # body - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "end"), # end - (SpaceToken, " "), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "body"), # body - (SpaceToken, " "), # - (WordToken, "p"), # p - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -201,23 +201,23 @@ class SimplePackageBody_OneLine_NoName_EndWithKeywordAndName(TestCase, ExpectedD 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) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -232,23 +232,23 @@ class SimplePackageBody_OneLine_NoIs_EndWithKeywordAndName(TestCase, ExpectedDat class SimplePackageBody_OneLine_NoEnd_EndWithKeywordAndName(TestCase, ExpectedDataMixin, TokenLinking, TokenSequence, BlockSequenceWithParserError): code = "package body p is package body p;" tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "body"), # body - (SpaceToken, " "), # - (WordToken, "p"), # p - (SpaceToken, " "), # - (WordToken, "is"), # is - (SpaceToken, " "), # - (WordToken, "package"), # package - (SpaceToken, " "), # - (WordToken, "body"), # body - (SpaceToken, " "), # - (WordToken, "p"), # p - (CharacterToken, ";"), # ; - (EndOfDocumentToken, None) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -263,25 +263,25 @@ class SimplePackageBody_OneLine_NoEnd_EndWithKeywordAndName(TestCase, ExpectedDa 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) # - ] + [(StartOfDocumentToken, None), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "p"), # p + (WhitespaceToken, " "), # + (WordToken, "is"), # is + (WhitespaceToken, " "), # + (WordToken, "end"), # end + (WhitespaceToken, " "), # + (WordToken, "package"), # package + (WhitespaceToken, " "), # + (WordToken, "body"), # body + (WhitespaceToken, " "), # + (WordToken, "a"), # a + (CharacterToken, ";"), # ; + (EndOfDocumentToken, None) # + ] ) blockStream = ExpectedBlockStream( [ (StartOfDocumentBlock, None), # @@ -301,21 +301,21 @@ class SimplePackageBody_MultiLine_LongForm(TestCase, ExpectedDataMixin, LinkingT tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "body"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, "\n"), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "body"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ";"), (LinebreakToken, "\n"), (EndOfDocumentToken, None) @@ -394,23 +394,23 @@ class SimplePackageBody_MultiLine_LongForm_WithSingleGeneric(TestCase, ExpectedD tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "body"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), (LinebreakToken, None), (IndentationToken, "\t"), (WordToken, "generic"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "("), (LinebreakToken, None), (IndentationToken, "\t\t"), (WordToken, "G"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "integer"), (LinebreakToken, None), (IndentationToken, "\t"), @@ -418,11 +418,11 @@ class SimplePackageBody_MultiLine_LongForm_WithSingleGeneric(TestCase, ExpectedD (CharacterToken, ";"), (LinebreakToken, None), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "body"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), (CharacterToken, ";"), (LinebreakToken, None), diff --git a/tests/unit/SimpleBlockSequences/PortList.py b/tests/unit/SimpleBlockSequences/PortList.py index 3ff158dd3..a2ea26820 100644 --- a/tests/unit/SimpleBlockSequences/PortList.py +++ b/tests/unit/SimpleBlockSequences/PortList.py @@ -31,7 +31,7 @@ from pyVHDLParser.Blocks.List import PortList from pyVHDLParser.Blocks.List.PortList import PortListInterfaceSignalBlock -from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken +from pyVHDLParser.Token import WordToken, StartOfDocumentToken, WhitespaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Structural import Entity @@ -53,22 +53,22 @@ class SimplePortList_OneLine_SinglePort(TestCase, ExpectedDataMixin, LinkingTest tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "port"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "("), (WordToken, "port1"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "bit"), (CharacterToken, ")"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) @@ -92,30 +92,30 @@ class SimplePortList_OneLine_DoublePort(TestCase, ExpectedDataMixin, TokenLinkin tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "entity"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "port"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "("), (WordToken, "port1"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "bit"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "port2"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "boolean"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ")"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/Procedure.py b/tests/unit/SimpleBlockSequences/Procedure.py index 8cc78c1ed..327fc08ee 100644 --- a/tests/unit/SimpleBlockSequences/Procedure.py +++ b/tests/unit/SimpleBlockSequences/Procedure.py @@ -29,7 +29,7 @@ # from unittest import TestCase -from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken +from pyVHDLParser.Token import WordToken, StartOfDocumentToken, WhitespaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Sequential import Package, Procedure @@ -51,16 +51,16 @@ class SimpleProcedureInPackage_OneLine_NoParameter(TestCase, ExpectedDataMixin, tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "package"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "procedure"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "p"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/Process.py b/tests/unit/SimpleBlockSequences/Process.py index 6cabcbc84..994376834 100644 --- a/tests/unit/SimpleBlockSequences/Process.py +++ b/tests/unit/SimpleBlockSequences/Process.py @@ -29,7 +29,7 @@ # from unittest import TestCase -from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken +from pyVHDLParser.Token import StartOfDocumentToken, WordToken, WhitespaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Structural import Architecture @@ -53,26 +53,26 @@ class SimpleProcessInArchitecture_OneLine_NoIs(TestCase, ExpectedDataMixin, Link tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "of"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "process"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "process"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/Signal.py b/tests/unit/SimpleBlockSequences/Signal.py index 4fa5000f9..01bd8e46f 100644 --- a/tests/unit/SimpleBlockSequences/Signal.py +++ b/tests/unit/SimpleBlockSequences/Signal.py @@ -29,7 +29,7 @@ # from unittest import TestCase -from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, CharacterToken, EndOfDocumentToken +from pyVHDLParser.Token import StartOfDocumentToken, WordToken, WhitespaceToken, CharacterToken, EndOfDocumentToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import WhitespaceBlock from pyVHDLParser.Blocks.Object import Signal @@ -53,26 +53,26 @@ class SimpleSignalInArchitecture_OneLine_OnlyDeclaration(TestCase, ExpectedDataM tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "architecture"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "a"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "of"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "e"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "is"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "signal"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "s"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ":"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "bit"), (CharacterToken, ";"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "begin"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "end"), (CharacterToken, ";"), (EndOfDocumentToken, None) diff --git a/tests/unit/SimpleBlockSequences/Use.py b/tests/unit/SimpleBlockSequences/Use.py index c849555d0..bd0288070 100644 --- a/tests/unit/SimpleBlockSequences/Use.py +++ b/tests/unit/SimpleBlockSequences/Use.py @@ -29,7 +29,7 @@ # from unittest import TestCase -from pyVHDLParser.Token import WordToken, StartOfDocumentToken, SpaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken +from pyVHDLParser.Token import WordToken, StartOfDocumentToken, WhitespaceToken, CharacterToken, EndOfDocumentToken, LinebreakToken from pyVHDLParser.Blocks import StartOfDocumentBlock, EndOfDocumentBlock from pyVHDLParser.Blocks.Whitespace import LinebreakBlock from pyVHDLParser.Blocks.Reference import Use @@ -51,7 +51,7 @@ class Use_OneLine_SinglePackage_All(TestCase, ExpectedDataMixin, LinkingTests, T tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "use"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "lib0"), (CharacterToken, "."), (WordToken, "pkg0"), @@ -75,7 +75,7 @@ class Use_OneLine_SinglePackage_Const0(TestCase, ExpectedDataMixin, LinkingTests tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "use"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "lib0"), (CharacterToken, "."), (WordToken, "pkg0"), @@ -99,24 +99,24 @@ class Use_OneLine_DoublePackage_All(TestCase, ExpectedDataMixin, LinkingTests, T tokenStream = ExpectedTokenStream( [ (StartOfDocumentToken, None), (WordToken, "use"), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "lib0"), (CharacterToken, "."), (WordToken, "pkg0"), (CharacterToken, "."), (WordToken, "all"), (CharacterToken, ","), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "lib0"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "."), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "pkg1"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, "."), - (SpaceToken, " "), + (WhitespaceToken, " "), (WordToken, "all"), - (SpaceToken, " "), + (WhitespaceToken, " "), (CharacterToken, ";"), (EndOfDocumentToken, None) ] diff --git a/tests/unit/Tokenizer/Tokens.py b/tests/unit/Tokenizer/Tokens.py index a80497c8a..328dfba07 100644 --- a/tests/unit/Tokenizer/Tokens.py +++ b/tests/unit/Tokenizer/Tokens.py @@ -29,7 +29,7 @@ # from unittest import TestCase -from pyVHDLParser.Token import StartOfDocumentToken, WordToken, SpaceToken, LinebreakToken, IndentationToken, CharacterToken, CharacterLiteralToken, StringLiteralToken, BitStringLiteralToken, FusedCharacterToken, RealLiteralToken, IntegerLiteralToken, EndOfDocumentToken, ExtendedIdentifier, SingleLineCommentToken, MultiLineCommentToken +from pyVHDLParser.Token import StartOfDocumentToken, WordToken, WhitespaceToken, LinebreakToken, IndentationToken, CharacterToken, CharacterLiteralToken, StringLiteralToken, BitStringLiteralToken, FusedCharacterToken, RealLiteralToken, IntegerLiteralToken, EndOfDocumentToken, ExtendedIdentifier, SingleLineCommentToken, MultiLineCommentToken from pyVHDLParser.Token.Keywords import EntityKeyword from pyVHDLParser.Token.Parser import Tokenizer, TokenizerException @@ -46,107 +46,107 @@ class Sequence_1(TestCase, ExpectedDataMixin, TokenSequence): # code = "a bbb 1 23 3.4 45.6 5.67 67.89 .7 .89 ( ) < > = . , ; & / + - * << >> /= <= >= => := ** ?= ?/= ?< ?> ?<= ?>= <>" code = "a bbb 1 23 3.4 45.6 5.67 67.89 .7 .89 ( ) < > = . , ; & / + - * << >> /= <= >= => := ** ?= ?/= ?< ?> <> " tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), - (WordToken, "a"), - (SpaceToken, " "), - (WordToken, "bbb"), - (SpaceToken, " "), - (IntegerLiteralToken, "1"), - (SpaceToken, " "), - (IntegerLiteralToken, "23"), - (SpaceToken, " "), - (RealLiteralToken, "3.4"), - (SpaceToken, " "), - (RealLiteralToken, "45.6"), - (SpaceToken, " "), - (RealLiteralToken, "5.67"), - (SpaceToken, " "), - (RealLiteralToken, "67.89"), - (SpaceToken, " "), - (RealLiteralToken, ".7"), - (SpaceToken, " "), - (RealLiteralToken, ".89"), - (SpaceToken, " "), - (CharacterToken, "("), - (SpaceToken, " "), - (CharacterToken, ")"), - (SpaceToken, " "), - (CharacterToken, "<"), - (SpaceToken, " "), - (CharacterToken, ">"), - (SpaceToken, " "), - (CharacterToken, "="), - (SpaceToken, " "), - (CharacterToken, "."), - (SpaceToken, " "), - (CharacterToken, ","), - (SpaceToken, " "), - (CharacterToken, ";"), - (SpaceToken, " "), - (CharacterToken, "&"), - (SpaceToken, " "), - (CharacterToken, "/"), - (SpaceToken, " "), - (CharacterToken, "+"), - (SpaceToken, " "), - (CharacterToken, "-"), - (SpaceToken, " "), - (CharacterToken, "*"), - (SpaceToken, " "), -# (CharacterToken, "'"), -# (SpaceToken, " "), - (FusedCharacterToken, "<<"), - (SpaceToken, " "), - (FusedCharacterToken, ">>"), - (SpaceToken, " "), - (FusedCharacterToken, "/="), - (SpaceToken, " "), - (FusedCharacterToken, "<="), - (SpaceToken, " "), - (FusedCharacterToken, ">="), - (SpaceToken, " "), - (FusedCharacterToken, "=>"), - (SpaceToken, " "), - (FusedCharacterToken, ":="), - (SpaceToken, " "), - (FusedCharacterToken, "**"), - (SpaceToken, " "), - (FusedCharacterToken, "?="), - (SpaceToken, " "), - (FusedCharacterToken, "?/="), - (SpaceToken, " "), - (FusedCharacterToken, "?<"), - (SpaceToken, " "), - (FusedCharacterToken, "?>"), -# (SpaceToken, " "), -# (FusedCharacterToken, "?<="), -# (SpaceToken, " "), -# (FusedCharacterToken, "?>="), - (SpaceToken, " "), - (FusedCharacterToken, "<>"), - (SpaceToken, " "), # FIXME: workaround until incomplete fused tokens are handled in Tokenizer - (EndOfDocumentToken, None) - ] + [(StartOfDocumentToken, None), + (WordToken, "a"), + (WhitespaceToken, " "), + (WordToken, "bbb"), + (WhitespaceToken, " "), + (IntegerLiteralToken, "1"), + (WhitespaceToken, " "), + (IntegerLiteralToken, "23"), + (WhitespaceToken, " "), + (RealLiteralToken, "3.4"), + (WhitespaceToken, " "), + (RealLiteralToken, "45.6"), + (WhitespaceToken, " "), + (RealLiteralToken, "5.67"), + (WhitespaceToken, " "), + (RealLiteralToken, "67.89"), + (WhitespaceToken, " "), + (RealLiteralToken, ".7"), + (WhitespaceToken, " "), + (RealLiteralToken, ".89"), + (WhitespaceToken, " "), + (CharacterToken, "("), + (WhitespaceToken, " "), + (CharacterToken, ")"), + (WhitespaceToken, " "), + (CharacterToken, "<"), + (WhitespaceToken, " "), + (CharacterToken, ">"), + (WhitespaceToken, " "), + (CharacterToken, "="), + (WhitespaceToken, " "), + (CharacterToken, "."), + (WhitespaceToken, " "), + (CharacterToken, ","), + (WhitespaceToken, " "), + (CharacterToken, ";"), + (WhitespaceToken, " "), + (CharacterToken, "&"), + (WhitespaceToken, " "), + (CharacterToken, "/"), + (WhitespaceToken, " "), + (CharacterToken, "+"), + (WhitespaceToken, " "), + (CharacterToken, "-"), + (WhitespaceToken, " "), + (CharacterToken, "*"), + (WhitespaceToken, " "), + # (CharacterToken, "'"), + # (SpaceToken, " "), + (FusedCharacterToken, "<<"), + (WhitespaceToken, " "), + (FusedCharacterToken, ">>"), + (WhitespaceToken, " "), + (FusedCharacterToken, "/="), + (WhitespaceToken, " "), + (FusedCharacterToken, "<="), + (WhitespaceToken, " "), + (FusedCharacterToken, ">="), + (WhitespaceToken, " "), + (FusedCharacterToken, "=>"), + (WhitespaceToken, " "), + (FusedCharacterToken, ":="), + (WhitespaceToken, " "), + (FusedCharacterToken, "**"), + (WhitespaceToken, " "), + (FusedCharacterToken, "?="), + (WhitespaceToken, " "), + (FusedCharacterToken, "?/="), + (WhitespaceToken, " "), + (FusedCharacterToken, "?<"), + (WhitespaceToken, " "), + (FusedCharacterToken, "?>"), + # (SpaceToken, " "), + # (FusedCharacterToken, "?<="), + # (SpaceToken, " "), + # (FusedCharacterToken, "?>="), + (WhitespaceToken, " "), + (FusedCharacterToken, "<>"), + (WhitespaceToken, " "), # FIXME: workaround until incomplete fused tokens are handled in Tokenizer + (EndOfDocumentToken, None) + ] ) 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) - ] + [(StartOfDocumentToken, None), + (WordToken, "abc"), + (WhitespaceToken, " "), + (ExtendedIdentifier, "\\def\\"), + (WhitespaceToken, " \t "), + (CharacterLiteralToken, "a"), + (WhitespaceToken, " "), + (StringLiteralToken, "abc"), + (WhitespaceToken, " "), + (MultiLineCommentToken, "/* help */"), + (WhitespaceToken, " "), + (SingleLineCommentToken, "-- foo\n"), + (WhitespaceToken, " "), # FIXME: workaround until incomplete fused tokens are handled in Tokenizer + (EndOfDocumentToken, None) + ] ) class Sequence_3(TestCase, ExpectedDataMixin, TokenSequence): @@ -195,7 +195,7 @@ class Sequence_3(TestCase, ExpectedDataMixin, TokenSequence): (LinebreakToken, None), (IndentationToken, "\t"), (WordToken, "abc"), - (SpaceToken, " "), + (WhitespaceToken, " "), (EndOfDocumentToken, None) ] ) @@ -203,57 +203,57 @@ class Sequence_3(TestCase, ExpectedDataMixin, TokenSequence): class Sequence_4(TestCase, ExpectedDataMixin, TokenSequence): code = """abc-- comment\n123-- comment\n456.789-- comment\n'Z'-- comment\n"Hallo"-- comment\n\\foo\\-- comment\n-- comment\n/* comment */-- comment\n;-- comment\n -- comment\n """ tokenStream = ExpectedTokenStream( - [ (StartOfDocumentToken, None), - (WordToken, "abc"), - (SingleLineCommentToken, "-- comment\n"), - (IntegerLiteralToken, "123"), - (SingleLineCommentToken, "-- comment\n"), - (RealLiteralToken, "456.789"), - (SingleLineCommentToken, "-- comment\n"), - (CharacterLiteralToken, "Z"), - (SingleLineCommentToken, "-- comment\n"), - (StringLiteralToken, "Hallo"), - (SingleLineCommentToken, "-- comment\n"), - (ExtendedIdentifier, "\\foo\\"), - (SingleLineCommentToken, "-- comment\n"), - (SingleLineCommentToken, "-- comment\n"), - (MultiLineCommentToken, "/* comment */"), - (SingleLineCommentToken, "-- comment\n"), - (CharacterToken, ";"), - (SingleLineCommentToken, "-- comment\n"), - (IndentationToken, " "), - (SingleLineCommentToken, "-- comment\n"), - (SpaceToken, " "), # FIXME: workaround until incomplete fused tokens are handled in Tokenizer - (EndOfDocumentToken, None) - ] + [(StartOfDocumentToken, None), + (WordToken, "abc"), + (SingleLineCommentToken, "-- comment\n"), + (IntegerLiteralToken, "123"), + (SingleLineCommentToken, "-- comment\n"), + (RealLiteralToken, "456.789"), + (SingleLineCommentToken, "-- comment\n"), + (CharacterLiteralToken, "Z"), + (SingleLineCommentToken, "-- comment\n"), + (StringLiteralToken, "Hallo"), + (SingleLineCommentToken, "-- comment\n"), + (ExtendedIdentifier, "\\foo\\"), + (SingleLineCommentToken, "-- comment\n"), + (SingleLineCommentToken, "-- comment\n"), + (MultiLineCommentToken, "/* comment */"), + (SingleLineCommentToken, "-- comment\n"), + (CharacterToken, ";"), + (SingleLineCommentToken, "-- comment\n"), + (IndentationToken, " "), + (SingleLineCommentToken, "-- comment\n"), + (WhitespaceToken, " "), # FIXME: workaround until incomplete fused tokens are handled in Tokenizer + (EndOfDocumentToken, None) + ] ) 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) - ] + [(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 */"), + (WhitespaceToken, " "), + (MultiLineCommentToken, "/* comment */"), + (WhitespaceToken, " "), # FIXME: workaround until incomplete fused tokens are handled in Tokenizer + (EndOfDocumentToken, None) + ] ) class Tokenizer_ExceptionInKeyword(TestCase, ExpectedDataMixin, TokenSequence): From 7087c49e90b1c9e62e7b6881012b93f5ebf40c95 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 2 Apr 2023 22:40:51 +0200 Subject: [PATCH 06/15] Fixed asserts. --- tests/unit/Common.py | 93 ++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 51 deletions(-) diff --git a/tests/unit/Common.py b/tests/unit/Common.py index dea07e7ca..4369a86e4 100644 --- a/tests/unit/Common.py +++ b/tests/unit/Common.py @@ -144,7 +144,7 @@ def test_TokenLinking(self) -> None: tokenIterator = iter(tokenStream) startToken = next(tokenIterator) - self.assertIsInstance(startToken, StartOfDocumentToken, msg="First token is not StartOfDocumentToken: {token}".format(token=startToken)) + self.assertIsInstance(startToken, StartOfDocumentToken, msg=f"First token is not StartOfDocumentToken: {startToken}") self.assertIsNone(startToken.PreviousToken, msg="First token has no open start.") lastToken: Token = startToken @@ -155,17 +155,17 @@ def test_TokenLinking(self) -> None: endToken = token break - self.assertEqual(lastToken.NextToken, token, msg="Last token is not connected to the current token: {token}".format(token=token)) - self.assertEqual(lastToken, token.PreviousToken, msg="Current token is not connected to lastToken: {token}".format(token=token)) + self.assertIs(lastToken.NextToken, token, msg=f"Last token is not connected to the current token: {token}") + self.assertIs(lastToken, token.PreviousToken, msg=f"Current token is not connected to lastToken: {token}") lastToken = token else: self.fail(msg="No EndOfDocumentToken found.") - self.assertIsInstance(endToken, EndOfDocumentToken, msg="End token is not EndOfDocumentToken: {token}".format(token=endToken)) - self.assertEqual(lastToken.NextToken, endToken, msg="Last token is not connected to the end token: {token}".format(token=token)) - self.assertEqual(lastToken, endToken.PreviousToken, msg="End token is not connected to lastToken: {token}".format(token=token)) - self.assertIsNone(endToken.NextToken, msg="End token has no open end: {token}".format(token=endToken.NextToken)) + self.assertIsInstance(endToken, EndOfDocumentToken, msg=f"End token is not EndOfDocumentToken: {endToken}") + self.assertIs(lastToken.NextToken, endToken, msg=f"Last token is not connected to the end token: {token}") + self.assertIs(lastToken, endToken.PreviousToken, msg=f"End token is not connected to lastToken: {token}") + self.assertIsNone(endToken.NextToken, msg=f"End token has no open end: {endToken.NextToken}") class BlockSequence(ITestcase): #, ExpectedDataMixin): @@ -184,11 +184,7 @@ def test_BlockSequence(self) -> None: self.assertIsInstance( block, item[0], - msg="Block has not expected type.\n Actual: {actual!s}\n Expected: {expected}".format( -# actual=block.__class__.__qualname__, - actual=block, - expected=item[0].__qualname__ - ) + msg=f"Block has not expected type.\n Actual: {block!s}\n Expected: {item[0].__qualname__}" ) if item[1] is not None: blockValue = str(block) @@ -201,15 +197,15 @@ def test_BlockSequence(self) -> None: ) except TokenizerException as ex: - self.fail(msg="Unexpected 'TokenizerException' at {pos}".format(pos=ex.Position)) + self.fail(msg=f"Unexpected 'TokenizerException' at {ex.Position}") except BlockParserException as ex: - self.fail(msg="Unexpected 'BlockParserException' at {pos}".format(pos=ex.Token.Start)) + self.fail(msg=f"Unexpected 'BlockParserException' at {ex.Token.Start}") except StopIteration: pass except AssertionError: raise except Exception as ex: - self.fail(msg="Unexpected exception '{exname}' := {ex!s}.".format(ex=ex, exname=ex.__class__.__qualname__)) + self.fail(msg=f"Unexpected exception '{ex.__class__.__qualname__}' := {ex!s}.") class BlockSequenceWithParserError(ITestcase): #, ExpectedDataMixin): @@ -229,11 +225,7 @@ def test_BlockSequenceError(self) -> None: self.assertIsInstance( block, item[0], - msg="Block has not expected type.\n Actual: {actual!s}\n Expected: {expected}".format( - # actual=block.__class__.__qualname__, - actual=block, - expected=item[0].__qualname__ - ) + msg=f"Block has not expected type.\n Actual: {block!s}\n Expected: {item[0].__qualname__}" ) if item[1] is not None: blockValue = str(block) @@ -246,7 +238,7 @@ def test_BlockSequenceError(self) -> None: ) except TokenizerException as ex: - self.fail(msg="Unexpected 'TokenizerException' at {pos}".format(pos=ex.Position)) + self.fail(msg=f"Unexpected 'TokenizerException' at {ex.Position}") except BlockParserException: raise except StopIteration: @@ -254,7 +246,7 @@ def test_BlockSequenceError(self) -> None: except AssertionError: raise except Exception as ex: - self.fail(msg="Unexpected exception '{exname}' := {ex!s}.".format(ex=ex, exname=ex.__class__.__qualname__)) + self.fail(msg=f"Unexpected exception '{ex.__class__.__qualname__}' := {ex!s}.") print(ex) @@ -268,10 +260,10 @@ def test_BlockLinking(self) -> None: blockIterator = iter(blockStream) firstBlock = next(blockIterator) - self.assertIsInstance(firstBlock, StartOfDocumentBlock, msg="First block is not StartOfDocumentBlock: {block}".format(block=firstBlock)) + self.assertIsInstance(firstBlock, StartOfDocumentBlock, msg=f"First block is not StartOfDocumentBlock: {firstBlock}") startToken = firstBlock.StartToken - self.assertIsInstance(startToken, StartOfDocumentToken, msg="First token is not StartOfDocumentToken: {token}".format(token=startToken)) + self.assertIsInstance(startToken, StartOfDocumentToken, msg=f"First token is not StartOfDocumentToken: {startToken}") lastBlock: Block = firstBlock endBlock: Block = None @@ -283,19 +275,19 @@ def test_BlockLinking(self) -> None: break # Block checks - self.assertEqual(lastBlock.NextBlock, block, - msg="Last block is not connected to the current block: {block}".format(block=block)) - self.assertEqual(lastBlock, block.PreviousBlock, - msg="Current block is not connected to last block: {block}".format(block=block)) + self.assertIs(lastBlock.NextBlock, block, + msg=f"Last block is not connected to the current block: {block}") + self.assertIs(lastBlock, block.PreviousBlock, + msg=f"Current block is not connected to last block: {block}") # Token checks tokenIterator = iter(block) for token in tokenIterator: - self.assertIsNotNone(token.NextToken, msg="Token has an open end (token).".format(token=token.NextToken)) - self.assertEqual(lastToken.NextToken, token, msg="Last token is not connected to the current token.") + self.assertIsNotNone(token.NextToken, msg="Token has an open end (token).") + self.assertIs(lastToken.NextToken, token, msg="Last token is not connected to the current token.") self.assertIsNotNone(token.PreviousToken, msg="Token has an open end (PreviousToken).") - self.assertEqual(token.PreviousToken, lastToken, msg="Current token is not connected to lastToken.") + self.assertIs(token.PreviousToken, lastToken, msg="Current token is not connected to lastToken.") lastToken = token @@ -304,13 +296,13 @@ def test_BlockLinking(self) -> None: self.fail(msg="No EndOfDocumentBlock found.") # Block checks - self.assertIsInstance(endBlock, EndOfDocumentBlock, msg="End block is not EndOfDocumentblock: {token}".format(token=endBlock)) - self.assertIsInstance(endBlock.EndToken, EndOfDocumentToken, msg="End block's token is not EndOfDocumentToken: {token}".format(token=endBlock.EndToken)) + self.assertIsInstance(endBlock, EndOfDocumentBlock, msg=f"End block is not EndOfDocumentblock: {endBlock}") + self.assertIsInstance(endBlock.EndToken, EndOfDocumentToken, msg=f"End block's token is not EndOfDocumentToken: {endBlock.EndToken}") # Token checks - self.assertEqual(lastToken.NextToken, endBlock.EndToken, msg="Last token is not connected to the end token.") - self.assertEqual(lastToken, endBlock.EndToken.PreviousToken, msg="End token is not connected to lastToken.") - self.assertIsNone(endBlock.EndToken.NextToken, msg="End token has no open end: {token}".format(token=endBlock.EndToken.NextToken)) + self.assertIs(lastToken.NextToken, endBlock.EndToken, msg="Last token is not connected to the end token.") + self.assertIs(lastToken, endBlock.EndToken.PreviousToken, msg="End token is not connected to lastToken.") + self.assertIsNone(endBlock.EndToken.NextToken, msg=f"End token has no open end: {endBlock.EndToken.NextToken}") class BlockLinking(ITestcase): #, ExpectedDataMixin): @@ -322,10 +314,10 @@ def test_BlockLinking(self) -> None: blockIterator = iter(blockStream) firstBlock = next(blockIterator) - self.assertIsInstance(firstBlock, StartOfDocumentBlock, msg="First block is not StartOfDocumentBlock: {block}".format(block=firstBlock)) + self.assertIsInstance(firstBlock, StartOfDocumentBlock, msg=f"First block is not StartOfDocumentBlock: {firstBlock}") startToken = firstBlock.StartToken - self.assertIsInstance(startToken, StartOfDocumentToken, msg="First token is not StartOfDocumentToken: {token}".format(token=startToken)) + self.assertIsInstance(startToken, StartOfDocumentToken, msg=f"First token is not StartOfDocumentToken: {startToken}") lastBlock: Block = firstBlock endBlock: Block = None @@ -337,19 +329,19 @@ def test_BlockLinking(self) -> None: break # Block checks - self.assertEqual(lastBlock.NextBlock, block, - msg="Last block is not connected to the current block: {block}".format(block=block)) - self.assertEqual(lastBlock, block.PreviousBlock, - msg="Current block is not connected to last block: {block}".format(block=block)) + self.assertIs(lastBlock.NextBlock, block, + msg=f"Last block is not connected to the current block: {block}") + self.assertIs(lastBlock, block.PreviousBlock, + msg=f"Current block is not connected to last block: {block}") # Token checks tokenIterator = iter(block) for token in tokenIterator: - self.assertIsNotNone(token.NextToken, msg="Token has an open end (token).".format(token=token.NextToken)) - self.assertEqual(lastToken.NextToken, token, msg="Last token is not connected to the current token.") + self.assertIsNotNone(token.NextToken, msg="Token has an open end (token).") + self.assertIs(lastToken.NextToken, token, msg="Last token is not connected to the current token.") self.assertIsNotNone(token.PreviousToken, msg="Token has an open end (PreviousToken).") - self.assertEqual(token.PreviousToken, lastToken, msg="Current token is not connected to lastToken.") + self.assertIs(token.PreviousToken, lastToken, msg="Current token is not connected to lastToken.") lastToken = token @@ -358,14 +350,13 @@ def test_BlockLinking(self) -> None: self.fail(msg="No EndOfDocumentBlock found.") # Block checks - self.assertIsInstance(endBlock, EndOfDocumentBlock, msg="End block is not EndOfDocumentblock: {token}".format(token=endBlock)) - self.assertIsInstance(endBlock.EndToken, EndOfDocumentToken, msg="End block's token is not EndOfDocumentToken: {token}".format( - token=endBlock.EndToken)) + self.assertIsInstance(endBlock, EndOfDocumentBlock, msg=f"End block is not EndOfDocumentblock: {endBlock}") + self.assertIsInstance(endBlock.EndToken, EndOfDocumentToken, msg=f"End block's token is not EndOfDocumentToken: {endBlock.EndToken}") # Token checks - self.assertEqual(lastToken.NextToken, endBlock.EndToken, msg="Last token is not connected to the end token.") - self.assertEqual(lastToken, endBlock.EndToken.PreviousToken, msg="End token is not connected to lastToken.") - self.assertIsNone(endBlock.EndToken.NextToken, msg="End token has no open end: {token}".format(token=endBlock.EndToken.NextToken)) + self.assertIs(lastToken.NextToken, endBlock.EndToken, msg="Last token is not connected to the end token.") + self.assertIs(lastToken, endBlock.EndToken.PreviousToken, msg="End token is not connected to lastToken.") + self.assertIsNone(endBlock.EndToken.NextToken, msg=f"End token has no open end: {endBlock.EndToken.NextToken}") class LinkingTests(TokenLinking, BlockLinking): From f71eae8d4972fd044890c48540442d44e3c6a5f0 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 4 Apr 2023 00:08:59 +0200 Subject: [PATCH 07/15] Converted str.format to f-strings. --- pyVHDLParser/Blocks/Comment.py | 2 +- pyVHDLParser/Blocks/InterfaceObject.py | 6 +++--- pyVHDLParser/CLI/Block.py | 4 ++-- pyVHDLParser/CLI/CodeDOM.py | 2 +- pyVHDLParser/CLI/Group.py | 2 +- pyVHDLParser/CLI/VHDLParser.py | 16 ++++++++-------- pyVHDLParser/Token/Keywords.py | 4 ++-- pyVHDLParser/Token/Parser.py | 3 +-- pyVHDLParser/Token/__init__.py | 4 ++-- pyVHDLParser/__init__.py | 4 ++-- tests/IssueTester.py | 2 +- tests/Linking.py | 14 +++++++------- tests/unit/Common.py | 12 ++++++------ tests/unit/Tokenizer/Tokens.py | 6 +++--- 14 files changed, 40 insertions(+), 41 deletions(-) diff --git a/pyVHDLParser/Blocks/Comment.py b/pyVHDLParser/Blocks/Comment.py index 586ae140b..6fc42513e 100644 --- a/pyVHDLParser/Blocks/Comment.py +++ b/pyVHDLParser/Blocks/Comment.py @@ -46,7 +46,7 @@ def statePossibleCommentStart(cls, parserState: TokenToBlockParser): parserState.NextState = cls.stateConsumeComment return - raise NotImplementedError("State=PossibleCommentStart: {0!r}".format(token)) + raise NotImplementedError(f"State=PossibleCommentStart: {token!r}") @classmethod def stateConsumeComment(cls, parserState: TokenToBlockParser): diff --git a/pyVHDLParser/Blocks/InterfaceObject.py b/pyVHDLParser/Blocks/InterfaceObject.py index ef13ae1a6..949cca46e 100644 --- a/pyVHDLParser/Blocks/InterfaceObject.py +++ b/pyVHDLParser/Blocks/InterfaceObject.py @@ -77,7 +77,7 @@ def stateWhitespace1(cls, parserState: TokenToBlockParser): parserState.TokenMarker = None return - raise BlockParserException("Expected interface {0} name (identifier).".format(cls.OBJECT_KIND), token) + raise BlockParserException(f"Expected interface {cls.OBJECT_KIND} name (identifier).", token) @classmethod def stateObjectName(cls, parserState: TokenToBlockParser): @@ -98,7 +98,7 @@ def stateObjectName(cls, parserState: TokenToBlockParser): parserState.NextState = cls.stateWhitespace2 return - raise BlockParserException("Expected whitespace after interface {0} name.".format(cls.OBJECT_KIND), token) + raise BlockParserException(f"Expected whitespace after interface {cls.OBJECT_KIND} name.", token) @classmethod def stateWhitespace2(cls, parserState: TokenToBlockParser): @@ -127,7 +127,7 @@ def stateWhitespace2(cls, parserState: TokenToBlockParser): parserState.TokenMarker = None return - raise BlockParserException("Expected ':' after interface {0} name.".format(cls.OBJECT_KIND), token) + raise BlockParserException(f"Expected ':' after interface {cls.OBJECT_KIND} name.", token) @classmethod def stateColon1(cls, parserState: TokenToBlockParser): diff --git a/pyVHDLParser/CLI/Block.py b/pyVHDLParser/CLI/Block.py index 3a3347323..f6b22a31b 100644 --- a/pyVHDLParser/CLI/Block.py +++ b/pyVHDLParser/CLI/Block.py @@ -59,7 +59,7 @@ def HandleBlockStreaming(self: FrontEndProtocol, args): file = Path(args.Filename) if not file.exists(): - print("File '{0!s}' does not exist.".format(file)) + print(f"File '{file!s}' does not exist.") with file.open('r') as fileHandle: content = fileHandle.read() @@ -131,7 +131,7 @@ def HandleCheckBlockStreaming(self: FrontEndProtocol, args): file = Path(args.Filename) if not file.exists(): - print("File '{0!s}' does not exist.".format(file)) + print(f"File '{file!s}' does not exist.") with file.open('r') as fileHandle: content = fileHandle.read() diff --git a/pyVHDLParser/CLI/CodeDOM.py b/pyVHDLParser/CLI/CodeDOM.py index 9b4898471..b57b3e751 100644 --- a/pyVHDLParser/CLI/CodeDOM.py +++ b/pyVHDLParser/CLI/CodeDOM.py @@ -49,7 +49,7 @@ def HandleCodeDOM(self : FrontEndProtocol, args): file = Path(args.Filename) if not file.exists(): - print("File '{0!s}' does not exist.".format(file)) # raise error + print(f"File '{file!s}' does not exist.") # raise error with file.open('r') as fileHandle: content = fileHandle.read() diff --git a/pyVHDLParser/CLI/Group.py b/pyVHDLParser/CLI/Group.py index 01d1aa856..5c29b062c 100644 --- a/pyVHDLParser/CLI/Group.py +++ b/pyVHDLParser/CLI/Group.py @@ -56,7 +56,7 @@ def HandleGroupStreaming(self : FrontEndProtocol, args): file = Path(args.Filename) if not file.exists(): - print("File '{0!s}' does not exist.".format(file)) + print(f"File '{file!s}' does not exist.") with file.open('r') as fileHandle: content = fileHandle.read() diff --git a/pyVHDLParser/CLI/VHDLParser.py b/pyVHDLParser/CLI/VHDLParser.py index bfdbbb665..e57ffd29e 100644 --- a/pyVHDLParser/CLI/VHDLParser.py +++ b/pyVHDLParser/CLI/VHDLParser.py @@ -52,7 +52,7 @@ def printImportError(ex) -> NoReturn: # TODO: use pyTooling Platform platform = platform_system() print("IMPORT ERROR: One or more Python packages are not available in your environment.") - print("Missing package: '{0}'\n".format(ex.name)) + print(f"Missing package: '{ex.name}'\n") if platform == "Windows": print("Run: 'py.exe -3 -m pip install -r requirements.txt'\n") elif platform == "Linux": @@ -158,7 +158,7 @@ def HandleHelp(self, args): try: self.SubParsers[args.Command].print_help() except KeyError: - self.WriteError("Command {0} is unknown.".format(args.Command)) + self.WriteError(f"Command {args.Command} is unknown.") self.WriteNormal("") self.exit() @@ -171,15 +171,15 @@ def HandleInfo(self, args): self.PrintHeadline() copyrights = __copyright__.split("\n", 1) - self.WriteNormal("Copyright: {0}".format(copyrights[0])) + self.WriteNormal(f"Copyright: {copyrights[0]}") for copyright in copyrights[1:]: - self.WriteNormal(" {0}".format(copyright)) - self.WriteNormal("License: {0}".format(__license__)) + self.WriteNormal(f" {copyright}") + self.WriteNormal(f"License: {__license__}") authors = __author__.split(", ") - self.WriteNormal("Authors: {0}".format(authors[0])) + self.WriteNormal(f"Authors: {authors[0]}") for author in authors[1:]: - self.WriteNormal(" {0}".format(author)) - self.WriteNormal("Version: {0}".format(__version__)) + self.WriteNormal(f" {author}") + self.WriteNormal(f"Version: {__version__}") self.exit() diff --git a/pyVHDLParser/Token/Keywords.py b/pyVHDLParser/Token/Keywords.py index efdc70e2b..d1a8f9387 100644 --- a/pyVHDLParser/Token/Keywords.py +++ b/pyVHDLParser/Token/Keywords.py @@ -407,12 +407,12 @@ class KeywordToken(VHDLToken): def __init__(self, previousToken: Token = None, value: str = None, start: SourceCodePosition = None, end: SourceCodePosition = None, fromExistingToken: WordToken = None): if fromExistingToken is None: if value.lower() != self.__KEYWORD__: - raise TokenizerException("Expected keyword {0}.".format(self.__KEYWORD__.upper()), None) + raise TokenizerException(f"Expected keyword {self.__KEYWORD__.upper()}.", None) super().__init__(previousToken, value, str, end) else: if not (isinstance(fromExistingToken, WordToken) and (fromExistingToken <= self.__KEYWORD__)): - raise TokenizerException("Expected keyword {0}.".format(self.__KEYWORD__.upper()), fromExistingToken) + raise TokenizerException(f"Expected keyword {self.__KEYWORD__.upper()}.", fromExistingToken) super().__init__(fromExistingToken.PreviousToken, self.__KEYWORD__, fromExistingToken.Start, fromExistingToken.End) diff --git a/pyVHDLParser/Token/Parser.py b/pyVHDLParser/Token/Parser.py index 6e89d8ff6..887ec98c3 100644 --- a/pyVHDLParser/Token/Parser.py +++ b/pyVHDLParser/Token/Parser.py @@ -48,7 +48,7 @@ def __init__(self, message: str, position: SourceCodePosition): self.Position = position def __str__(self) -> str: - return "{0!s}: {1}".format(self.Position, self._message) + return f"{self.Position!s}: {self._message}" @export @@ -74,7 +74,6 @@ class TokenKind(IntEnum): FuseableCharacter = 15 #: Last char was a character that could be fused OtherChars = 16 #: Anything else - @classmethod def GetVHDLTokenizer(cls, iterable: Iterator[str]): previousToken = StartOfDocumentToken() diff --git a/pyVHDLParser/Token/__init__.py b/pyVHDLParser/Token/__init__.py index c684ed0e0..a86ad35f9 100644 --- a/pyVHDLParser/Token/__init__.py +++ b/pyVHDLParser/Token/__init__.py @@ -437,11 +437,11 @@ def __init__(self): Initializes the first token object in a chain of tokens. As this is the first token in the token-chain, :data:`_previousToken` is set to ``None``, the :data:`Start` is set - to :pycode:`SourceCodePosition(1, 1, 1)` and :data:`End` is set to :data:`Start`. + to :pycode:`SourceCodePosition(0, 0, 0)` and :data:`End` is set to :data:`Start`. """ self._previousToken = None self.NextToken = None - self.Start = SourceCodePosition(1, 1, 1) + self.Start = SourceCodePosition(0, 0, 0) self.End = self.Start def __len__(self) -> int: diff --git a/pyVHDLParser/__init__.py b/pyVHDLParser/__init__.py index c869033e0..a7bfad853 100644 --- a/pyVHDLParser/__init__.py +++ b/pyVHDLParser/__init__.py @@ -59,10 +59,10 @@ def __init__(self, row: int, column: int, absolute: int): self.Absolute = absolute def __repr__(self) -> str: - return "{0}:{1}".format(self.Row, self.Column) + return f"{self.Row}:{self.Column}" def __str__(self) -> str: - return "(line: {0: >3}, col: {1: >2})".format(self.Row, self.Column) + return f"(line: {self.Row: >3}, col: {self.Column: >2})" @export diff --git a/tests/IssueTester.py b/tests/IssueTester.py index 0c11ad4ef..80df65611 100644 --- a/tests/IssueTester.py +++ b/tests/IssueTester.py @@ -37,7 +37,7 @@ class SingleFileIssue(TokenizerChecks): def check_Tokenizer(self, file): - self.assertTrue(file.exists(), "Sourcefile '{0!s}' does not exist.".format(file)) + self.assertTrue(file.exists(), f"Sourcefile '{file!s}' does not exist.") with file.open('r') as fileHandle: self.code = fileHandle.read() diff --git a/tests/Linking.py b/tests/Linking.py index df4b41d3b..af3db1368 100644 --- a/tests/Linking.py +++ b/tests/Linking.py @@ -40,7 +40,7 @@ def check_TokenLinking(self) -> None: tokenIterator = iter(tokenStream) startToken = next(tokenIterator) - self.assertIsInstance(startToken, StartOfDocumentToken, msg="First token is not StartOfDocumentToken: {token}".format(token=startToken)) + self.assertIsInstance(startToken, StartOfDocumentToken, msg=f"First token is not StartOfDocumentToken: {startToken}") self.assertIsNone(startToken.PreviousToken, msg="First token has no open start.") lastToken: Token = startToken @@ -51,14 +51,14 @@ def check_TokenLinking(self) -> None: endToken = token break - self.assertEqual(lastToken.NextToken, token, msg="Last token is not connected to the current token: {token}".format(token=token)) - self.assertEqual(lastToken, token.PreviousToken, msg="Current token is not connected to lastToken: {token}".format(token=token)) + self.assertEqual(lastToken.NextToken, token, msg=f"Last token is not connected to the current token: {token}") + self.assertEqual(lastToken, token.PreviousToken, msg=f"Current token is not connected to lastToken: {token}") lastToken = token else: self.fail(msg="No EndOfDocumentToken found.") - self.assertIsInstance(endToken, EndOfDocumentToken, msg="End token is not EndOfDocumentToken: {token}".format(token=endToken)) - self.assertEqual(lastToken.NextToken, endToken, msg="Last token is not connected to the end token: {token}".format(token=token)) - self.assertEqual(lastToken, endToken.PreviousToken, msg="End token is not connected to lastToken: {token}".format(token=token)) - self.assertIsNone(endToken.NextToken, msg="End token has no open end: {token}".format(token=endToken.NextToken)) + self.assertIsInstance(endToken, EndOfDocumentToken, msg=f"End token is not EndOfDocumentToken: {endToken}") + self.assertEqual(lastToken.NextToken, endToken, msg=f"Last token is not connected to the end token: {token}") + self.assertEqual(lastToken, endToken.PreviousToken, msg=f"End token is not connected to lastToken: {token}") + self.assertIsNone(endToken.NextToken, msg=f"End token has no open end: {endToken.NextToken}") diff --git a/tests/unit/Common.py b/tests/unit/Common.py index 4369a86e4..e7276a0f5 100644 --- a/tests/unit/Common.py +++ b/tests/unit/Common.py @@ -81,7 +81,7 @@ class ExpectedDataMixin: @classmethod def setUpClass(cls): - print("Starting testcases in {}.".format(cls.__qualname__)) + print(f"Starting testcases in {cls.__qualname__}.") def setUp(self): print("Starting another test.") @@ -120,20 +120,20 @@ def test_TokenSequence(self) -> None: self.assertTrue( token == item[1], 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=item[1], type=item[0].__qualname__) + context=f"at {token.Start!s}", + actual=f"'{token!r}' of {token.__class__.__qualname__}", + expected=f"'{item[1]}' of {item[0].__qualname__}" ) ) except TokenizerException as ex: - self.fail(msg="Unexpected 'TokenizerException' ({ex!s}) at {pos}".format(ex=ex, pos=ex.Position)) + self.fail(msg=f"Unexpected 'TokenizerException' ({ex!s}) at {ex.Position}") except StopIteration: pass except AssertionError: raise except Exception as ex: - self.fail(msg="Unexpected exception '{exname}' := {ex!s}.".format(ex=ex, exname=ex.__class__.__qualname__)) + self.fail(msg=f"Unexpected exception '{ex.__class__.__qualname__}' := {ex!s}.") class TokenLinking(ITestcase): #, ExpectedDataMixin): diff --git a/tests/unit/Tokenizer/Tokens.py b/tests/unit/Tokenizer/Tokens.py index 328dfba07..d263762db 100644 --- a/tests/unit/Tokenizer/Tokens.py +++ b/tests/unit/Tokenizer/Tokens.py @@ -291,9 +291,9 @@ def test_KeywordToWordTokenMissmatch(self) -> None: 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__) + context=f"at {token.Start!s}", + actual=f"'{token!r}' of {token.__class__.__qualname__}", + expected=f"'keyword' of {WordToken.__qualname__}" ) ) From dfa28930895680b8ed2e76915180e8cdf9ea4fac Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 4 Apr 2023 00:09:30 +0200 Subject: [PATCH 08/15] Added Length methods. --- pyVHDLParser/Token/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pyVHDLParser/Token/__init__.py b/pyVHDLParser/Token/__init__.py index a86ad35f9..cd5a74eac 100644 --- a/pyVHDLParser/Token/__init__.py +++ b/pyVHDLParser/Token/__init__.py @@ -734,6 +734,15 @@ def __init__(self, previousToken: Token, value: str, start: SourceCodePosition, """ super().__init__(previousToken, value[1:-1], start=start, end=end) + @property + def Length(self) -> int: + """ + A read-only property to return the length of the token. + + :return: Length of the token. + """ + return len(self.Value) + def __repr__(self) -> str: value = "\"" + self.Value + "\" " return f"<{self.__class__.__name__: <50} {value:.<59} at {self.Start!r}>" @@ -751,6 +760,15 @@ def __init__(self, previousToken: Token, value: str, start: SourceCodePosition, """ super().__init__(previousToken, value[1:-1], start=start, end=end) + @property + def Length(self) -> int: + """ + A read-only property to return the length of the token. + + :return: Length of the token. + """ + return len(self.Value) + def __repr__(self) -> str: value = "\"" + self.Value + "\" " return f"<{self.__class__.__name__: <50} {value:.<59} at {self.Start!r}>" From 519f9af80b6e3a42a21e508287303fbf6f6e459d Mon Sep 17 00:00:00 2001 From: Sebastian Kaupper Date: Mon, 19 Jun 2023 11:22:58 +0200 Subject: [PATCH 09/15] When tokenizing PossibleCharacterLiteral, only strip the leading single quote, and nothing else --- pyVHDLParser/Token/Parser.py | 2 +- pyVHDLParser/Token/__init__.py | 14 +++++++---- tests/issue/18/Issue_18.py | 1 - tests/unit/Tokenizer/Tokens.py | 45 ++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/pyVHDLParser/Token/Parser.py b/pyVHDLParser/Token/Parser.py index 887ec98c3..903e83865 100644 --- a/pyVHDLParser/Token/Parser.py +++ b/pyVHDLParser/Token/Parser.py @@ -353,7 +353,7 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): start.Column += 1 start.Absolute += 1 - buffer = buffer[:2] + buffer = buffer[1:] if (buffer[0] in __ALPHA_CHARACTERS__) and (buffer[1] in __ALPHA_CHARACTERS__): tokenKind = cls.TokenKind.AlphaChars elif (buffer[0] in __WHITESPACE_CHARACTERS__) and (buffer[1] in __WHITESPACE_CHARACTERS__): diff --git a/pyVHDLParser/Token/__init__.py b/pyVHDLParser/Token/__init__.py index cd5a74eac..644ccdb91 100644 --- a/pyVHDLParser/Token/__init__.py +++ b/pyVHDLParser/Token/__init__.py @@ -27,7 +27,7 @@ # limitations under the License. # # ==================================================================================================================== # # -from typing import Iterator, Optional as Nullable +from typing import Iterator, Union, Optional as Nullable from pyTooling.Decorators import export from pyTooling.MetaClasses import ExtendedType @@ -391,29 +391,33 @@ def __iter__(self) -> Iterator[str]: """ return iter(self.Value) - def __eq__(self, other: str) -> bool: + def __eq__(self, other: Union[str, "ValuedToken"]) -> bool: """ Returns true, if the token's internal value is equal to the second operand. :param other: Parameter to compare against. :returns: ``True``, if token's value and second operand are equal. - :raises TypeError: If second operand is not of type :py:class:`str`. + :raises TypeError: If second operand is not of type :py:class:`str` or :py:class:`ValuedToken`. """ if isinstance(other, str): return self.Value == other + elif isinstance(other, ValuedToken): + return self.Value == other.Value else: raise TypeError(f"Second operand of type '{other.__class__.__name__}' is not supported by equal operator.") - def __ne__(self, other: str) -> bool: + def __ne__(self, other: Union[str, "ValuedToken"]) -> bool: """ Returns true, if the token's internal value is unequal to the second operand. :param other: Parameter to compare against. :returns: ``True``, if token's value and second operand are unequal. - :raises TypeError: If second operand is not of type :py:class:`str`. + :raises TypeError: If second operand is not of type :py:class:`str` or :py:class:`ValuedToken`. """ if isinstance(other, str): return self.Value != other + elif isinstance(other, ValuedToken): + return self.Value != other.Value else: raise TypeError(f"Second operand of type '{other.__class__.__name__}' is not supported by unequal operator.") diff --git a/tests/issue/18/Issue_18.py b/tests/issue/18/Issue_18.py index 99e58c0a8..295495200 100644 --- a/tests/issue/18/Issue_18.py +++ b/tests/issue/18/Issue_18.py @@ -39,7 +39,6 @@ exit(1) class Issue_18(TestCase, SingleFileIssue): - @mark.xfail def test_Tokenizer(self): file = Path(__file__).with_suffix(".vhdl") self.check_Tokenizer(file) diff --git a/tests/unit/Tokenizer/Tokens.py b/tests/unit/Tokenizer/Tokens.py index d263762db..9dc280d24 100644 --- a/tests/unit/Tokenizer/Tokens.py +++ b/tests/unit/Tokenizer/Tokens.py @@ -256,6 +256,51 @@ class Sequence_5(TestCase, ExpectedDataMixin, TokenSequence): ] ) +class Sequence_6(TestCase, ExpectedDataMixin, TokenSequence): + code = """if Clk'event and Clk = '1' then -- rising clock edge\nname'attr1'attr2\nsignal reg_catch1 : std_logic_vector(flags_src1'range);""" + tokenStream = ExpectedTokenStream( + [ (StartOfDocumentToken, None), + (WordToken, "if"), + (WhitespaceToken, " "), + (WordToken, "Clk"), + (CharacterToken, "'"), + (WordToken, "event"), + (WhitespaceToken, " "), + (WordToken, "and"), + (WhitespaceToken, " "), + (WordToken, "Clk"), + (WhitespaceToken, " "), + (CharacterToken, "="), + (WhitespaceToken, " "), + (CharacterLiteralToken, "1"), + (WhitespaceToken, " "), + (WordToken, "then"), + (WhitespaceToken, " "), + (SingleLineCommentToken, "-- rising clock edge\n"), + (WordToken, "name"), + (CharacterToken, "'"), + (WordToken, "attr1"), + (CharacterToken, "'"), + (WordToken, "attr2"), + (LinebreakToken, None), + (WordToken, "signal"), + (WhitespaceToken, " "), + (WordToken, "reg_catch1"), + (WhitespaceToken, " "), + (CharacterToken, ":"), + (WhitespaceToken, " "), + (WordToken, "std_logic_vector"), + (CharacterToken, "("), + (WordToken, "flags_src1"), + (CharacterToken, "'"), + (WordToken, "range"), + (CharacterToken, ")"), + (CharacterToken, ";"), + (EndOfDocumentToken, None) + ] + ) + + class Tokenizer_ExceptionInKeyword(TestCase, ExpectedDataMixin, TokenSequence): code = """keyword""" tokenStream = ExpectedTokenStream( From 41daf492c173b89d1ff7b206bf91c96db4c5cc36 Mon Sep 17 00:00:00 2001 From: Sebastian Kaupper Date: Fri, 30 Jun 2023 15:38:34 +0200 Subject: [PATCH 10/15] Avoid tokenizer exceptions for qualified expressions --- pyVHDLParser/Token/Parser.py | 8 ++++- tests/unit/Tokenizer/Tokens.py | 59 ++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/pyVHDLParser/Token/Parser.py b/pyVHDLParser/Token/Parser.py index 903e83865..ed0c10132 100644 --- a/pyVHDLParser/Token/Parser.py +++ b/pyVHDLParser/Token/Parser.py @@ -335,7 +335,13 @@ def GetVHDLTokenizer(cls, iterable: Iterator[str]): elif tokenKind is cls.TokenKind.PossibleCharacterLiteral: buffer += char if len(buffer) == 2: - if buffer[1] == "'": + if buffer[1] == "(" and isinstance(previousToken, WordToken): + previousToken = CharacterToken(previousToken, "'", start) + yield previousToken + previousToken = CharacterToken(previousToken, "(", SourceCodePosition(row, column, absolute)) + yield previousToken + tokenKind = cls.TokenKind.OtherChars + elif buffer[1] == "'": previousToken = CharacterToken(previousToken, "'", start) yield previousToken previousToken = CharacterToken(previousToken, "'", SourceCodePosition(row, column, absolute)) diff --git a/tests/unit/Tokenizer/Tokens.py b/tests/unit/Tokenizer/Tokens.py index 9dc280d24..19a85d1ef 100644 --- a/tests/unit/Tokenizer/Tokens.py +++ b/tests/unit/Tokenizer/Tokens.py @@ -256,6 +256,7 @@ class Sequence_5(TestCase, ExpectedDataMixin, TokenSequence): ] ) + class Sequence_6(TestCase, ExpectedDataMixin, TokenSequence): code = """if Clk'event and Clk = '1' then -- rising clock edge\nname'attr1'attr2\nsignal reg_catch1 : std_logic_vector(flags_src1'range);""" tokenStream = ExpectedTokenStream( @@ -301,6 +302,64 @@ class Sequence_6(TestCase, ExpectedDataMixin, TokenSequence): ) +class Sequence_7(TestCase, ExpectedDataMixin, TokenSequence): + code = """constant BIT_STRING : UNSIGNED(0 downto 0) := UNSIGNED'(x\"0\");\nconstant LPAREN_CHAR : character := '(';\nfoo'('0')\nbar'('(')""" + tokenStream = ExpectedTokenStream( + [ (StartOfDocumentToken, None), + (WordToken, "constant"), + (WhitespaceToken, " "), + (WordToken, "BIT_STRING"), + (WhitespaceToken, " "), + (CharacterToken, ":"), + (WhitespaceToken, " "), + (WordToken, "UNSIGNED"), + (CharacterToken, "("), + (IntegerLiteralToken, "0"), + (WhitespaceToken, " "), + (WordToken, "downto"), + (WhitespaceToken, " "), + (IntegerLiteralToken, "0"), + (CharacterToken, ")"), + (WhitespaceToken, " "), + (FusedCharacterToken, ":="), + (WhitespaceToken, " "), + (WordToken, "UNSIGNED"), + (CharacterToken, "'"), + (CharacterToken, "("), + (WordToken, "x"), + (StringLiteralToken, "0"), + (CharacterToken, ")"), + (CharacterToken, ";"), + (LinebreakToken, None), + (WordToken, "constant"), + (WhitespaceToken, " "), + (WordToken, "LPAREN_CHAR"), + (WhitespaceToken, " "), + (CharacterToken, ":"), + (WhitespaceToken, " "), + (WordToken, "character"), + (WhitespaceToken, " "), + (FusedCharacterToken, ":="), + (WhitespaceToken, " "), + (CharacterLiteralToken, "("), + (CharacterToken, ";"), + (LinebreakToken, None), + (WordToken, "foo"), + (CharacterToken, "'"), + (CharacterToken, "("), + (CharacterLiteralToken, "0"), + (CharacterToken, ")"), + (LinebreakToken, None), + (WordToken, "bar"), + (CharacterToken, "'"), + (CharacterToken, "("), + (CharacterLiteralToken, "("), + (CharacterToken, ")"), + (EndOfDocumentToken, None) + ] + ) + + class Tokenizer_ExceptionInKeyword(TestCase, ExpectedDataMixin, TokenSequence): code = """keyword""" tokenStream = ExpectedTokenStream( From 28ec4032b4978d3fbd12bf56cda352b3f14fd38f Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 17 Apr 2023 23:00:07 +0200 Subject: [PATCH 11/15] Bumped dependencies. --- requirements.txt | 2 +- tests/requirements.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3cbb9fb2d..c7e8eac9a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ py-flags>=1.1.4 pyTooling>=4.0.1, <5.0 pyAttributes>=2.5.1 -pyVHDLModel==0.24.0 +pyVHDLModel==0.25.1 diff --git a/tests/requirements.txt b/tests/requirements.txt index 976fde436..84d8c97a9 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,12 +1,12 @@ -r ../requirements.txt # Coverage collection -Coverage>=6.5 +Coverage>=7.2 # Test Runner -pytest>=7.1.3 +pytest>=7.3.0 pytest-cov>=4.0.0 # Static Type Checking -mypy>=0.981 +mypy>=1.2.0 lxml>=4.9 From 42ce6d0b093a9d14b27eb54d4e6228f2125255be Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Thu, 6 Jul 2023 00:13:53 +0200 Subject: [PATCH 12/15] Bumped dependencies. --- doc/Dependency.rst | 10 +++++----- doc/TokenStream/index.rst | 4 ++-- doc/requirements.txt | 4 ++-- pyVHDLParser/Blocks/__init__.py | 4 ++-- pyVHDLParser/Groups/__init__.py | 4 ++-- pyVHDLParser/Token/__init__.py | 6 +++--- pyVHDLParser/__init__.py | 14 +++++++------- pyproject.toml | 2 +- requirements.txt | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/doc/Dependency.rst b/doc/Dependency.rst index 039d82540..8ec4ed3c1 100644 --- a/doc/Dependency.rst +++ b/doc/Dependency.rst @@ -78,15 +78,15 @@ the mandatory dependencies too. +--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ | **Package** | **Version** | **License** | **Dependencies** | +====================================================================+=============+========================================================================================+======================+ -| `pytest `__ | ≥7.2.0 | `MIT `__ | *Not yet evaluated.* | +| `pytest `__ | ≥7.3.0 | `MIT `__ | *Not yet evaluated.* | +--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `pytest-cov `__ | ≥4.0.0 | `MIT `__ | *Not yet evaluated.* | +| `pytest-cov `__ | ≥4.1.0 | `MIT `__ | *Not yet evaluated.* | +--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ | `pytest-benchmark `__ | ≥4.0.0 | `BSD 2-Clause `__ | *Not yet evaluated.* | +--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ | `Coverage `__ | ≥7.2 | `Apache License, 2.0 `__ | *Not yet evaluated.* | +--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `mypy `__ | ≥1.1.1 | `MIT `__ | *Not yet evaluated.* | +| `mypy `__ | ≥1.2.0 | `MIT `__ | *Not yet evaluated.* | +--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ | `lxml `__ | ≥4.9 | `BSD 3-Clause `__ | *Not yet evaluated.* | +--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ @@ -116,11 +116,11 @@ the mandatory dependencies too. +-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ | **Package** | **Version** | **License** | **Dependencies** | +=================================================================================================+==============+==========================================================================================================+======================================================================================================================================================+ -| `pyTooling `__ | ≥2.11.0 | `Apache License, 2.0 `__ | *None* | +| `pyTooling `__ | ≥5.0.0 | `Apache License, 2.0 `__ | *None* | +-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ | `Sphinx `__ | ≥5.3.0 | `BSD 3-Clause `__ | *Not yet evaluated.* | +-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `sphinxcontrib-mermaid `__ | ≥0.8.1 | `BSD `__ | *Not yet evaluated.* | +| `sphinxcontrib-mermaid `__ | ≥0.9.2 | `BSD `__ | *Not yet evaluated.* | +-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ | `autoapi `__ | ≥2.0.1 | `Apache License, 2.0 `__ | *Not yet evaluated.* | +-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/doc/TokenStream/index.rst b/doc/TokenStream/index.rst index ea5c47293..578582f19 100644 --- a/doc/TokenStream/index.rst +++ b/doc/TokenStream/index.rst @@ -16,7 +16,7 @@ comments. .. code-block:: Python @export - class SourceCodePosition(metaclass=ExtendedType, useSlots=True): + class SourceCodePosition(metaclass=ExtendedType, slots=True): """Represent a position (row, column, absolute) in a source code file.""" Row: int #: Row in the source code file (starting at 1) @@ -29,7 +29,7 @@ comments. .. code-block:: Python @export - class Token(metaclass=ExtendedType, useSlots=True): + class Token(metaclass=ExtendedType, slots=True): """Base-class for all token classes.""" _previousToken: Token #: Reference to the previous token (backward pointer) diff --git a/doc/requirements.txt b/doc/requirements.txt index 9061f5c3a..48621de29 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -2,12 +2,12 @@ # Enforce latest version on ReadTheDocs sphinx>=5.3,<6.0 -pyTooling>=4.0.1, <5.0 +pyTooling >= 5.0.0, <6.0 # Sphinx Extenstions #sphinx.ext.coverage #sphinxcontrib-actdiag>=0.8.5 -sphinxcontrib-mermaid>=0.8.1 +sphinxcontrib-mermaid>=0.9.2 #sphinxcontrib-seqdiag>=0.8.5 #sphinxcontrib-textstyle>=0.2.1 #sphinxcontrib-spelling>=2.2.0 diff --git a/pyVHDLParser/Blocks/__init__.py b/pyVHDLParser/Blocks/__init__.py index e6d4e797a..f5193c460 100644 --- a/pyVHDLParser/Blocks/__init__.py +++ b/pyVHDLParser/Blocks/__init__.py @@ -58,7 +58,7 @@ def Token(self) -> Token: @export -class TokenToBlockParser(metaclass=ExtendedType, useSlots=True): +class TokenToBlockParser(metaclass=ExtendedType, slots=True): """Represents the current state of a token-to-block parser.""" _iterator: Iterator[Token] @@ -216,7 +216,7 @@ def __new__(cls, className, baseClasses, classMembers: dict): if isinstance(memberObject, FunctionType) and (memberName[:5] == "state"): states.append(memberObject) - block = super().__new__(cls, className, baseClasses, classMembers, useSlots=True) + block = super().__new__(cls, className, baseClasses, classMembers, slots=True) block.__STATES__ = states cls.BLOCKS.append(block) diff --git a/pyVHDLParser/Groups/__init__.py b/pyVHDLParser/Groups/__init__.py index ac16b684b..0be6154c3 100644 --- a/pyVHDLParser/Groups/__init__.py +++ b/pyVHDLParser/Groups/__init__.py @@ -80,7 +80,7 @@ def __next__(self) -> 'Block': @export -class BlockToGroupParser(metaclass=ExtendedType, useSlots=True): +class BlockToGroupParser(metaclass=ExtendedType, slots=True): """Represents the current state of a block-to-group parser.""" _iterator: Iterator @@ -226,7 +226,7 @@ def __new__(cls, className, baseClasses, classMembers: dict): if isinstance(memberObject, FunctionType) and (memberName[:5] == "state"): states.append(memberObject) - group = super().__new__(cls, className, baseClasses, classMembers, useSlots=True) + group = super().__new__(cls, className, baseClasses, classMembers, slots=True) group.__STATES__ = states return group diff --git a/pyVHDLParser/Token/__init__.py b/pyVHDLParser/Token/__init__.py index 644ccdb91..7109a6c72 100644 --- a/pyVHDLParser/Token/__init__.py +++ b/pyVHDLParser/Token/__init__.py @@ -72,7 +72,7 @@ def CharacterTranslation(value: str, oneLiner: bool = False) -> str: @export -class TokenIterator(metaclass=ExtendedType, useSlots=True): +class TokenIterator(metaclass=ExtendedType, slots=True): """A token iterator to iterate tokens in ascending/forward order.""" _startToken: 'Token' #: First token for the iteration. @@ -170,7 +170,7 @@ def Reset(self) -> None: @export -class TokenReverseIterator(metaclass=ExtendedType, useSlots=True): +class TokenReverseIterator(metaclass=ExtendedType, slots=True): """A token iterator to iterate tokens in descending/backward order.""" _startToken: 'Token' #: First token for the iteration. @@ -268,7 +268,7 @@ def Reset(self) -> None: @export -class Token(metaclass=ExtendedType, useSlots=True): +class Token(metaclass=ExtendedType, slots=True): """Base-class for all token classes.""" _previousToken: 'Token' #: Reference to the previous token (backward pointer) diff --git a/pyVHDLParser/__init__.py b/pyVHDLParser/__init__.py index a7bfad853..307ead1ac 100644 --- a/pyVHDLParser/__init__.py +++ b/pyVHDLParser/__init__.py @@ -44,7 +44,7 @@ @export -class SourceCodePosition(metaclass=ExtendedType, useSlots=True): +class SourceCodePosition(metaclass=ExtendedType, slots=True): """Represent a position (row, column, absolute) in a source code file.""" Row: int #: Row in the source code file @@ -66,30 +66,30 @@ def __str__(self) -> str: @export -class StartOf(metaclass=ExtendedType, useSlots=True): +class StartOf(metaclass=ExtendedType, slots=True, mixin=True): """Base-class (mixin) for all StartOf*** classes.""" @export -class StartOfDocument(StartOf): +class StartOfDocument(StartOf, mixin=True): """Base-class (mixin) for all StartOf***Document classes.""" @export -class StartOfSnippet(StartOf): +class StartOfSnippet(StartOf, mixin=True): """Base-class (mixin) for all StartOf***Snippet classes.""" @export -class EndOf(metaclass=ExtendedType, useSlots=True): +class EndOf(metaclass=ExtendedType, slots=True, mixin=True): """Base-class (mixin) for all EndOf*** classes.""" @export -class EndOfDocument(EndOf): +class EndOfDocument(EndOf, mixin=True): """Base-class (mixin) for all EndOf***Document classes.""" @export -class EndOfSnippet(EndOf): +class EndOfSnippet(EndOf, mixin=True): """Base-class (mixin) for all EndOf***Snippet classes.""" diff --git a/pyproject.toml b/pyproject.toml index 63574b7ac..673832389 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "pyTooling >= 4.0.1", + "pyTooling >= 5.0.0", "setuptools >= 62.3.3", "wheel >= 0.38.1" ] diff --git a/requirements.txt b/requirements.txt index c7e8eac9a..997e70bc0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ colorama>=0.4.6 py-flags>=1.1.4 -pyTooling>=4.0.1, <5.0 +pyTooling >= 5.0.0, <6.0 pyAttributes>=2.5.1 pyVHDLModel==0.25.1 From 9d9ede9c5438c139309c868f6cdca94a8125dce3 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Thu, 13 Jul 2023 06:38:32 +0200 Subject: [PATCH 13/15] Bumped dependencies. --- doc/Dependency.rst | 6 +++--- pyVHDLParser/Filters/Comment.py | 4 ++-- pyproject.toml | 4 ++-- tests/requirements.txt | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/Dependency.rst b/doc/Dependency.rst index 8ec4ed3c1..6d35325f6 100644 --- a/doc/Dependency.rst +++ b/doc/Dependency.rst @@ -159,7 +159,7 @@ install the mandatory dependencies too. +============================================================================+==============+==========================================================================================================+======================================================================================================================================================+ | `pyTooling `__ | ≥2.11.0 | `Apache License, 2.0 `__ | *None* | +----------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `wheel `__ | ≥0.38.1 | `MIT `__ | *Not yet evaluated.* | +| `wheel `__ | ≥0.40.0 | `MIT `__ | *Not yet evaluated.* | +----------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -188,7 +188,7 @@ install the mandatory dependencies too. +----------------------------------------------------------+--------------+-------------------------------------------------------------------------------------------+----------------------+ | **Package** | **Version** | **License** | **Dependencies** | +==========================================================+==============+===========================================================================================+======================+ -| `wheel `__ | ≥0.38.1 | `MIT `__ | *Not yet evaluated.* | +| `wheel `__ | ≥0.40.0 | `MIT `__ | *Not yet evaluated.* | +----------------------------------------------------------+--------------+-------------------------------------------------------------------------------------------+----------------------+ -| `Twine `__ | any | `Apache License, 2.0 `__ | *Not yet evaluated.* | +| `Twine `__ | ≥4.0.2 | `Apache License, 2.0 `__ | *Not yet evaluated.* | +----------------------------------------------------------+--------------+-------------------------------------------------------------------------------------------+----------------------+ diff --git a/pyVHDLParser/Filters/Comment.py b/pyVHDLParser/Filters/Comment.py index 0c617a588..811fcc8e7 100644 --- a/pyVHDLParser/Filters/Comment.py +++ b/pyVHDLParser/Filters/Comment.py @@ -45,7 +45,7 @@ def StripAndFuse(generator: Generator[Block, Any, None]) -> Generator[Block, Any if isinstance(block, (IndentationBlock, CommentBlock, LinebreakBlock)): continue else: - if block.MultiPart == True: + if block.MultiPart: while True: nextBlock = next(iterator) if isinstance(nextBlock, (WhitespaceBlock, CommentBlock)): @@ -55,7 +55,7 @@ def StripAndFuse(generator: Generator[Block, Any, None]) -> Generator[Block, Any nextBlock.StartToken.PreviousToken = block.EndToken block.EndToken = nextBlock.EndToken - if nextBlock.MultiPart == False: + if not nextBlock.MultiPart: break block.PreviousBlock = lastBlock diff --git a/pyproject.toml b/pyproject.toml index 673832389..3a8c82c2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [build-system] requires = [ "pyTooling >= 5.0.0", - "setuptools >= 62.3.3", - "wheel >= 0.38.1" + "setuptools >= 68.0.0", + "wheel >= 0.40.0" ] build-backend = "setuptools.build_meta" diff --git a/tests/requirements.txt b/tests/requirements.txt index 84d8c97a9..14b5e6abe 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -5,7 +5,8 @@ Coverage>=7.2 # Test Runner pytest>=7.3.0 -pytest-cov>=4.0.0 +typing_extensions>=4.6.3 +pytest-cov>=4.1.0 # Static Type Checking mypy>=1.2.0 From e4d8ad0fa8ca4bad516cf82772c2715d27d043e1 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 13 Aug 2023 23:11:56 +0200 Subject: [PATCH 14/15] Fixed InterSphinx configuration. --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index b33291076..0a6f13bd2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -229,7 +229,7 @@ extlinks = { "ghissue": ('https://GitHub.com/Paebbels/pyVHDLParser/issues/%s', 'issue #'), "ghpull": ('https://GitHub.com/Paebbels/pyVHDLParser/pull/%s', 'pull request #'), - "ghsrc": ('https://GitHub.com/Paebbels/pyVHDLParser/blob/main/%s?ts=2', ""), + "ghsrc": ('https://GitHub.com/Paebbels/pyVHDLParser/blob/main/%s?ts=2', None), } From d7620849932207805b2a61e55ddf8713891e11dd Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 13 Aug 2023 23:13:27 +0200 Subject: [PATCH 15/15] Bumped dependencies. --- doc/Dependency.rst | 34 ++++++++++++++++++---------------- doc/requirements.txt | 2 +- tests/requirements.txt | 10 +++++----- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/doc/Dependency.rst b/doc/Dependency.rst index 6d35325f6..1c2392cd6 100644 --- a/doc/Dependency.rst +++ b/doc/Dependency.rst @@ -75,21 +75,23 @@ the mandatory dependencies too. .. rubric:: Dependency List -+--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| **Package** | **Version** | **License** | **Dependencies** | -+====================================================================+=============+========================================================================================+======================+ -| `pytest `__ | ≥7.3.0 | `MIT `__ | *Not yet evaluated.* | -+--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `pytest-cov `__ | ≥4.1.0 | `MIT `__ | *Not yet evaluated.* | -+--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `pytest-benchmark `__ | ≥4.0.0 | `BSD 2-Clause `__ | *Not yet evaluated.* | -+--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `Coverage `__ | ≥7.2 | `Apache License, 2.0 `__ | *Not yet evaluated.* | -+--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `mypy `__ | ≥1.2.0 | `MIT `__ | *Not yet evaluated.* | -+--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `lxml `__ | ≥4.9 | `BSD 3-Clause `__ | *Not yet evaluated.* | -+--------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| **Package** | **Version** | **License** | **Dependencies** | ++=====================================================================+=============+========================================================================================+======================+ +| `pytest `__ | ≥7.4.0 | `MIT `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `pytest-cov `__ | ≥4.1.0 | `MIT `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `pytest-benchmark `__ | ≥4.0.0 | `BSD 2-Clause `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `Coverage `__ | ≥7.3 | `Apache License, 2.0 `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `mypy `__ | ≥1.5.0 | `MIT `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `typing-extensions `__ | ≥4.7.1 | `PSF-2.0 `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ +| `lxml `__ | ≥4.9 | `BSD 3-Clause `__ | *Not yet evaluated.* | ++---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ .. _dependency-documentation: @@ -128,7 +130,7 @@ the mandatory dependencies too. +-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ | !! `sphinx_fontawesome `__ | ≥0.0.6 | `GPL 2.0 `__ | *Not yet evaluated.* | +-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `sphinx_autodoc_typehints `__ | ≥1.19.5 | `MIT `__ | *Not yet evaluated.* | +| `sphinx_autodoc_typehints `__ | ≥1.24.0 | `MIT `__ | *Not yet evaluated.* | +-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ | `ruamel.yaml `__ | ≥0.17 | `MIT `__ | *Not yet evaluated.* | +-------------------------------------------------------------------------------------------------+--------------+----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/doc/requirements.txt b/doc/requirements.txt index 48621de29..4010ee413 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -13,7 +13,7 @@ sphinxcontrib-mermaid>=0.9.2 #sphinxcontrib-spelling>=2.2.0 autoapi sphinx_fontawesome>=0.0.6 -sphinx_autodoc_typehints>=1.12.0 +sphinx_autodoc_typehints >= 1.24.0 # changelog>=0.3.5 # BuildTheDocs Extensions (mostly patched Sphinx extensions) diff --git a/tests/requirements.txt b/tests/requirements.txt index 14b5e6abe..e75ed5eca 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,13 +1,13 @@ -r ../requirements.txt # Coverage collection -Coverage>=7.2 +Coverage >= 7.3 # Test Runner -pytest>=7.3.0 -typing_extensions>=4.6.3 -pytest-cov>=4.1.0 +pytest >= 7.4.0 +pytest-cov >= 4.1.0 # Static Type Checking -mypy>=1.2.0 +mypy >= 1.5.0 +typing_extensions >= 4.7.1 lxml>=4.9