// a symbol-table client that finds the number of occurrences of each string // (having at least as many characters as a given threshold length) // in a sequence of strings from standard input, // then iterates through the keys to find the one that occurs the most frequently static void FrequencyCounter(ISymbolTable <string, int> st, IEnumerable <string> strings) { foreach (string s in strings) { if (st.Contains(s)) { st.Put(s, 1 + st.Get(s)); } else { st.Put(s, 1); } } }
public override void HandleViolation(ISymbolTable context, IProblemPipe problemPipe) { if (!IsViolated (context)) return; bool symbolIsUndefined = context.Contains (_symbol) && context.GetFragmentType (_symbol).Undefined; if (symbolIsUndefined) { SetSymbolFragmentType(context); } else { HandleFragmentConflict (context, problemPipe); } }
private void SetSymbolFragmentType(string name, AttributeNodeCollection attributes) { if (!_result.Contains(name)) { if (FragmentUtility.ContainsFragment(attributes)) { Fragment fragmentType = FragmentUtility.GetFragmentType(attributes); _result.MakeSafe(name, fragmentType); } else { _result.MakeUnsafe(name); } } }
public override void HandleViolation(ISymbolTable context, IProblemPipe problemPipe) { if (!IsViolated(context)) { return; } bool symbolIsUndefined = context.Contains(_symbol) && context.GetFragmentType(_symbol).Undefined; if (symbolIsUndefined) { SetSymbolFragmentType(context); } else { HandleFragmentConflict(context, problemPipe); } }
private bool ExpressionIsVariableFromPrecedingBlock(Expression operand, out string variableName) { return(IntrospectionUtility.IsVariable(operand, out variableName) && !_symbolTable.Contains(variableName)); }
private bool OperandIsVariableFromPrecedingBlock(Expression operand, ISymbolTable symbolTable, out string variableName) { return IntrospectionUtility.IsVariable (operand, out variableName) && !symbolTable.Contains (variableName); }