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

12
LINES

< > BotCompany Repo | #1000346 // Use "case" as a variable name

JavaX translator [tags: use-pretranspiled]

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

!636
!quicktranslator
!class JavaTok

List<String> tok = JavaTok.split(s);

for (int i = 1; i+2 < tok.size(); i += 2)
  if (tok.get(i).equals("case")
    && !tok.get(i+2).startsWith("'"))
    tok.set(i, "_case");
    
s = JavaTok.join(tok);

Author comment

Fixed to re-allow some switch statements (those on characters)

download  show line numbers  debug dex  old transpilations   

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

Comments [hide]

ID Author/Program Comment Date
903 #1000604 (pitcher) 2015-08-20 15:28:24
900 #1000610 Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
!636
!quicktranslator
!class JavaTok

List<String> tok = JavaTok.split(s);

for (int i = 1; i+2 < tok.size(); i += 2)
if (tok.get(i).equals("case")
&& !tok.get(i+2).startsWith("'"))
tok.set(i, "_case");

s = JavaTok.join(tok);
}}
2015-08-20 00:52:10  delete 
79 stefan Correct with respect to comments, strings etc.!

Just the "switch/case" statement doesn't work anymore :o)

(We could fix that too quite probably...)
2015-07-27 14:20:16

add comment

Snippet ID: #1000346
Snippet name: Use "case" as a variable name
Eternal ID of this version: #1000346/1
Text MD5: ac34169be48deeebeb715f8f8208b6ac
Transpilation MD5: e34d75ccc869d5e88478c7c018262c71
Author: stefan
Category: javax
Type: JavaX translator
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-07-31 19:55:24
Source code size: 251 bytes / 12 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1175 / 2643
Referenced in: [show references]