Commit | Line | Data |
---|---|---|
3719602c PC |
1 | import re |
2 | ||
3 | # 0: full struct; 1: up to & including first []; 2: content between first {} | |
4 | p_struct = re.compile(r'(struct\s*[a-zA-Z0-9_\s]+\[])\s*' | |
5 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+)\s*)*' | |
6 | r'=\s*' # = | |
7 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+)\s*)*' | |
8 | r'{((?:.|[\r\n])*?)\{\s*NULL,\s*NULL,\s*NULL\s*(?:.|[\r\n])*?},?(?:.|[\r\n])*?};') # captures full struct, it's beginning and it's content | |
9 | # 0: type name[]; 1: type; 2: name | |
10 | p_type_name = re.compile(r'(retro_core_option_[a-zA-Z0-9_]+)\s*' | |
11 | r'(option_cats([a-z_]{0,8})|option_defs([a-z_]{0,8}))\s*\[]') | |
12 | # 0: full option; 1: key; 2: description; 3: additional info; 4: key/value pairs | |
13 | p_option = re.compile(r'{\s*' # opening braces | |
14 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
15 | r'(\".*?\"|' # key start; group 1 | |
16 | r'[a-zA-Z0-9_]+\s*\((?:.|[\r\n])*?\)|' | |
17 | r'[a-zA-Z0-9_]+\s*\[(?:.|[\r\n])*?]|' | |
18 | r'[a-zA-Z0-9_]+\s*\".*?\")\s*' # key end | |
19 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
20 | r',\s*' # comma | |
21 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
22 | r'(\".*?\")\s*' # description; group 2 | |
23 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
24 | r',\s*' # comma | |
25 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
26 | r'((?:' # group 3 | |
27 | r'(?:NULL|\"(?:.|[\r\n])*?\")\s*' # description in category, info, info in category, category | |
28 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
29 | r',?\s*' # comma | |
30 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
31 | r')+)' | |
32 | r'(?:' # defs only start | |
33 | r'{\s*' # opening braces | |
34 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
35 | r'((?:' # key/value pairs start; group 4 | |
36 | r'{\s*' # opening braces | |
37 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
38 | r'(?:NULL|\".*?\")\s*' # option key | |
39 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
40 | r',\s*' # comma | |
41 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
42 | r'(?:NULL|\".*?\")\s*' # option value | |
43 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
44 | r'}\s*' # closing braces | |
45 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
46 | r',?\s*' # comma | |
47 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
48 | r')*)' # key/value pairs end | |
49 | r'}\s*' # closing braces | |
50 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
51 | r',?\s*' # comma | |
52 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
53 | r'(?:' # defaults start | |
54 | r'(?:NULL|\".*?\")\s*' # default value | |
55 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
56 | r',?\s*' # comma | |
57 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
58 | r')*' # defaults end | |
59 | r')?' # defs only end | |
60 | r'},') # closing braces | |
61 | # analyse option group 3 | |
62 | p_info = re.compile(r'(NULL|\"(?:.|[\r\n])*?\")\s*' # description in category, info, info in category, category | |
63 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
64 | r',') | |
65 | p_info_cat = re.compile(r'(NULL|\"(?:.|[\r\n])*?\")') | |
66 | # analyse option group 4 | |
67 | p_key_value = re.compile(r'{\s*' # opening braces | |
68 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
69 | r'(NULL|\".*?\")\s*' # option key; 1 | |
70 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
71 | r',\s*' # comma | |
72 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
73 | r'(NULL|\".*?\")\s*' # option value; 2 | |
74 | r'(?:(?:\/\*(?:.|[\r\n])*?\*\/|\/\/.*[\r\n]+|#.*[\r\n]+)\s*)*' | |
75 | r'}') | |
76 | ||
77 | p_masked = re.compile(r'([A-Z_][A-Z0-9_]+)\s*(\"(?:"\s*"|\\\s*|.)*\")') | |
78 | ||
79 | p_intl = re.compile(r'(struct retro_core_option_definition \*option_defs_intl\[RETRO_LANGUAGE_LAST]) = {' | |
80 | r'((?:.|[\r\n])*?)};') | |
81 | p_set = re.compile(r'static INLINE void libretro_set_core_options\(retro_environment_t environ_cb\)' | |
82 | r'(?:.|[\r\n])*?};?\s*#ifdef __cplusplus\s*}\s*#endif') | |
83 | ||
84 | p_yaml = re.compile(r'"project_id": "[0-9]+".*\s*' | |
85 | r'"api_token": "([a-zA-Z0-9]+)".*\s*' | |
86 | r'"base_path": "\./intl".*\s*' | |
87 | r'"base_url": "https://api\.crowdin\.com".*\s*' | |
88 | r'"preserve_hierarchy": true.*\s*' | |
89 | r'"files": \[\s*' | |
90 | r'\{\s*' | |
91 | r'"source": "/_us/\*\.json",.*\s*' | |
92 | r'"translation": "/_%two_letters_code%/%original_file_name%",.*\s*' | |
93 | r'"skip_untranslated_strings": true.*\s*' | |
94 | r'},\s*' | |
95 | r']') |