Improve exception messages when a token is not found #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In most cases, a full selector is parsed as a token, and if not, we
report the character we are at as invalid. While better context is
provided in exceptions for tokens that are fully parsed and validated,
when we don't parse a token, very little is conveyed back to the user.
There are only a few types of selectors allowed in CSS: tags, attr,
class, id, pseudo-class, pseudo-elements, and combinators. You can have
variations of these, but that is it. We cover most of these cases
already with decent context, but there are still a few case that are
just reported as invalid characters. Moving forward, we will see if the
invalid character represents the start of one of the basic, supported
types. Only attr, class, id, and pseudo-(class|element) really fall into
the category that would generate one of these ambiguous exceptions, so
identify their starting character and raise an appropriate "malformed"
selector exception.
Also remove unnecessary "+" in PAT_PSEUDO_CLASS.