/*
Name     : expandCompositCharAtNear
Function : Expands the LamAlef character into Lam + Alef, YehHamza character
into Yeh + Hamza, SeenFamily character into SeenFamily character
+ Tail, while consuming the space next to the character.
339249
private boolean expandCompositCharAtNear(char[] dest,int start, int length,
                                       int yehHamzaOption, int seenTailOption, int lamAlefOption){

      boolean spaceNotFound = false;



      if (isNormalizedLamAlefChar(dest[start])) {
          spaceNotFound = true;
          return spaceNotFound;
      }
      for (int i = start + length; --i >=start;) {
          char ch = dest[i];
          if (lamAlefOption == 1 && isNormalizedLamAlefChar(ch)) {
              if (i>start &&dest[i-1] == SPACE_CHAR) {
                  dest[i] = LAM_CHAR;
                  dest[--i] = convertNormalizedLamAlef[ch - '\u065C'];
              } else {
                  spaceNotFound = true;
                  return spaceNotFound;
              }
          }else if(seenTailOption == 1 && isSeenTailFamilyChar(ch) == 1){
              if(i>start &&dest[i-1] == SPACE_CHAR){
                  dest[i-1] = tailChar;
              } else{
                  spaceNotFound = true;
                  return spaceNotFound;
              }
          }else if(yehHamzaOption == 1 && isYehHamzaChar(ch)){

               if(i>start &&dest[i-1] == SPACE_CHAR){
                  dest[i] = yehHamzaToYeh[ch - YEH_HAMZAFE_CHAR];
                  dest[i-1] = HAMZAFE_CHAR;
              }else{
                  spaceNotFound = true;
                  return spaceNotFound;
                }


          }
      }
      return false;

  }
53556
private String expandLHS(final String lhs,
                             int lineOffset) {
        substitutions = new ArrayList<Map<String, String>>();

        //        logger.info( "*** LHS>" + lhs + "<" );
        final StringBuilder buf = new StringBuilder();
        
        final String[] lines = lhs.split( (lhs.indexOf("\r\n") >= 0 ? "\r\n":"\n"),
                                          -1 ); // since we assembled the string, we know line breaks are \n
        final String[] expanded = new String[lines.length]; // buffer for expanded lines
        int lastExpanded = -1;
        int lastPattern = -1;
        for ( int i = 0; i < lines.length - 1; i++ ) {
            final String trimmed = lines[i].trim();
            expanded[++lastExpanded] = lines[i];

            if ( trimmed.length() == 0 || trimmed.startsWith( "#" ) || trimmed.startsWith( "//" ) ) {
                // comments - do nothing
            } else if ( trimmed.startsWith( ">" ) ) {
                // passthrough code - simply remove the passthrough mark character
                expanded[lastExpanded] = lines[i].replaceFirst( ">",
                                                                " " );
                lastPattern = lastExpanded;
            } else {
                // regular expansion - expand the expression
                expanded[lastExpanded] =
                        substitute( expanded[lastExpanded],
                                    this.condition,
                                    i + lineOffset,
                                    useWhen,
                                    showSteps );

                // do we need to report errors for that?
                if ( lines[i].equals( expanded[lastExpanded] ) ) {
                    // report error
                    this.addError( new ExpanderException( "Unable to expand: " + lines[i].replaceAll( "[\n\r]",
                                                                                                      "" ).trim(),
                                                          i + lineOffset ) );
                }
                // but if the original starts with a "-", it means we need to add it
                // as a constraint to the previous pattern
                if ( trimmed.startsWith( "-" ) && (!lines[i].equals( expanded[lastExpanded] )) ) {
                    if ( lastPattern >= 0 ) {
                        ConstraintInformation c = ConstraintInformation.findConstraintInformationInPattern( expanded[lastPattern] );
                        if ( c.start > -1 ) {
                            // rebuilding previous pattern structure
                            expanded[lastPattern] = expanded[lastPattern].substring( 0,
                                                                                     c.start ) + c.constraints + ((c.constraints.trim().length() == 0) ? "" : ", ") + expanded[lastExpanded].trim() + expanded[lastPattern].substring( c.end );
                        } else {
                            // error, pattern not found to add constraint to
                            this.addError( new ExpanderException( "No pattern was found to add the constraint to: " + lines[i].trim(),
                                                                  i + lineOffset ) );
                        }
                    }
                    lastExpanded--;
                } else {
                    lastPattern = lastExpanded;
                }
            }
        }
        for ( int i = 0; i <= lastExpanded; i++ ) {
            buf.append( expanded[i] );
            buf.append( nl );
        }

        return buf.toString();
    }
402256
private Document createCompositeILF(
            final IPerson person,
            final Document PLF,
            final List<Document> applicableLayouts,
            final IntegrationResult integrationResult) {
        final Document ILF = ILFBuilder.constructILF(PLF, applicableLayouts, person);
        PLFIntegrator.mergePLFintoILF(PLF, ILF, integrationResult);
        if (logger.isDebugEnabled()) {
            logger.debug(
                    "PLF for {} after MERGING\n{}",
                    person.getAttribute(IPerson.USERNAME),
                    XmlUtilitiesImpl.toString(PLF));
            logger.debug(
                    "ILF for {} after MERGING\n{}",
                    person.getAttribute(IPerson.USERNAME),
                    XmlUtilitiesImpl.toString(ILF));
        }
        return ILF;
    }
546222
private void expandAffix(String pattern, String pluralCount, StringBuffer buffer) {
        buffer.setLength(0);
        for (int i = 0; i < pattern.length();) {
            char c = pattern.charAt(i++);
            if (c == QUOTE) {
                for (;;) {
                    int j = pattern.indexOf(QUOTE, i);
                    if (j == i) {
                        buffer.append(QUOTE);
                        i = j + 1;
                        break;
                    } else if (j > i) {
                        buffer.append(pattern.substring(i, j));
                        i = j + 1;
                        if (i < pattern.length() && pattern.charAt(i) == QUOTE) {
                            buffer.append(QUOTE);
                            ++i;
                            // loop again
                        } else {
                            break;
                        }
                    } else {
                        // Unterminated quote; should be caught by apply
                        // pattern.
                        throw new RuntimeException();
                    }
                }
                continue;
            }

            switch (c) {
            case CURRENCY_SIGN:
                // As of ICU 2.2 we use the currency object, and ignore the currency
                // symbols in the DFS, unless we have a null currency object. This occurs
                // if resurrecting a pre-2.2 object or if the user sets a custom DFS.
                boolean intl = i < pattern.length() && pattern.charAt(i) == CURRENCY_SIGN;
                boolean plural = false;
                if (intl) {
                    ++i;
                    if (i < pattern.length() && pattern.charAt(i) == CURRENCY_SIGN) {
                        plural = true;
                        intl = false;
                        ++i;
                    }
                }
                String s = null;
                Currency currency = getCurrency();
                if (currency != null) {
                    // plural name is only needed when pluralCount != null, which means
                    // when formatting currency plural names.  For other cases,
                    // pluralCount == null, and plural names are not needed.
                    if (plural && pluralCount != null) {
                        s = currency.getName(symbols.getULocale(), Currency.PLURAL_LONG_NAME,
                                             pluralCount, null);
                    } else if (!intl) {
                        s = currency.getName(symbols.getULocale(), Currency.SYMBOL_NAME, null);
                    } else {
                        s = currency.getCurrencyCode();
                    }
                } else {
                    s = intl ? symbols.getInternationalCurrencySymbol() :
                        symbols.getCurrencySymbol();
                }
                // Here is where FieldPosition could be set for CURRENCY PLURAL.
                buffer.append(s);
                break;
            case PATTERN_PERCENT:
                buffer.append(symbols.getPercentString());
                break;
            case PATTERN_PER_MILLE:
                buffer.append(symbols.getPerMillString());
                break;
            case PATTERN_MINUS_SIGN:
                buffer.append(symbols.getMinusSignString());
                break;
            default:
                buffer.append(c);
                break;
            }
        }
    }
622031
function add(x, y) {
  var ans=expand(x, (x.length>y.length ? x.length+1 : y.length+1));
  add_(ans, y);
  return trim(ans, 1);
}
816332
function wrappedOrigCall(orgFunc, newFunc) {
    return function() {
        var args = [].slice.call(arguments);
        try { orgFunc.apply(WinConsole, args); } catch (e) {}
        try { newFunc.apply(console,    args); } catch (e) {}
    };
}
439318
private String handleCompositeColumnName(final String columnName) {
        final String columnKey = columnName.substring(columnName.lastIndexOf(":") + 1);
        return columnKey.equals("") ? columnName : columnKey;
    }
524869
def _expand(self, coeffsin, nmax):
        
        if self.coeffs is None:
            self.rotate(clat=90., clon=0., nrot=nmax)
            falpha = _shtools.SlepianCoeffs(self.coeffs, coeffsin, self.nrot)
        else:
            falpha = _shtools.SlepianCoeffs(self.coeffs, coeffsin, self.nrot)

        return SlepianCoeffs(falpha, self)
818957
function expandItem(data) {
    // Cloning to avoid modification of the original data item.
    data = JSON.parse(JSON.stringify(data));

    if (!data.expansions) {
        data.expansions = [];
    }

    // Expansions are stored in a tree structure.
    let obj = findExpansion.call(this, data.parent);
    obj.expansions.push(data);
}
86515
function interpose(coll, separator) {
  if (arguments.length === 1) {
    separator = coll;
    return function(xform) {
      return new Interpose(separator, xform);
    };
  }
  return seq(coll, interpose(separator));
}
919665
function expandTokenMatchesToSentences2(tokens, tokenMatches) {
    var a = [];
    var wordMatches = [];
    debuglogV(debuglog.enabled ? JSON.stringify(tokenMatches) : '-');
    tokenMatches.forEach(function (aWordMatches, wordIndex) {
        wordMatches[wordIndex] = [];
        aWordMatches.forEach(function (oWordVariant, wordVariantIndex) {
            wordMatches[wordIndex][wordVariantIndex] = oWordVariant;
        });
    });
    debuglog(debuglog.enabled ? JSON.stringify(tokenMatches) : '-');
    var result = {
        errors: [],
        tokens: tokens,
        sentences: []
    };
    var nvecs = [];
    var res = [[]];
    // var nvecs = [];
    var rvec = [];
    for (var tokenIndex = 0; tokenIndex < tokenMatches.length; ++tokenIndex) {
        //vecs is the vector of all so far seen variants up to tokenIndex length.
        var nextBase = [];
        // independent of existence of matches on level k, we retain all vectors which are covered by a span
        // we skip extending them below
        for (var u = 0; u < res.length; ++u) {
            if (isSpanVec(res[u], tokenIndex)) {
                nextBase.push(res[u]);
            }
            else if (isSuccessorOperator(res[u], tokenIndex)) {
                res[u].push(makeAnyWord(tokens[tokenIndex]));
                nextBase.push(res[u]);
            }
        }
        // independent of existence of matches on level tokenIndex, we extend all vectors which
        // are a successor of a binary extending op ( like "starting with", "containing" with the next token)
        /*   for(var resIndex = 0; resIndex < res.length; ++resIndex) {
          if (isSuccessorOperator(res[resIndex], tokenIndex)) {
            res[resIndex].push(makeAnyWord(tokens[tokenIndex]));
            nextBase.push(res[resIndex]);
          }
        }
        */
        var lenMatches = tokenMatches[tokenIndex].length;
        if (nextBase.length === 0 && lenMatches === 0) {
            // the word at index I cannot be understood
            //if (result.errors.length === 0) {
            result.errors.push(ERError.makeError_NO_KNOWN_WORD(tokenIndex, tokens));
            //}
        }
        for (var l = 0; l < lenMatches; ++l) {
            //debuglog("vecs now" + JSON.stringify(vecs));
            var nvecs = []; //vecs.slice(); // copy the vec[i] base vector;
            //debuglog("vecs copied now" + JSON.stringify(nvecs));
            for (var u = 0; u < res.length; ++u) {
                if (!isSpanVec(res[u], tokenIndex) && !isSuccessorOperator(res[u], tokenIndex)) {
                    // for each so far constructed result (of length k) in res
                    nvecs.push(res[u].slice()); // make a copy of each vector
                    nvecs[nvecs.length - 1] = copyVecMembers(nvecs[nvecs.length - 1]);
                    // debuglog("copied vecs["+ u+"]" + JSON.stringify(vecs[u]));
                    nvecs[nvecs.length - 1].push(clone(tokenMatches[tokenIndex][l])); // push the lth variant
                    // debuglog("now nvecs " + nvecs.length + " " + JSON.stringify(nvecs));
                }
            }
            //   debuglog(" at     " + k + ":" + l + " nextbase >" + JSON.stringify(nextBase))
            //   debuglog(" append " + k + ":" + l + " nvecs    >" + JSON.stringify(nvecs))
            nextBase = nextBase.concat(nvecs);
            //   debuglog("  result " + k + ":" + l + " nvecs    >" + JSON.stringify(nextBase))
        } //constru
        //  debuglog("now at " + k + ":" + l + " >" + JSON.stringify(nextBase))
        res = nextBase;
    }
    debuglogV(debuglogV.enabled ? ("APPENDING TO RES" + 0 + ":" + l + " >" + JSON.stringify(nextBase)) : '-');
    res = res.filter(function (sentence, index) {
        var full = 0xFFFFFFFF;
        //console.log(`sentence  ${index}  \n`)
        return sentence.every(function (word, index2) {
            full = full & word.rule.bitSentenceAnd;
            //console.log(` word  ${index2} ${full} "${word.matchedString}" ${word.rule.bitSentenceAnd}  ${tokens[index2]} \n`);
            return full !== 0;
        });
    });
    result.sentences = res;
    return result;
}
1055665
function assimilateSimilarTokens(xs, a) {
  var b  = last(xs)
  var ys = butLast(xs)
  return !b?       [a]
  :      /* _ */   ys.concat( b.canAssimilate(a)?  [b.assimilate(a)]
                            : /* otherwise */      [b, a]) }
