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

16
LINES

< > BotCompany Repo | #1031876 // tok_castToStatements

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

Libraryless. Click here for Pure Java version (5400L/31K).

// e.g. cast req to Req; 
// (converts req to (Req) req for the rest of the block)
svoid tok_castToStatements(LS tok) {
  int i;
  while ((i = jfind(tok, "cast <id> to")) >= 0) {
    S id = tok.get(i+2);
    int iTypeStart = i+6;
    int semicolon = findEndOfStatement(tok, iTypeStart)-1;
    int endOfOuterBlock = findEndOfBracketPart(tok, semicolon)-1;
    S type = joinSubList(tok, iTypeStart, semicolon-1);
    
    tok_insertCasts_noReTok(tok, semicolon+2, endOfOuterBlock, id, type);
    clearTokens(tok, i, semicolon+1);
    reTok(tok, i, endOfOuterBlock);
  }
}
  

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1031876
Snippet name: tok_castToStatements
Eternal ID of this version: #1031876/3
Text MD5: 8eb09ad309949e8e674f12acbbf2b4ea
Transpilation MD5: 6518fe6bfa4f28f6328fc521b87d4d32
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-12-24 22:05:52
Source code size: 588 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 165 / 250
Version history: 2 change(s)
Referenced in: [show references]