Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.9.0 #55

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/BlockStream/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _blkstm:

2. Pass - Blocks
################
2. Pass - Tokens ⇒ Blocks
#########################

In the :ref:`second pass <concept-passes>` a stream of double-linked
:class:`~pyVHDLParser.Token.Token` objects is read and grouped in another Python
Expand Down
4 changes: 2 additions & 2 deletions doc/Concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
44 changes: 23 additions & 21 deletions doc/Dependency.rst

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions doc/DocumentObjectModel/index.rst
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 2 additions & 2 deletions doc/GroupStream/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _grpstm:

3. Pass - Groups
################
3. Pass - Blocks ⇒ Groups
#########################

In the :ref:`third pass <concept-passes>` a stream of double-linked
:class:`~pyVHDLParser.Block.Block` objects is read and grouped in another Python
Expand Down
50 changes: 29 additions & 21 deletions doc/TokenStream/index.rst
Original file line number Diff line number Diff line change
@@ -1,46 +1,54 @@
.. _tokstm:

1. Pass - Tokens
################
1. Pass - String ⇒ Tokens
#########################

In the :ref:`first pass <concept-passes>` 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 <concept-passes>` 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, slots=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, slots=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:



Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}


Expand Down
6 changes: 3 additions & 3 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

# 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
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)
Expand Down
4 changes: 2 additions & 2 deletions pyVHDLParser/ANTLR4/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *

Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions pyVHDLParser/Blocks/Assignment/SignalAssignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#
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.Common import LinebreakBlock, WhitespaceBlock
from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock
from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions pyVHDLParser/Blocks/Assignment/VariableAssignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#
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.Common import LinebreakBlock, WhitespaceBlock
from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock
from pyVHDLParser.Blocks.Comment import SingleLineCommentBlock, MultiLineCommentBlock


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions pyVHDLParser/Blocks/Attribute/AttributeDeclaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#
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
from pyVHDLParser.Blocks.Common import LinebreakBlock, WhitespaceBlock
from pyVHDLParser.Blocks.Whitespace import LinebreakBlock, WhitespaceBlock


@export
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Loading
Loading