-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure categegory and entity names are tokenized correctly, closes #186…
… (#192)
- Loading branch information
Showing
6 changed files
with
64 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
static var regex:RegEx | ||
|
||
## Converts any string into a GDScript-valid token (cannot contain special characters) | ||
static func tokenize(value:String) -> String: | ||
if regex == null: | ||
regex = RegEx.new() | ||
regex.compile("(^[^A-Z_])|([^A-Z0-9_])") | ||
var token = value.to_upper() | ||
|
||
var regex_matches = regex.search_all(token) | ||
var offset = 0 | ||
for regex_match in regex_matches: | ||
var start = regex_match.get_start() | ||
var end = regex_match.get_end() | ||
var length = end - start | ||
var text = token.substr(start + offset, length) | ||
var replacement = "_" | ||
token = token.substr(0, start + offset) + replacement + token.substr(end + offset) | ||
offset += replacement.length() - text.length() | ||
|
||
return token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Do not modify! Auto-generated file. | ||
class_name MockEntities | ||
|
||
|
||
const MOCKENTITY = "55" | ||
const __SOME_ENTITY = "7" | ||
const _1209I____9390292084 = "8" |