public static VariableNumPattern
518262
@Override
  public List<VariableMatch> matchVariables(VariableNumMap inputVariables) {
    // All of the fixed variables must be matched in order to return anything.
    if (!inputVariables.containsAll(fixedVariables)) {
      return Collections.emptyList();
    }
    // Special case: if there aren't any templates, then only the fixed
    // variables should be returned.
    if (plateStarts.length == 0) {
      return Arrays.asList(VariableMatch.identity(fixedVariables));
    }

    int maxPlateReplication = -1;
    int[] inputVarNums = inputVariables.getVariableNumsArray();
    int numVars = inputVarNums.length;
    int numMatchers = plateStarts.length;
    for (int i = 0; i < numMatchers; i++) {
      for (int j = 0; j < numVars; j++) {
        if (inputVarNums[j] >= plateStarts[i] && inputVarNums[j] < plateEnds[i]) {
          int withinPlateIndex = inputVarNums[j] - plateStarts[i];
          int plateReplicationNum = withinPlateIndex / plateReplicationSizes[i];
          int replicationIndex = plateReplicationNum - plateMatchIndexOffsets[i];
          maxPlateReplication = Math.max(replicationIndex, maxPlateReplication);
        }
      }
    }

    // Aggregate pattern matches for each variable.
    int[] templateVarNums = templateVariables.getVariableNumsArray();
    int[][] variableMatches = new int[maxPlateReplication + 1][];
    for (int i = 0; i < numMatchers; i++) {      
      for (int j = 0; j < numVars; j++) {
        if (inputVarNums[j] >= plateStarts[i] && inputVarNums[j] < plateEnds[i]) {
          // The variable is within the plate we're matching.
          int withinPlateIndex = inputVarNums[j] - plateStarts[i];
          int plateReplicationNum = withinPlateIndex / plateReplicationSizes[i];
          int varOffset = withinPlateIndex % plateReplicationSizes[i];
          if (varOffset == plateVarOffsets[i]) {
            // The variable matches the pattern.
            int replicationIndex = plateReplicationNum - plateMatchIndexOffsets[i];
            if (variableMatches[replicationIndex] == null) {
              variableMatches[replicationIndex] = new int[templateVarNums.length];
              Arrays.fill(variableMatches[replicationIndex], -1);
            }
            variableMatches[replicationIndex][i] = inputVarNums[j];
          }
        }
      }
    }

    // Eliminate any partial matches which do not contain a match for every
    // variable prefix.
    List<VariableMatch> validMatches = Lists.newArrayList();
    int numMatches = variableMatches.length;
    for (int i = 0; i < numMatches; i++) {
      int[] matchBuilder = variableMatches[i];
      if (matchBuilder != null && Ints.indexOf(matchBuilder, -1) == -1) {
        VariableNumMap matchedVariables = inputVariables.intersection(matchBuilder);
        VariableRelabeling fixedVariableRelabeling = VariableRelabeling.identity(fixedVariables);

        int[] templateCopy = Arrays.copyOf(templateVarNums, templateVarNums.length);

        IntBiMap mapping = IntBiMap.fromUnsortedKeyValues(matchBuilder, templateCopy);
        VariableRelabeling matchedRelabeling = new VariableRelabeling(matchedVariables,
            templateVariables, mapping);
        VariableMatch match = new VariableMatch(matchedVariables.union(fixedVariables),
          templateVariables.union(fixedVariables), fixedVariableRelabeling.union(matchedRelabeling));

        validMatches.add(match);
      }
    }
    return validMatches;
  }
302775
private List<NumberPattern> getNumberPattern(String pattern) {
    int i = pattern.indexOf(';');
    if (i == -1) {
      return Arrays.asList(
          parseNumberPattern(pattern),
          parseNumberPattern("-" + pattern));
    }
    return Arrays.asList(
        parseNumberPattern(pattern.substring(0, i)),
        parseNumberPattern(pattern.substring(i+1)));
  }
606874
public static final VariableNumMap singleton(int varNum, String varName, Variable variable) {
    return new VariableNumMap(new int[] {varNum}, new String[] {varName}, new Variable[] {variable});
  }
