-
Notifications
You must be signed in to change notification settings - Fork 589
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
parser/lexer: correct ID_Start & ID_Continue checks #524
parser/lexer: correct ID_Start & ID_Continue checks #524
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.
Looks reasonable but lets get some tests which exercise this.
fc0cdaf
to
a14eb3c
Compare
I added a few tests for the areas where the allowed character sets differ. Please let me know if you want me to add further tests. |
a14eb3c
to
c1a6c0a
Compare
@stevenh Linter warnings should be fixed now |
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.
Thanks for this, just a minor nit and then good to go.
parser/lexer.go
Outdated
unicode.Pattern_White_Space, | ||
} | ||
|
||
func UnicodeIDStart(r rune) bool { |
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.
Just a minor tweak can we unexport these:
func UnicodeIDStart(r rune) bool { | |
func unicodeIDStart(r rune) bool { |
parser/lexer.go
Outdated
return unicode.In(r, includeIDStart...) | ||
} | ||
|
||
func UnicodeIDContinue(r rune) bool { |
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.
func UnicodeIDContinue(r rune) bool { | |
func unicodeIDContinue(r rune) bool { |
parser/lexer.go
Outdated
func isDigit(chr rune, base int) bool { | ||
return digitValue(chr) < base | ||
} | ||
|
||
func isIdentifierStart(chr rune) bool { | ||
return chr == '$' || chr == '_' || chr == '\\' || | ||
'a' <= chr && chr <= 'z' || 'A' <= chr && chr <= 'Z' || | ||
chr >= utf8.RuneSelf && unicode.IsLetter(chr) | ||
chr >= utf8.RuneSelf && UnicodeIDStart(chr) |
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.
chr >= utf8.RuneSelf && UnicodeIDStart(chr) | |
chr >= utf8.RuneSelf && unicodeIDStart(chr) |
parser/lexer.go
Outdated
} | ||
|
||
func isIdentifierPart(chr rune) bool { | ||
return chr == '$' || chr == '_' || chr == '\\' || | ||
'a' <= chr && chr <= 'z' || 'A' <= chr && chr <= 'Z' || | ||
'0' <= chr && chr <= '9' || | ||
chr >= utf8.RuneSelf && (unicode.IsLetter(chr) || unicode.IsDigit(chr)) | ||
chr >= utf8.RuneSelf && UnicodeIDContinue(chr) |
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.
chr >= utf8.RuneSelf && UnicodeIDContinue(chr) | |
chr >= utf8.RuneSelf && unicodeIDContinue(chr) |
c1a6c0a
to
8237717
Compare
Sure thing, I pushed with the methods unexported |
unicode.IsLetter
andunicode.IsDigit
will not return the complete set ofID_Start
andID_Continue
characters defined here: https://www.unicode.org/reports/tr31/.