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).

static Set<S> gazelle_allSyntacticPatternsFromInput(S input) {
  Chain<S> tokens = toChain(javaTokC(input));
  new LinkedHashSet<S> out;
  gazelle_allSyntacticPatternsFromInput_collect(null, tokens, out);
  ret out;
}

svoid gazelle_allSyntacticPatternsFromInput_collect(ReverseChain<S> prefix, Chain<S> tokens, Set<S> out) {
  ping();
  if (empty(tokens)) {
    out.add(joinWithSpace(asList(prefix)));
    ret;
  }
  
  // output one token
  gazelle_allSyntacticPatternsFromInput_collect(
    chainPlus(prefix, first(tokens)),
    dropFirst(tokens), out);
    
  // output * unless last token output was a *
  // consume between 1 and all tokens
  if (!eq(last(prefix), "*")) {
    ReverseChain<S> prefix2 = chainPlus(prefix, "*");
    Chain<S> tokens2 = tokens;
    while (!empty(tokens2)) {
      tokens2 = dropFirst(tokens2);
      gazelle_allSyntacticPatternsFromInput_collect(prefix2, tokens2, out);
    }
  }
}

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: 111 / 188
Version history: 3 change(s)
Referenced in: [show references]