278047
public final void variable_definition() throws RecognitionException {
		CommonTree varname=null;
		CommonTree q=null;
		CommonTree pattern=null;

		try {
			// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:127:5: ( ^( VT_VAR_DEF varname= LITERAL ^( VT_QUAL (q= LITERAL )? ) (pattern= VT_PATTERN )? ) )
			// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:127:9: ^( VT_VAR_DEF varname= LITERAL ^( VT_QUAL (q= LITERAL )? ) (pattern= VT_PATTERN )? )
			{
			match(input,VT_VAR_DEF,FOLLOW_VT_VAR_DEF_in_variable_definition423); 
			match(input, Token.DOWN, null); 
			varname=(CommonTree)match(input,LITERAL,FOLLOW_LITERAL_in_variable_definition427); 
			match(input,VT_QUAL,FOLLOW_VT_QUAL_in_variable_definition430); 
			if ( input.LA(1)==Token.DOWN ) {
				match(input, Token.DOWN, null); 
				// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:127:49: (q= LITERAL )?
				int alt13=2;
				int LA13_0 = input.LA(1);
				if ( (LA13_0==LITERAL) ) {
					alt13=1;
				}
				switch (alt13) {
					case 1 :
						// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:127:49: q= LITERAL
						{
						q=(CommonTree)match(input,LITERAL,FOLLOW_LITERAL_in_variable_definition434); 
						}
						break;

				}

				match(input, Token.UP, null); 
			}

			// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:127:67: (pattern= VT_PATTERN )?
			int alt14=2;
			int LA14_0 = input.LA(1);
			if ( (LA14_0==VT_PATTERN) ) {
				alt14=1;
			}
			switch (alt14) {
				case 1 :
					// src/main/resources/org/drools/compiler/lang/dsl/DSLMapWalker.g:127:67: pattern= VT_PATTERN
					{
					pattern=(CommonTree)match(input,VT_PATTERN,FOLLOW_VT_PATTERN_in_variable_definition440); 
					}
					break;

			}

			match(input, Token.UP, null); 


			        entry_stack.peek().variables.put((varname!=null?varname.getText():null), Integer.valueOf(0));

			        if(q!=null && pattern!=null){
			            entry_stack.peek().sentenceKeyBuffer.append("{"+(varname!=null?varname.getText():null)+":"+(q!=null?q.getText():null)+":"+(pattern!=null?pattern.getText():null)+"}");
			        }else if(q==null && pattern!=null){
			            entry_stack.peek().sentenceKeyBuffer.append("{"+(varname!=null?varname.getText():null)+":"+(pattern!=null?pattern.getText():null)+"}");
			        }else{
			            entry_stack.peek().sentenceKeyBuffer.append("{"+(varname!=null?varname.getText():null)+"}");
			        }

			        if(q == null || (!q.getText().equals("ENUM") && !q.getText().equals("CF") && 
			                          !q.getText().equals("DATE") && !q.getText().equals("BOOLEAN"))){
			            entry_stack.peek().keybuffer.append(pattern != null? "(" + (pattern!=null?pattern.getText():null) + ")" : "(.*?)");
			        }else{
			            entry_stack.peek().keybuffer.append("(.*?)");
			        }
			    
			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
		}
	}
1359363
public static String getVariablesMapExpression(Collection variables) {
        StringBuilder variablesMap = new StringBuilder("new  " + PropertiesMap.class.getName() + "()");
        for (Object variable : variables) {
            JRVariable jrvar = (JRVariable) variable;
            String varname = jrvar.getName();
            variablesMap.append(".with(\"").append(varname).append("\",$V{").append(varname).append("})");
        }
        return variablesMap.toString();
    }
101403
public static Annotation[] findAnnotations(AbstractVariableDeclaration field, Pattern namePattern) {
		List<Annotation> result = new ArrayList<Annotation>();
		if (field.annotations == null) return EMPTY_ANNOTATIONS_ARRAY;
		for (Annotation annotation : field.annotations) {
			TypeReference typeRef = annotation.type;
			if (typeRef != null && typeRef.getTypeName() != null) {
				char[][] typeName = typeRef.getTypeName();
				String suspect = new String(typeName[typeName.length - 1]);
				if (namePattern.matcher(suspect).matches()) {
					result.add(annotation);
				}
			}
		}	
		return result.toArray(EMPTY_ANNOTATIONS_ARRAY);
	}
852709
public final void localVariableDeclaration() throws RecognitionException {
		VarDecl_stack.push(new VarDecl_scope());

		int localVariableDeclaration_StartIndex = input.index();

		ParserRuleReturnScope variableModifier1 =null;
		ParserRuleReturnScope type2 =null;


		            VarDecl_stack.peek().descr = new JavaLocalDeclarationDescr();
		        
		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 82) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:710:5: ( ( variableModifier )* type variableDeclarators ';' )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:711:5: ( variableModifier )* type variableDeclarators ';'
			{
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:711:5: ( variableModifier )*
			loop106:
			while (true) {
				int alt106=2;
				int LA106_0 = input.LA(1);
				if ( (LA106_0==58||LA106_0==83) ) {
					alt106=1;
				}

				switch (alt106) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:711:7: variableModifier
					{
					pushFollow(FOLLOW_variableModifier_in_localVariableDeclaration2865);
					variableModifier1=variableModifier();
					state._fsp--;
					if (state.failed) return;
					if ( state.backtracking==0 ) {
					            VarDecl_stack.peek().descr.updateStart( ((CommonToken)(variableModifier1!=null?(variableModifier1.start):null)).getStartIndex() - 1 );
					            VarDecl_stack.peek().descr.addModifier( (variableModifier1!=null?input.toString(variableModifier1.start,variableModifier1.stop):null) );
					        }
					}
					break;

				default :
					break loop106;
				}
			}

			pushFollow(FOLLOW_type_in_localVariableDeclaration2888);
			type2=type();
			state._fsp--;
			if (state.failed) return;
			if ( state.backtracking==0 ) {
			            VarDecl_stack.peek().descr.updateStart( ((CommonToken)(type2!=null?(type2.start):null)).getStartIndex() - 1 );
			            VarDecl_stack.peek().descr.setType( (type2!=null?input.toString(type2.start,type2.stop):null) );
			            VarDecl_stack.peek().descr.setEnd( ((CommonToken)(type2!=null?(type2.stop):null)).getStopIndex() );
			        }
			pushFollow(FOLLOW_variableDeclarators_in_localVariableDeclaration2904);
			variableDeclarators();
			state._fsp--;
			if (state.failed) return;
			match(input,52,FOLLOW_52_in_localVariableDeclaration2906); if (state.failed) return;
			}

			if ( state.backtracking==0 ) {
			            addLocalDeclaration( VarDecl_stack.peek().descr );
			        }
		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 82, localVariableDeclaration_StartIndex); }

			VarDecl_stack.pop();

		}
	}
