Generates an expression from a variable
@param var The variable from which to generate the expression
@return A expression that represents the given variable
509588
protected static JRDesignExpression getExpressionFromVariable(JRDesignVariable var){
		JRDesignExpression exp = new JRDesignExpression();
		exp.setText("$V{" + var.getName() + "}");
		exp.setValueClass(var.getValueClass());
		return exp;
	}
520350
def _transform(self, var):
        '''  '''
        self.collection.variables.pop(var.name)
        return var.values
65750
private VarNamePattern getValidVarNamePattern( String varNamePattern) throws IllegalArgumentException
    {
    VarNamePattern pattern = new VarNamePattern( varNamePattern);
    if( !pattern.isValid())
      {
      throw new IllegalArgumentException( "\"" + pattern + "\" is not a valid variable name pattern");
      }

    return pattern;
    }
1155658
def p_expression_invar(self, p):
        '''  
        '''
        _LOGGER.debug("expresion -> expresion IN VAR")
    
        if p[3] not in self._VAR_VALUES:
            if self._autodefine_vars:
                self._VAR_VALUES[p[3]] = TypedList([])
            else:
                raise TypeError("list expected for IN operator")
            
        l = self._VAR_VALUES[p[3]]
        if l.type != TypedList.LIST: raise TypeError("list expected for IN operator")
        p[3] = l
        
        self.p_expression_inlist(p)
61380
public int getID(Variable var) {
		Variable[] vars = this.getVariables();
		for (int i = 0; i < vars.length; i++) {
			if (vars[i].equals(var)) return i;
		}
		return -1;
	}
826487
private static String resolveVariableExpression(final String value, final int last,
      final JexlEngine jexl) {
    final int lastIndex = value.lastIndexOf("$(", last);
    if (lastIndex == -1) {
      return value;
    }

    // Want to check that everything is well formed, and that
    // we properly capture $( ...(...)...).
    int bracketCount = 0;
    int nextClosed = lastIndex + 2;
    for (; nextClosed < value.length(); ++nextClosed) {
      if (value.charAt(nextClosed) == '(') {
        bracketCount++;
      } else if (value.charAt(nextClosed) == ')') {
        bracketCount--;
        if (bracketCount == -1) {
          break;
        }
      }
    }

    if (nextClosed == value.length()) {
      throw new IllegalArgumentException("Expression " + value
          + " not well formed.");
    }

    final String innerExpression = value.substring(lastIndex + 2, nextClosed);
    Object result = null;
    try {
      final Expression e = jexl.createExpression(innerExpression);
      result = e.evaluate(new MapContext());
    } catch (final JexlException e) {
      throw new IllegalArgumentException("Expression " + value
          + " not well formed. " + e.getMessage(), e);
    }

    if (result == null) {
      // for backward compatibility it is best to return value
      return value;
    }

    final String newValue =
        value.substring(0, lastIndex) + result.toString()
            + value.substring(nextClosed + 1);
    return resolveVariableExpression(newValue, lastIndex, jexl);
  }
1227953
private Expression generateSingleMsgVariable(MsgNode msgNode, String tmpVarName) {
    String googMsgVarName = buildGoogMsgVarNameHelper(msgNode);

    // Generate the goog.getMsg call.
    GoogMsgCodeGenInfo googMsgCodeGenInfo = genGoogGetMsgCallHelper(googMsgVarName, msgNode);

    if (!msgNode.isPlrselMsg()) {
      // No postprocessing is needed. Simply use the original goog.getMsg var.
      return googMsgCodeGenInfo.googMsgVar;
    }
    // For plural/select messages, generate the goog.i18n.MessageFormat call.
    // We don't want to output the result of goog.getMsg() directly. Instead, we send that
    // string to goog.i18n.MessageFormat for postprocessing. This postprocessing is where we're
    // handling all placeholder replacements, even ones that have nothing to do with
    // plural/select.
    return VariableDeclaration.builder(tmpVarName)
        .setRhs(getMessageFormatCall(googMsgCodeGenInfo))
        .build()
        .ref();
  }
