source: branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/SourceReader.cs @ 9726

Last change on this file since 9726 was 9726, checked in by gkronber, 6 years ago

#2026 removed unused methods

File size: 992 bytes
Line 
1using System.Collections.Generic;
2using System.Linq;
3using System.Text.RegularExpressions;
4
5public class SourceReader {
6
7  private static Regex formalParameterExpr = new Regex(@"\s*,?\s*((?<refOrOut>(out|ref))\s+)?(?<type>[_\w]*)\s+(?<id>[_\w]*)\s*");
8  public static IEnumerable<TerminalNode.FieldDefinition> ExtractFormalParameters(string formalParameterSrc) {
9    var match = formalParameterExpr.Match(formalParameterSrc);
10    var matches = formalParameterExpr.Matches(formalParameterSrc);
11
12    foreach (var m in matches.OfType<Match>()) {
13      yield return new TerminalNode.FieldDefinition(m.Groups["refOrOut"].Value, m.Groups["type"].Value, m.Groups["id"].Value);
14    }
15    //var nParameters = match.Groups["id"].Captures.Count;
16    //for (int i = 0; i < nParameters; i++) {
17    //  yield return new TerminalNode.FieldDefinition(match.Groups["refOrOut"].Captures[i].Value, match.Groups["type"].Captures[i].Value, match.Groups["id"].Captures[i].Value);
18    //}
19  }
20}
Note: See TracBrowser for help on using the repository browser.