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

17
LINES

< > BotCompany Repo | #1031294 // tok_pingify - add ping calls to for and while loops (so they are interruptible)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3603L/22K).

// Almost complete for Java code
// but we should also cover function calls to be really complete
// Incomplete for JavaX code
svoid tok_pingify(LS tok) {
  // Java
  
  jreplace(tok, "for (", "for ping (");
  jreplace(tok, "while (", "while ping (");
  jreplace(tok, "do {", "do { ping();");
  
  // JavaX - TODO: make sure we have all the constructs
  
  //jreplace(tok, "for $id to *:", "for $2 to $4: "... // TODO
  
  jreplace(tok, "while <id> {", "while $2 { ping();");
  jreplace(tok, "repeat * {", "repeat $2 { ping();");
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031294
Snippet name: tok_pingify - add ping calls to for and while loops (so they are interruptible)
Eternal ID of this version: #1031294/3
Text MD5: eb3580624383f79304a944105fd63e7e
Transpilation MD5: de51b84aa7029cd07e4bc2980e2ee139
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-26 19:49:17
Source code size: 547 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 206 / 289
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1031295 - tok_safeify - convert typical function calls to their safe (sandboxed) versions. Maybe we don't need this. Just make all the functions safe to begin with