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

18
LINES

< > BotCompany Repo | #1035526 // Tok_IdentifierSemicolonToReturnStatement

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

Libraryless. Click here for Pure Java version (9857L/55K).

1  
srecord noeq Tok_IdentifierSemicolonToReturnStatement(LS tok) {
2  
  Set<S> exceptions = defaultExceptions;
3  
  static Set<S> defaultExceptions = litset("break", "continue", "return", "else", "endifdef", "endif");
4  
  Set<S> precedingTokens = defaultPrecedingTokens;
5  
  static Set<S> defaultPrecedingTokens = litset("}", ";");
6  
  
7  
  TokCondition cond = new {
8  
    public bool get(L<S> tok, int nIdx) {
9  
      ret contains(precedingTokens, _get(tok, nIdx-1))
10  
        && !contains(exceptions, tok.get(nIdx+1));
11  
    }
12  
  };
13  
    
14  
  run {
15  
    for (S pre : precedingTokens)
16  
      jreplace(tok, "<id>;", "ret $1;", cond);
17  
  }
18  
}

Author comment

Began life as a copy of #1035525

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035526
Snippet name: Tok_IdentifierSemicolonToReturnStatement
Eternal ID of this version: #1035526/5
Text MD5: 8e74d624a2e0fefec5b777cfef09ad2e
Transpilation MD5: 04660ac12894f8b38c50f6ac7815342d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-04 05:02:32
Source code size: 625 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 90 / 136
Version history: 4 change(s)
Referenced in: [show references]