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

30
LINES

< > BotCompany Repo | #1030889 // gazelle_allSyntacticPatternsFromInput - version without stars next to each other

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

Libraryless. Click here for Pure Java version (3020L/18K).

1  
static Set<S> gazelle_allSyntacticPatternsFromInput(S input) {
2  
  Chain<S> tokens = toChain(javaTokC(input));
3  
  new LinkedHashSet<S> out;
4  
  gazelle_allSyntacticPatternsFromInput_collect(null, tokens, out);
5  
  ret out;
6  
}
7  
8  
svoid gazelle_allSyntacticPatternsFromInput_collect(ReverseChain<S> prefix, Chain<S> tokens, Set<S> out) {
9  
  ping();
10  
  if (empty(tokens)) {
11  
    out.add(joinWithSpace(asList(prefix)));
12  
    ret;
13  
  }
14  
  
15  
  // output one token
16  
  gazelle_allSyntacticPatternsFromInput_collect(
17  
    chainPlus(prefix, first(tokens)),
18  
    dropFirst(tokens), out);
19  
    
20  
  // output * unless last token output was a *
21  
  // consume between 1 and all tokens
22  
  if (!eq(last(prefix), "*")) {
23  
    ReverseChain<S> prefix2 = chainPlus(prefix, "*");
24  
    Chain<S> tokens2 = tokens;
25  
    while (!empty(tokens2)) {
26  
      tokens2 = dropFirst(tokens2);
27  
      gazelle_allSyntacticPatternsFromInput_collect(prefix2, tokens2, out);
28  
    }
29  
  }
30  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1030889
Snippet name: gazelle_allSyntacticPatternsFromInput - version without stars next to each other
Eternal ID of this version: #1030889/4
Text MD5: 154152378a85bd928ae3f8f04682d9c5
Transpilation MD5: b1117ffb23bf4f99a917a8c267e53b13
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-06 13:14:45
Source code size: 946 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 208 / 322
Version history: 3 change(s)
Referenced in: [show references]