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

30
LINES

< > BotCompany Repo | #1002779 // Find tests and theories

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

Libraryless. Click here for Pure Java version (3599L/24K/78K).

!759

p {
  S text = loadSnippet("#1002764");
  snlCheckBrackets(text);
  print("Bracket check OK");
  Lisp tree = snlToTree(text);
  print("head: " + tree.head);
}

static void snlCheckBrackets(S snl) {
  L<S> tok = snlTok(snl);
  new L<S> stack;
  for (int i = 1; i < l(tok); i += 2) {
    S t = tok.get(i);
    if (eq(t, "[") || eq(t, "("))
      stack.add(t);
    else if (eq(t, "]")) {
      S op = popLast(stack);
      if (!eq(op, "["))
        fail("bracket failure at token " + i + "/" + l(tok) + ": " + op + " vs " + join(subList(tok, i, i+9)));
    } else if (eq(t, ")")) {
      S op = popLast(stack);
      if (!eq(op, "("))
        fail("bracket failure at token " + i + "/" + l(tok) + ": " + op + " vs " + join(subList(tok, i, i+9)));
    }
  }
  if (!stack.isEmpty())
    print("open brackets remain: " + structure(stack));
}

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: #1002779
Snippet name: Find tests and theories
Eternal ID of this version: #1002779/1
Text MD5: ade5bbf52538b254b55f89a946697c85
Transpilation MD5: 3406af4a7594db7a82e5aaf57ea9d707
Author: stefan
Category: eleu / snl
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-02-23 02:21:12
Source code size: 870 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 668 / 670
Referenced in: #3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)