Constructor
@param Object keywordSpec An object with keywords as keys and parameter indexes as values
497689
function Parser (customKeywordSpec) {
    var keywordSpec = customKeywordSpec || {
        _: [0],
        gettext: [0],
        ngettext: [0, 1]
    };
    var openings = ['<%', '{\\*', '{{'];
    var closures = ['%>', '\\*}', '}}'];

    if (typeof keywordSpec !== 'object') {
        throw 'Invalid keyword spec';
    }

    this.keywordSpec = keywordSpec;
    this.expressionPattern = new RegExp([
        '(?:' + openings.join('[=-]|') + '[=-]) *',
        '(' + Object.keys(keywordSpec).map(escapeRegExp).join('|') + ')',
        '\\(',
        '([\\s\\S]*?)',
        '\\)',
        ' *(?:' + closures.join('|') + ')'
    ].join(''), 'g');
}
68455
def _do_create_keywords(args, kw):
    
    v = kw.get('varlist', ())
    # prevent varlist="FOO" from being interpreted as ['F', 'O', 'O']
    if is_String(v): v = (v,)
    kw['varlist'] = tuple(v)
    if args:
        # turn positional args into equivalent keywords
        cmdstrfunc = args[0]
        if cmdstrfunc is None or is_String(cmdstrfunc):
            kw['cmdstr'] = cmdstrfunc
        elif callable(cmdstrfunc):
            kw['strfunction'] = cmdstrfunc
        else:
            raise SCons.Errors.UserError(
                'Invalid command display variable type. '
                'You must either pass a string or a callback which '
                'accepts (target, source, env) as parameters.')
        if len(args) > 1:
            kw['varlist'] = tuple(SCons.Util.flatten(args[1:])) + kw['varlist']
    if kw.get('strfunction', _null) is not _null \
                      and kw.get('cmdstr', _null) is not _null:
        raise SCons.Errors.UserError(
            'Cannot have both strfunction and cmdstr args to Action()')
1082516
def prepare(query, params):
    
    def repl(match):
        name = match.group(1)[1:]
        if name in params:
            return marshal(params[name])
        return ":%s" % name

    new, count = re.subn(_param_re, repl, query)

    if len(params) > count:
        raise cql.ProgrammingError("More keywords were provided "
                                   "than parameters")
    return new
1340395
function logSpecs(e2eSpecPaths) {
  Object.keys(e2eSpecPaths).forEach(type => {
    const paths = e2eSpecPaths[type];

    console.log(`  ${type.toUpperCase()}:`);
    console.log(paths.map(p => `    ${p}`).join('\n'));
  });
}
681923
function WordList(words) {
  this.words = words;
  this.map = Object.create(null);

  for (let i = 0; i < words.length; i++) {
    const word = words[i];
    this.map[word] = i;
  }
}
1065811
private Summary explan(List<Keyword> keywords, String content) {

        SmartForest<Double> sf = new SmartForest<>();

        for (Keyword keyword : keywords) {
            sf.add(keyword.getName(), keyword.getScore());
        }

        // 先断句
        List<Sentence> sentences = toSentenceList(content.toCharArray());

        for (Sentence sentence : sentences) {
            computeScore(sentence, sf);
        }

        double maxScore = 0;
        int maxIndex = 0;

        MapCount<String> mc = new MapCount<>();

        for (int i = 0; i < sentences.size(); i++) {
            double tempScore = sentences.get(i).score;
            int tempLength = sentences.get(i).value.length();
            mc.addAll(sentences.get(i).mc.get());

            if (tempLength >= len) {
                tempScore = tempScore * mc.get().size();
                if (maxScore < tempScore) {
                    maxScore = tempScore;
                    maxIndex = i;
                    continue;
                }
                mc.get().clear();
            }
            for (int j = i + 1; j < sentences.size(); j++) {
                tempScore += sentences.get(j).score;
                tempLength += sentences.get(j).value.length();
                mc.addAll(sentences.get(j).mc.get());

                if (tempLength >= len) {
                    tempScore = tempScore * mc.get().size();
                    if (maxScore < tempScore) {
                        maxScore = tempScore;
                        maxIndex = i;
                    }
                    mc.get().clear();
                    break;
                }
            }

            if (tempLength < len) {
                tempScore = tempScore * mc.get().size();
                if (maxScore < tempScore) {
                    maxScore = tempScore;
                    maxIndex = i;
                    break;
                }
                mc.get().clear();
            }
        }

        StringBuilder sb = new StringBuilder();
        for (int i = maxIndex; i < sentences.size(); i++) {
            sb.append(sentences.get(i).value);
            if (sb.length() > len) {
                break;
            }
        }

        String summaryStr = sb.toString();

        /**
         * 是否强制文本长度。对于abc这种字符算半个长度
         */

        if (isSplitSummary && sb.length() > len) {
            double value = len;

            StringBuilder newSummary = new StringBuilder();
            char c = 0;
            for (int i = 0; i < sb.length(); i++) {
                c = sb.charAt(i);
                if (c < 256) {
                    value -= 0.5;
                } else {
                    value -= 1;
                }

                if (value < 0) {
                    break;
                }

                newSummary.append(c);
            }

            summaryStr = newSummary.toString();
        }

        return new Summary(keywords, summaryStr);
    }
