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

45
LINES

< > BotCompany Repo | #1001533 // Structure Holder (developing)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1046L/8K/23K).

!747
!pcall {

m {
  static S inputID = "#1001532"; // Eins etc.
  
  static new L<S> fields;
  static new L<Map<S, S>> rows;
  
  p {
    for (S line : toLinesFullTrim(loadSnippet(inputID))) try {
      new Matches m;
      
      if (match3("a structure with * fields: ...", line, m)) {
        fields.clear();
        for (int i = 1; i < l(m.m); i++) {
          S s = m.unq(i);
          if (!eq(s, ","))
            fields.add(s);
        }
        print(l(fields) + " field(s)");
      } else {
        L<S> tok = javaTok(line);
        new Map<S, S> row;
        for (int i = 1; i < l(tok); i += 2) {
          S field = unquote(tok.get(i));
          if (!eq(tok.get(i+2), "=")) fail("huh?");
          i += 4;
          S val = unquote(tok.get(i));
          row.put(field, val);
          if (i+2 < l(tok)) {
            i += 2;
            if (!eq(tok.get(i), ",")) fail("huh 2?");
          }
        }
        rows.add(row);
      }
    } catch (Exception e) {
      e.printStackTrace();
      print("Was parsing: " + quote(line));
    }
    
    print(l(fields) + " field(s), " + l(rows) + " row(s).");
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001533
Snippet name: Structure Holder (developing)
Eternal ID of this version: #1001533/1
Text MD5: d6953957e6aeef9693ce7b3b8e729caf
Transpilation MD5: e7b7f0fccf00a691a7245a1dbbbcc7c0
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-25 00:59:10
Source code size: 1166 bytes / 45 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 648 / 659
Referenced in: [show references]