24
LINES
< > BotCompany Repo | #1001642
// findTranslators - changes argument (removes translator invocations)
JavaX fragment (include)
1 | static List<String[]> findTranslators(List<String> lines) {
|
2 | List<String[]> translators = new ArrayList<String[]>();
|
3 | Pattern pattern = Pattern.compile("^!([0-9# \t]+)");
|
4 | Pattern pArgs = Pattern.compile("^\\s*\\((.*)\\)");
|
5 | for (ListIterator<String> iterator = lines.listIterator(); iterator.hasNext(); ) {
|
6 | String line = iterator.next();
|
7 | line = line.trim();
|
8 | Matcher matcher = pattern.matcher(line);
|
9 | if (matcher.find()) {
|
10 | String[] t = matcher.group(1).split("[ \t]+");
|
11 | String rest = line.substring(matcher.end());
|
12 | String arg = null;
|
13 | if (t.length == 1) {
|
14 | Matcher mArgs = pArgs.matcher(rest);
|
15 | if (mArgs.find())
|
16 | arg = mArgs.group(1);
|
17 | }
|
18 | for (String transi : t)
|
19 | translators.add(new String[]{transi, arg});
|
20 | iterator.remove();
|
21 | }
|
22 | }
|
23 | return translators;
|
24 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
| ID |
Author/Program |
Comment |
Date |
| 1157 | stefan | Also removes the translator invocation lines from the source. | 2015-10-30 21:36:59 |
add comment
| Snippet ID: |
#1001642 |
| Snippet name: |
findTranslators - changes argument (removes translator invocations) |
| Eternal ID of this version: |
#1001642/2 |
| Text MD5: |
6a2209bd7e99a663618b7313b3f619f4 |
| Author: |
stefan |
| Category: |
|
| Type: |
JavaX fragment (include) |
| Public (visible to everyone): |
Yes |
| Archived (hidden from active list): |
No |
| Created/modified: |
2017-03-10 16:30:33 |
| Source code size: |
920 bytes / 24 lines |
| Pitched / IR pitched: |
No / No |
| Views / Downloads: |
1509 / 2761 |
| Version history: |
1 change(s) |
| Referenced in: |
[show references] |