public static List <Exp> AdjustExps(ZCParamInfo[] paramArr, List <Exp> exps) { if (!IsNeedAdjust(exps)) { return(exps); } var AdjustedArgExps = new List <Exp>(); Dictionary <string, ExpNameValue> argsDict = new Dictionary <string, ExpNameValue>(); foreach (var arg in exps) { if (arg is ExpNameValue) { ExpNameValue env = arg as ExpNameValue; argsDict.Add(env.ArgName, env); } else { throw new CCException(); } } foreach (var pi in paramArr) { string paramName = pi.ZParamName; ExpNameValue exp = argsDict[paramName]; AdjustedArgExps.Add(exp); } return(AdjustedArgExps); }
private Exp ParseNameValueExp() { Exp leftExp = ParseBinaryLogicExp(); if (tape.HasCurrent && tape.Current.IsKind(TokenKindSymbol.Colon)) { tape.MoveNext(); Exp rightExp = ParseBinaryLogicExp(); if (leftExp is ExpChain) { ExpChain chainExp = leftExp as ExpChain; if (chainExp.SubCount == 1) { object varobj = chainExp.RawElements[0]; if (varobj is LexTokenText) { LexTokenText textToken = (varobj as LexTokenText); ExpNameValue expNameValue = new ExpNameValue(this.expContext, textToken, rightExp); return(expNameValue); } else { tape.error("参数名称错误"); return(rightExp); } } else { tape.error("参数名称的长度不是1"); return(rightExp); } } else if (leftExp is ExpVarBase) { ExpVarBase leftVarExp = (leftExp as ExpVarBase); LexToken varToken = leftVarExp.VarToken; ExpNameValue expNameValue = new ExpNameValue(this.expContext, varToken, rightExp); return(expNameValue); } else { tape.error("调用过程时指定的参数名称只能是标识符"); return(rightExp); } } else { return(leftExp); } }