-
Notifications
You must be signed in to change notification settings - Fork 15
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
Avoid tokenizer exceptions for qualified expressions #56
Avoid tokenizer exceptions for qualified expressions #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a test for these sequences:
foo'('0')
foo'('(')
pyVHDLParser/Token/Parser.py
Outdated
elif (buffer[0] in __WHITESPACE_CHARACTERS__) and (buffer[1] in __WHITESPACE_CHARACTERS__): | ||
tokenKind = cls.TokenKind.SpaceChars | ||
|
||
if buffer[0] == "(": # Relevant for qualified expressions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if buffer[0] == "(": # Relevant for qualified expressions | |
if buffer[0] == "(": # Relevant for qualified expressions |
Python (styling) requires at least 2 spaces before #
. I'm following Python coding styles loosely, but this is a good rule :).
@skaupper are you planning more fixes like this or should I prepare for a release of that code to |
Well, without trying it I am pretty sure these cases will fail with the current solution. Can you think of an example of the form I will have another look at it! |
Currently I focus on fixing things which occur while parsing some generated VHDL sources. As of now it seems qualified expressions are the last issue with the tokenizer for my use cases. I may have a look into some issues with the block parser afterwards (e.g. #9 and #16). Personally, I do not need a release though. |
F**** Type, qualified expression on character
|
After digging through the LRM and using ModelSim to confirm some ideas, it seems like On the other hand these snippets ARE valid VHDL: A similiar issue arises with the string literal |
For this PR, I will focus on solving the Any shenanigans involving |
5e9754f
to
fd7422b
Compare
Please remove the draft state when ready for review / merge. |
fd7422b
to
41daf49
Compare
Currently qualified expressions trigger a tokenizer exception.
This PR should take care of these, by recognizing that the character pattern
'(
may not be followed by another single quote (which would produce the character literal'('
). In those cases both characters are output as instances ofCharacterToken
.An additional test case ensure a correct parsing of qualified expressions (e.g.
UNSIGNED'(x"0")
) and the relevant character literal(
.