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

21
LINES

< > BotCompany Repo | #1003922 // testBracketHygiene - uses Java brackets (except <>) and javaTok

JavaX fragment (include)

// not including <> as they are ambiguous (< is also a comparison operator)
static S testBracketHygiene_op    = "([{";
static S testBracketHygiene_close = ")]}";

static bool testBracketHygiene(S s) {
  ret testBracketHygiene(s, testBracketHygiene_op, testBracketHygiene_close, null);
}

static bool testBracketHygiene(S s, Var<S> msg) {
  ret testBracketHygiene(s, testBracketHygiene_op, testBracketHygiene_close, msg);
}

static bool testBracketHygiene(S s, S op, S close, Var<S> msg) {
  Pair<Int, S> p = testBracketHygiene2(s, op, close);
  if (p == null) {
    if (msg != null) msg.set("Hygiene OK!");
    true;
  }
  if (msg != null) msg.set(p.b);
  false;
}

Author comment

Began life as a copy of #1003920

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003922
Snippet name: testBracketHygiene - uses Java brackets (except <>) and javaTok
Eternal ID of this version: #1003922/5
Text MD5: 2983c7aadc568ced58c9e4a6f6f0b562
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-06 19:13:28
Source code size: 684 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 558 / 587
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1007977 - hasBracketHygiene - synonym of testBracketHygiene
#1009426 - testBracketHygiene2 - shows where the bad bracket is