Skip to content

Commit

Permalink
feat: support for parsing chinese characters
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Jun 14, 2022
1 parent 62bf1ca commit 4549145
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ func getDefaultConfig() {
if err != nil {
log.Println("Creating default config...")
b := []byte(defaultConfig())
ioutil.WriteFile("renpy-graphviz.config", b, 0644)
ioutil.WriteFile("renpy-graphviz.config", b, 0o644)
}
}

func defaultConfig() string {

return `### RENPY-GRAPHVIZ TOOL CONFIGURATION ###
# Select what you want to show and what you want to hide
# Hiding everything isn't always very useful
Expand Down
8 changes: 4 additions & 4 deletions parser/regexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ type customRegexes struct {
// should be called rarely
func initializeDetectors() customRegexes {
return customRegexes{
screen: regexp.MustCompile(`^\s*(?:init\s+[-\w]*\s+)?screen\s+([a-zA-Z0-9._-]+).*\s*:\s*(?:#.*)?$`),
screen: regexp.MustCompile(`^\s*(?:init\s+[-\w]*\s+)?screen\s+([\p{Han}a-zA-Z0-9._-]+).*\s*:\s*(?:#.*)?$`),
useScreenInScreen: regexp.MustCompile(`^\s*use\s+(\w*).*(?:#.*)?$`),
screenToScreen: regexp.MustCompile(`^\s*action\s+.*Show\("(.*?)".*\).*(?:#.*)?$`),
screenToLabel: regexp.MustCompile(`^\s*action\s+.*(?:Jump|Call)\("(.*?)".*\).*(?:#.*)?$`),
labelToScreen: regexp.MustCompile(`^\s*call\s+screen (\w*).*(?:#.*)?$`),
label: regexp.MustCompile(`^\s*label\s+([a-zA-Z0-9._-]+)(?:\([a-zA-Z0-9,_= \-"']*\))?\s*:\s*(?:#.*)?$`),
jump: regexp.MustCompile(`^\s*jump\s+([a-zA-Z0-9_.]+)\s*(?:#.*)?$`),
call: regexp.MustCompile(`^\s*call\s+(([a-zA-Z0-9_-]+)(?:\([a-zA-Z0-9,_= \-"']*\))?)\s*(?:#.*)?$`),
label: regexp.MustCompile(`^\s*label\s+([\p{Han}a-zA-Z0-9._-]+)(?:\([\p{Han}a-zA-Z0-9,_= \-"']*\))?\s*:\s*(?:#.*)?$`),
jump: regexp.MustCompile(`^\s*jump\s+([\p{Han}a-zA-Z0-9_.]+)\s*(?:#.*)?$`),
call: regexp.MustCompile(`^\s*call\s+(([\p{Han}a-zA-Z0-9_-]+)(?:\([\p{Han}a-zA-Z0-9,_= \-"']*\))?)\s*(?:#.*)?$`),
comment: regexp.MustCompile(`^\s*(#.*)?$`),
returns: regexp.MustCompile(`^\s{0,4}return\s*(?:#.*)?$`),
menu: regexp.MustCompile(`^\s*menu.*:\s*(?:#.*)?$`),
Expand Down

0 comments on commit 4549145

Please sign in to comment.