Category talk:Wren-check: Difference between revisions
Content deleted Content added
m PureFox moved page Talk:Wren-check to Category talk:Wren-check: Should have been a Category |
→Source code: Added a method to check if a string is a valid identifier. |
||
Line 160: | Line 160: | ||
if (!optionStr.contains(value)) abort_(name, value, "a character within '%(optionStr)'") |
if (!optionStr.contains(value)) abort_(name, value, "a character within '%(optionStr)'") |
||
} |
} |
||
/* Method to check if a value is a valid Wren identifier. */ |
|||
static ident(name, value) { |
|||
str(name, value, 1) |
|||
var allChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_" |
|||
var digits = "0123456789" |
|||
return value.all { |c| allChars.indexOf(c) >= 0 } && digits.indexOf(value[0]) == -1 |
|||
} |
|||
/* Methods to check if the value is a list or a typed list. */ |
/* Methods to check if the value is a list or a typed list. */ |