1357895
private WyalFile.VariableDeclaration[] generateLoopInvariantParameterDeclarations(Stmt.Loop loop,
			LocalEnvironment environment) {
		// Extract all used variables within the loop invariant. This is necessary to
		// determine what parameters are required for the loop invariant macros.
		Tuple<Decl.Variable> modified = determineUsedVariables(loop.getInvariant());
		WyalFile.VariableDeclaration[] vars = new WyalFile.VariableDeclaration[modified.size()];
		// second, set initial environment
		for (int i = 0; i != modified.size(); ++i) {
			WyilFile.Decl.Variable var = modified.get(i);
			vars[i] = environment.read(var);
		}
		return vars;
	}
326330
protected void parseBindVariable() {
        String expr = tokenizer.getToken();
        peek().addChild(new BindVariableNode(expr, beanDescFactory));
    }
301968
public VarValueDef getBinding( VarDef var)
    {
    VarBindingDef binding = bindings_.get( var);
    return
      binding == null
      ? null
      : binding.getValueDef();
    }
894321
public String[] getVariables()
    {
        if (variables == null)
        {
            variables = new LinkedHashSet<String>();
            for (Expression e : getExpressions())
            {
                for (VarSpec v : e.getVarSpecs())
                {
                    variables.add(v.getVariableName());
                }
            }
        }
        return variables.toArray(new String[variables.size()]);
    }
414589
private Context translateVariableDeclaration(WyilFile.Decl.Variable stmt, Context context) {
		if (stmt.hasInitialiser()) {
			Pair<Expr, Context> p = translateExpressionWithChecks(stmt.getInitialiser(), null, context);
			context = p.second();
			generateTypeInvariantCheck(stmt.getType(), p.first(), context);
			context = context.write(stmt, p.first());
		}
		//
		return context;
	}
673672
protected XExpression _generate(XVariableDeclaration varDeclaration, IAppendable it, IExtraLanguageGeneratorContext context) {
		final String name = it.declareUniqueNameVariable(varDeclaration, varDeclaration.getName());
		it.append(name);
		it.append(" = "); //$NON-NLS-1$
		if (varDeclaration.getRight() != null) {
			generate(varDeclaration.getRight(), it, context);
		} else if (varDeclaration.getType() != null) {
			it.append(toDefaultValue(varDeclaration.getType()));
		} else {
			it.append("None"); //$NON-NLS-1$
		}
		if (context.getExpectedExpressionType() != null) {
			it.newLine();
			it.append("return ").append(name); //$NON-NLS-1$
		}
		return varDeclaration;
	}
671900
private static Variable toVariable(final String argument)
   {
      final Variable retVal = new Variable();
      final int equalSignIndex = argument.indexOf('=');

      if (equalSignIndex == -1)
      {
         final String key = argument.substring(2);
         retVal.setKey(key);
      }
      else
      {
         final String key = argument.substring(2, equalSignIndex);
         retVal.setKey(key);
         final String value = argument.substring(equalSignIndex + 1);
         retVal.setValue(value);
      }

      return retVal;
   }
441805
@Override
    public VariableExpression visitVariableDeclaratorId(VariableDeclaratorIdContext ctx) {
        return configureAST(new VariableExpression(this.visitIdentifier(ctx.identifier())), ctx);
    }
214263
@Nonnull
    private Expression buildExpression( String str ) {
        switch( str.charAt( 0 ) ) {
            case '@':
                return new VariableExpression( reader, str );
            case '-':
                if( str.startsWith( "-@" ) ) {
                    return new FunctionExpression( reader, "-", new Operation( reader, buildExpression( str.substring( 1 ) ), (char)0 ) );
                }
                //$FALL-THROUGH$
            default:
                return new ValueExpression( reader, str );
        }
    }
532163
public static Object getVariable(PageContext pc, Collection collection, String var) throws PageException {
	StringList list = parse(pc, new ParserString(var), false);
	if (list == null) throw new InterpreterException("invalid variable declaration [" + var + "]");

	while (list.hasNextNext()) {
	    collection = Caster.toCollection(collection.get(KeyImpl.init(list.next())));
	}
	return collection.get(KeyImpl.init(list.next()));
    }