383453
private List<String> getPatterns(List<NumberPattern> patterns) {
    return patterns.stream()
        .map(p -> p.render())
        .collect(Collectors.toList());
  }
519058
private String replaceVariablesWithPatterns(String pattern) {
        int group = 0;
        Matcher findVariablesMatcher = variablePattern.matcher(pattern);
        while(findVariablesMatcher.find()) {
            String variable = findVariablesMatcher.group(0);
            pattern = pattern.replaceFirst(variable, "(.+)");
            variableToGroupNumber.put(variable, ++group);
        }
        return pattern;
    }
990339
private Pattern makePattern(String noProxy) {
        String regex = noProxy.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*");
        if (!regex.startsWith(".*")) {
            regex = ".*" + regex;
        }
        regex = "^" + regex + "$";
        return Pattern.compile(regex);
    }
260030
function createPatternVariations(pattern) {
    var lastCharIdx = pattern.length - 1,
        patternVariations = [pattern, '!' + pattern];

    if (pattern[lastCharIdx] === '/') {
        var unslashed = pattern.substring(0, lastCharIdx);

        patternVariations.push(unslashed);
        patternVariations.push('!' + unslashed);
    }

    return patternVariations;
}
295599
static String format(final String messagePattern, final Object[] arguments) {
        final StringBuilder result = new StringBuilder();
        final int argCount = arguments == null ? 0 : arguments.length;
        formatMessage(result, messagePattern, arguments, argCount);
        return result.toString();
    }
