private Tuple <Type, Expr> Match(string groupName, FluentPart part) { var group = _matches[groupName]; var ctx = _parser.Context; var helper = new FluentPluginHelper(ctx); Expr expr = null; Type type = null; // 1. Go through all the matches in group. e.g. "class" // Note: This is at most 4 possible groups ( class, instance, property, method ) for (int ndx = 0; ndx < group.Count; ndx++) { var match = group[ndx]; Token klass = null, instance = null, method = null, prop = null; var token = _tokenIt.NextToken.Token; // 2. Go through all the matches in each group // Note: There are at most 4 matches. int lastTokenPeek = 0; for (int ndxT = 0; ndxT < match.Count; ndxT++) { part = match[ndxT]; if (part == FluentPart.Class) { klass = token; } else if (part == FluentPart.Instance) { instance = token; } else if (part == FluentPart.Method) { method = token; } else if (part == FluentPart.Prop) { prop = token; } lastTokenPeek = ndxT; token = _tokenIt.Peek(lastTokenPeek + 1, false).Token; } // Check if match. type = helper.GetType(klass, instance); if (type != null) { var result = IsMatch(helper, type, klass, instance, prop, method); // Success if (result.Item1) { expr = result.Item2; _tokenIt.Advance(lastTokenPeek + 1); break; } } } return(new Tuple <Type, Expr>(type, expr)); }
private Tuple<Type, Expr> Match(string groupName, FluentPart part) { var group = _matches[groupName]; var ctx = _parser.Context; var helper = new FluentPluginHelper(ctx); Expr expr = null; Type type = null; // 1. Go through all the matches in group. e.g. "class" // Note: This is at most 4 possible groups ( class, instance, property, method ) for (int ndx = 0; ndx < group.Count; ndx++) { var match = group[ndx]; Token klass = null, instance = null, method = null, prop = null; var token = _tokenIt.NextToken.Token; // 2. Go through all the matches in each group // Note: There are at most 4 matches. int lastTokenPeek = 0; for (int ndxT = 0; ndxT < match.Count; ndxT++) { part = match[ndxT]; if (part == FluentPart.Class) klass = token; else if (part == FluentPart.Instance) instance = token; else if (part == FluentPart.Method) method = token; else if (part == FluentPart.Prop) prop = token; lastTokenPeek = ndxT; token = _tokenIt.Peek(lastTokenPeek + 1, false).Token; } // Check if match. type = helper.GetType(klass, instance); if (type != null) { var result = IsMatch(helper, type, klass, instance, prop, method); // Success if (result.Item1) { expr = result.Item2; _tokenIt.Advance(lastTokenPeek + 1); break; } } } return new Tuple<Type, Expr>(type, expr); }