828211
protected List<Map<String, ?>> generateSpecialKeywords(Set<String> keywords) {
		final List<Map<String, ?>> list = new ArrayList<>();
		if (!keywords.isEmpty()) {
			list.add(pattern(it -> {
				it.matches(keywordRegex(keywords));
				it.style(SPECIAL_KEYWORD_STYLE);
				it.comment("Special Keywords"); //$NON-NLS-1$
			}));
		}
		return list;
	}
498113
function keywordsListStrings (gettextFunctions) {
  const methodStrings = [];

  for (const getTextFunction of gettextFunctions) {
    let methodString = getTextFunction.name;

    if (getTextFunction.plural || getTextFunction.context) {
      methodString += ':1';
    }
    if (getTextFunction.plural) {
      methodString += `,${getTextFunction.plural}`;
    }
    if (getTextFunction.context) {
      methodString += `,${getTextFunction.context}c`;
    }

    methodStrings.push(methodString);
  }

  return methodStrings;
}
2118
public void setKeyword(String keyword) {
    if(keyword != null) {
      keyword = keyword.trim();
    }
    this.keyword = keyword;
  }
547806
function(object) {
      var module = object.constructor == JSpec.Module ? object : new JSpec.Module(object)
      this.modules.push(module)
      if ('init' in module) module.init()
      if ('utilities' in module) extend(this.defaultContext, module.utilities)
      if ('matchers' in module) this.addMatchers(module.matchers)
      if ('reporters' in module) extend(this.reporters, module.reporters)
      if ('DSLs' in module)
        each(module.DSLs, function(name, methods){
          JSpec.DSLs[name] = JSpec.DSLs[name] || {}
          extend(JSpec.DSLs[name], methods)
        })
      return this
    }
1198787
def build_valid_keywords_grammar(keywords=None):
    """"""
    from invenio_query_parser.parser import KeywordQuery, KeywordRule, \
        NotKeywordValue, SimpleQuery, ValueQuery

    if keywords:
        KeywordRule.grammar = attr('value', re.compile(
            r"(\d\d\d\w{{0,3}}|{0})\b".format("|".join(keywords), re.I)))

        NotKeywordValue.grammar = attr('value', re.compile(
            r'\b(?!\d\d\d\w{{0,3}}|{0}:)\S+\b:'.format(
                ":|".join(keywords))))

        SimpleQuery.grammar = attr(
            'op', [NotKeywordValue, KeywordQuery, ValueQuery])
    else:
        KeywordRule.grammar = attr('value', re.compile(r"[\w\d]+(\.[\w\d]+)*"))
        SimpleQuery.grammar = attr('op', [KeywordQuery, ValueQuery])
399859
private int parseKeywords() {
        int oldBlen = buffer.length();
        Map<String, String> m = getKeywordMap();
        if (!m.isEmpty()) {
            boolean first = true;
            for (Map.Entry<String, String> e : m.entrySet()) {
                append(first ? KEYWORD_SEPARATOR : ITEM_SEPARATOR);
                first = false;
                append(e.getKey());
                append(KEYWORD_ASSIGN);
                append(e.getValue());
            }
            if (first == false) {
                ++oldBlen;
            }
        }
        return oldBlen;
    }