1301591
function morechars() {
		switch (character) {
			case ';':
				flush();
				break;
			case '=':
			case '\'':
			case '"':
				if(!supercall) {
					flush();
				}
				break;
			default:
				if (supercall) {
					processsupercall();
				}
				buffer += character;
				if (prototype && !supercall) {
					checksupercall();
				}
				if(!prototype) {
					checkextensions();
				}
				break;
		}
	}
317196
def rule_expand(component, text):
    ''''''
    global rline_mpstate
    if component[0] == '<' and component[-1] == '>':
        return component[1:-1].split('|')
    if component in rline_mpstate.completion_functions:
        return rline_mpstate.completion_functions[component](text)
    return [component]
1333039
function makeContinuation(name, body) {
        var ctn = {
            $continuation: true,
            type: name ? 'FunctionDeclaration' : 'FunctionExpression',
            id: name ? typeof name === "string" ? ident(name) : name : undefined,
            params: [],
            body: {
                type: 'BlockStatement',
                body: cloneNode(body)
            }
        };
        if (name) {
            continuations[name] = {
                def: ctn
            };
        }
        return ctn;
    }
286438
def _expand(self, normalization, csphase, **kwargs):
        """"""
        if normalization.lower() == '4pi':
            norm = 1
        elif normalization.lower() == 'schmidt':
            norm = 2
        elif normalization.lower() == 'unnorm':
            norm = 3
        elif normalization.lower() == 'ortho':
            norm = 4
        else:
            raise ValueError(
                "The normalization must be '4pi', 'ortho', 'schmidt', " +
                "or 'unnorm'. Input value was {:s}."
                .format(repr(normalization))
                )

        cilm = _shtools.SHExpandDH(self.data, norm=norm, csphase=csphase,
                                   sampling=self.sampling,
                                   **kwargs)
        coeffs = SHCoeffs.from_array(cilm,
                                     normalization=normalization.lower(),
                                     csphase=csphase, copy=False)
        return coeffs
1369250
function getCompositeTypes(str){
  var type = getInnerType(str);
  if (type === str) {
    return getType(str);
  }

  var types = type.split(','),
      i = 0, ret = [], typeLength = types.length;

  for(; i < typeLength; i += 1){
    ret.push( parseTypeString(types[i]) );
  }

  return ret;
}