637374
public String getNumericName(int i )
    {
        if(i < getNumNumericalVars() && i >= 0)
            return numericalVariableNames.getOrDefault(i, "Numeric Feature " + i);
        else
            throw new IndexOutOfBoundsException("Can not acces variable for invalid index  " + i );
    }
819092
protected void generateNumericConstants(IStyleAppendable it) {
		appendComment(it, "numerical constants"); //$NON-NLS-1$
		appendMatch(it, "sarlNumber", "[0-9][0-9]*\\.[0-9]\\+([eE][0-9]\\+)\\?[fFdD]\\?"); //$NON-NLS-1$ //$NON-NLS-2$
		appendMatch(it, "sarlNumber", "0[xX][0-9a-fA-F]\\+"); //$NON-NLS-1$ //$NON-NLS-2$
		appendMatch(it, "sarlNumber", "[0-9]\\+[lL]\\?"); //$NON-NLS-1$ //$NON-NLS-2$
		appendCluster(it, "sarlNumber"); //$NON-NLS-1$
		hilight("sarlNumber", VimSyntaxGroup.CONSTANT); //$NON-NLS-1$
		it.newLine();
	}
884735
public final void variableInitializer() throws RecognitionException {
		int variableInitializer_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 44) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:495:5: ( arrayInitializer | expression )
			int alt60=2;
			int LA60_0 = input.LA(1);
			if ( (LA60_0==121) ) {
				alt60=1;
			}
			else if ( ((LA60_0 >= CharacterLiteral && LA60_0 <= DecimalLiteral)||LA60_0==FloatingPointLiteral||(LA60_0 >= HexLiteral && LA60_0 <= Identifier)||(LA60_0 >= OctalLiteral && LA60_0 <= StringLiteral)||LA60_0==29||LA60_0==36||(LA60_0 >= 40 && LA60_0 <= 41)||(LA60_0 >= 44 && LA60_0 <= 45)||LA60_0==53||LA60_0==65||LA60_0==67||(LA60_0 >= 70 && LA60_0 <= 71)||LA60_0==77||(LA60_0 >= 79 && LA60_0 <= 80)||LA60_0==82||LA60_0==85||LA60_0==92||LA60_0==94||(LA60_0 >= 97 && LA60_0 <= 98)||LA60_0==105||LA60_0==108||LA60_0==111||LA60_0==115||LA60_0==118||LA60_0==126) ) {
				alt60=2;
			}

			else {
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 60, 0, input);
				throw nvae;
			}

			switch (alt60) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:495:7: arrayInitializer
					{
					pushFollow(FOLLOW_arrayInitializer_in_variableInitializer1507);
					arrayInitializer();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:496:9: expression
					{
					pushFollow(FOLLOW_expression_in_variableInitializer1517);
					expression();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}
		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 44, variableInitializer_StartIndex); }

		}
	}
306577
def _variable_parts(self, line, codeline):
        """"""
        var_subs = []
        # codeline has pattern and then has the outputs in different versions
        if codeline:
            var_subs = self._find_variable(codeline.pattern, line)
        else:
            # make variable part of the line string without all the other stuff
            line_str = self._strip_datetime(self._strip_counters(line))
            var_subs = [line_str.strip()]
        return var_subs
520825
private LocalVariableScope calculateScope(LocalVariableScopeData scope) {
		final TryCatchBlockLabels enclosingTry = getEnclosingTry(scope);
		final Label start = scope.labels.start;
		final Label end = getTryFixedEndLabel(scope, enclosingTry);
		
		int startIndex = getIndex(start);
		int endIndex = getIndex(end);
		
		LocalVariableScopeData.LineNumbers scopeWithLineNumbers = getLineNumbers(scope, enclosingTry, start, end);
		
		return new LocalVariableScope(scope.var, scope.name, VariableType.getByDesc(scope.desc), scopeWithLineNumbers.startLine, scopeWithLineNumbers.endLine, startIndex, endIndex, getVarReferencesBeforeStart(scope));
	}