1083484
function(hljs) {
  var keywords = {
    built_in:
      // Clojure keywords
      'def cond apply if-not if-let if not not= = &lt; < > &lt;= <= >= == + / * - rem '+
      'quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? '+
      'set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? '+
      'class? distinct? isa? float? rational? reduced? ratio? odd? even? char? seq? vector? '+
      'string? map? nil? contains? zero? instance? not-every? not-any? libspec? -> ->> .. . '+
      'inc compare do dotimes mapcat take remove take-while drop letfn drop-last take-last '+
      'drop-while while intern condp case reduced cycle split-at split-with repeat replicate '+
      'iterate range merge zipmap declare line-seq sort comparator sort-by dorun doall nthnext '+
      'nthrest partition eval doseq await await-for let agent atom send send-off release-pending-sends '+
      'add-watch mapv filterv remove-watch agent-error restart-agent set-error-handler error-handler '+
      'set-error-mode! error-mode shutdown-agents quote var fn loop recur throw try monitor-enter '+
      'monitor-exit defmacro defn defn- macroexpand macroexpand-1 for dosync and or '+
      'when when-not when-let comp juxt partial sequence memoize constantly complement identity assert '+
      'peek pop doto proxy defstruct first rest cons defprotocol cast coll deftype defrecord last butlast '+
      'sigs reify second ffirst fnext nfirst nnext defmulti defmethod meta with-meta ns in-ns create-ns import '+
      'refer keys select-keys vals key val rseq name namespace promise into transient persistent! conj! '+
      'assoc! dissoc! pop! disj! use class type num float double short byte boolean bigint biginteger '+
      'bigdec print-method print-dup throw-if printf format load compile get-in update-in pr pr-on newline '+
      'flush read slurp read-line subvec with-open memfn time re-find re-groups rand-int rand mod locking '+
      'assert-valid-fdecl alias resolve ref deref refset swap! reset! set-validator! compare-and-set! alter-meta! '+
      'reset-meta! commute get-validator alter ref-set ref-history-count ref-min-history ref-max-history ensure sync io! '+
      'new next conj set! to-array future future-call into-array aset gen-class reduce map filter find empty '+
      'hash-map hash-set sorted-map sorted-map-by sorted-set sorted-set-by vec vector seq flatten reverse assoc dissoc list '+
      'disj get union difference intersection extend extend-type extend-protocol int nth delay count concat chunk chunk-buffer '+
      'chunk-append chunk-first chunk-rest max min dec unchecked-inc-int unchecked-inc unchecked-dec-inc unchecked-dec unchecked-negate '+
      'unchecked-add-int unchecked-add unchecked-subtract-int unchecked-subtract chunk-next chunk-cons chunked-seq? prn vary-meta '+
      'lazy-seq spread list* str find-keyword keyword symbol gensym force rationalize'
   };

  var CLJ_IDENT_RE = '[a-zA-Z_0-9\\!\\.\\?\\-\\+\\*\\/\\<\\=\\>\\&\\#\\$\';]+';
  var SIMPLE_NUMBER_RE = '[\\s:\\(\\{]+\\d+(\\.\\d+)?';

  var NUMBER = {
    className: 'number', begin: SIMPLE_NUMBER_RE,
    relevance: 0
  };
  var STRING = hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null});
  var COMMENT = {
    className: 'comment',
    begin: ';', end: '$',
    relevance: 0
  };
  var COLLECTION = {
    className: 'collection',
    begin: '[\\[\\{]', end: '[\\]\\}]'
  };
  var HINT = {
    className: 'comment',
    begin: '\\^' + CLJ_IDENT_RE
  };
  var HINT_COL = {
    className: 'comment',
    begin: '\\^\\{', end: '\\}'

  };
  var KEY = {
    className: 'attribute',
    begin: '[:]' + CLJ_IDENT_RE
  };
  var LIST = {
    className: 'list',
    begin: '\\(', end: '\\)'
  };
  var BODY = {
    endsWithParent: true,
    keywords: {literal: 'true false nil'},
    relevance: 0
  };
  var TITLE = {
    keywords: keywords,
    lexemes: CLJ_IDENT_RE,
    className: 'title', begin: CLJ_IDENT_RE,
    starts: BODY
  };

  LIST.contains = [{className: 'comment', begin: 'comment'}, TITLE, BODY];
  BODY.contains = [LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER];
  COLLECTION.contains = [LIST, STRING, HINT, COMMENT, KEY, COLLECTION, NUMBER];

  return {
    aliases: ['clj'],
    illegal: /\S/,
    contains: [
      COMMENT,
      LIST,
      {
        className: 'prompt',
        begin: /^=> /,
        starts: {end: /\n\n|\Z/} // eat up prompt output to not interfere with the illegal
      }
    ]
  }
}
548535
function(keywords) {
         var node = this.createElementDefaultNS("KeywordList");

         for (var i=0, len=keywords.length; i<len; i++) {
             node.appendChild(this.createElementDefaultNS(
                 "Keyword", keywords[i]
             ));
         }
         return node;
     }
995943
function defineKeywords(ajv, keyword) {
  if (Array.isArray(keyword)) {
    for (var i=0; i<keyword.length; i++)
      get(keyword[i])(ajv);
    return ajv;
  }
  if (keyword) {
    get(keyword)(ajv);
    return ajv;
  }
  for (keyword in KEYWORDS) get(keyword)(ajv);
  return ajv;
}
1121118
def make_generic_c_patterns(keywords, builtins,
                            instance=None, define=None, comment=None):
    ""
    kw = r"\b" + any("keyword", keywords.split()) + r"\b"
    builtin = r"\b" + any("builtin", builtins.split()+C_TYPES.split()) + r"\b"
    if comment is None:
        comment = any("comment", [r"//[^\n]*", r"\/\*(.*?)\*\/"])
    comment_start = any("comment_start", [r"\/\*"])
    comment_end = any("comment_end", [r"\*\/"])
    if instance is None:
        instance = any("instance", [r"\bthis\b"])
    number = any("number",
                 [r"\b[+-]?[0-9]+[lL]?\b",
                  r"\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b",
                  r"\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b"])
    sqstring = r"(\b[rRuU])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
    dqstring = r'(\b[rRuU])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
    string = any("string", [sqstring, dqstring])
    if define is None:
        define = any("define", [r"#[^\n]*"])
    return "|".join([instance, kw, comment, string, number,
                     comment_start, comment_end, builtin,
                     define, any("SYNC", [r"\n"])])
119917
public static void setProperties(Object object, Map map) {
        MetaClass mc = getMetaClass(object);
        for (Object o : map.entrySet()) {
            Map.Entry entry = (Map.Entry) o;
            String key = entry.getKey().toString();
            Object value = entry.getValue();
            setPropertySafe(object, mc, key, value);
        }
    }