1 package internal 2 3 import "unicode" 4 5 var ( 6 idContinue = []*unicode.RangeTable{ 7 unicode.L, 8 unicode.Nl, 9 unicode.Other_ID_Start, 10 unicode.Mn, 11 unicode.Mc, 12 unicode.Nd, 13 unicode.Pc, 14 unicode.Other_ID_Continue, 15 } 16 idStart = idContinue[:3] 17 notID = []*unicode.RangeTable{ 18 unicode.Pattern_Syntax, 19 unicode.Pattern_White_Space, 20 } 21 ) 22 23 const ( 24 zwnj rune = 8204 25 zwj rune = 8205 26 ) 27 28 func IsIDStart(c rune) bool { 29 if c == '$' || c == '_' || c == '\\' { 30 return true 31 } 32 return unicode.In(c, idStart...) && !unicode.In(c, notID...) 33 } 34 35 func IsIDContinue(c rune) bool { 36 if c == '$' || c == '_' || c == '\\' || c == zwnj || c == zwj { 37 return true 38 } 39 return unicode.In(c, idContinue...) && !unicode.In(c, notID...) 40 } 41