Expression ParseAtom() { string id; Expression x = null; FunctionDefinition fnDef = null; switch (_token.Type) { // literals case TKTYPE.LITERAL: x = new Expression(_token); break; // identifiers case TKTYPE.IDENTIFIER: // get identifier id = (string)_token.Value; // look for functions if (_fnTbl.TryGetValue(id, out fnDef)) { var p = GetParameters(); var pCnt = p == null ? 0 : p.Count; if (fnDef.ParmMin != -1 && pCnt < fnDef.ParmMin) { Throw("Too few parameters."); } if (fnDef.ParmMax != -1 && pCnt > fnDef.ParmMax) { Throw("Too many parameters."); } x = new FunctionExpression(fnDef, p); break; } // look for simple variables (much faster than binding!) if (_vars.ContainsKey(id)) { x = new VariableExpression(_vars, id); break; } // look for external objects var xObj = GetExternalObject(id); if (xObj != null) { x = new XObjectExpression(xObj); break; } // look for bindings if (DataContext != null) { var list = new List <BindingInfo>(); for (var t = _token; t != null; t = GetMember()) { list.Add(new BindingInfo((string)t.Value, GetParameters())); } x = new BindingExpression(this, list, _ci); break; } Throw("Unexpected identifier"); break; // sub-expressions case TKTYPE.GROUP: // anything other than opening parenthesis is illegal here if (_token.ID != TKID.OPEN) { Throw("Expression expected."); } // get expression GetToken(); x = ParseCompare(); // check that the parenthesis was closed if (_token.ID != TKID.CLOSE) { Throw("Unbalanced parenthesis."); } break; } // make sure we got something... if (x == null) { Throw(); } // done GetToken(); return(x); }
void _observer_OnPostEvaluate(object sender, EvaluateEventArgs e) { if (_maxLevel >= 0 && _DependencyDepth > _maxLevel) { return; } if (_suppressLevel >= 0 && _DependencyDepth >= _suppressLevel) { return; } if (e.Expression._token.Type == TKTYPE.LITERAL) { return; } if (e.Expression._token.ID == TKID.SUPPRESS) { return; } if (e.Expression is VariableExpression) { if (!this.AuditVariables) { return; } var v = e.Expression as VariableExpression; if ((v.Variable != null) && !v.Variable.CreateAudit) { return; } } if (e.Expression is FunctionExpression) { FunctionExpression func = e.Expression as FunctionExpression; if (!func._fn.Audited) { return; } } StringBuilder auditBuilder = new StringBuilder(); auditBuilder.Append(e.Expression.ToString()); auditBuilder.Append(" = "); if (e.Value != null) { if (e.Value is IEnumerable) { Expression.BuildParameterList(auditBuilder, e.Value as IEnumerable, sb => sb.AppendLine(",")); } else { auditBuilder.Append(e.Value.ToString()); } } auditBuilder.AppendLine(); string auditText = auditBuilder.ToString(); if (_auditHashes.Add(auditText)) { _stringBuilder.Append(auditText); } }