-
Notifications
You must be signed in to change notification settings - Fork 225
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
Fix parsing token components with parenthesis without spaces #254
Conversation
Just being pedantic here, but we want to make sure we cover all cases: Does this handle a (badly written) expression like:
|
Good point. If you're asking the question @djbe that means we need a test to cover it 😉 |
it won't handle |
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.
We may want to keep an eye on performance with those multiple repeated hasPrefix
/hasSuffix
tests (don't want to end up having to do another #226).
Don't forget the changelog entry! 😄
Sources/Tokenizer.swift
Outdated
} else if word != "(" && word.hasPrefix("(") { | ||
components.append("(") | ||
} else if word != "(" && word.hasPrefix("(") || word != ")" && word.hasPrefix(")") { | ||
components.append(String(word.first!)) |
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.
Please avoid force unwraps, especially in Sources
.
You could:
- use
word[0]
- unroll the if test into a separate one
- use
prefix(1)
- ...
3f725c7
to
e70023d
Compare
Resolves #253