Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1003070 // parsePoem

JavaX fragment (include)

1  
static L<E> parsePoem(S input) {
2  
  if (isSnippetID(input))
3  
    ret loadPoemAndParse(input);
4  
  ret parsePoem(toLinesFullTrim(input));
5  
}
6  
7  
static L<E> parsePoem(L<S> lines) {
8  
  char mode = ' ';
9  
  new L<E> entries;
10  
  for (S line : lines) {
11  
    new E e;
12  
    if (line.startsWith("!")) {
13  
      e.test = true;
14  
      line = line.substring(1).trim();
15  
    }
16  
    if (swicAny(line, litlist("Q:", "U:", "Usr:"))) {
17  
      mode = 'q';
18  
      line = line.substring(line.indexOf(':')+1).trim();
19  
    } else if (swicAny(line, litlist("A:", "B:", "Bot:"))) {
20  
      mode = 'a';
21  
      line = line.substring(line.indexOf(':')+1).trim();
22  
    } else if (startsWith(line, "["))
23  
      mode = 's';
24  
    if (mode == 'q')
25  
      e.q = line;
26  
    else if (mode == 'a')
27  
      e.a = line;
28  
    else {
29  
      e.comment = getJavaLineComment(line);
30  
      S s = javaDropComments(line).trim();
31  
      e.state = dropPrefix("[", dropSuffix("]", s)).trim();
32  
    }
33  
    entries.add(e);
34  
  }
35  
  ret entries;
36  
}

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

No comments. add comment

Snippet ID: #1003070
Snippet name: parsePoem
Eternal ID of this version: #1003070/1
Text MD5: 1ca3fc4521ce73994ad98c64ad877d73
Author: stefan
Category: eleu / nl
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-19 17:49:49
Source code size: 990 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 723 / 982
Referenced in: [show references]