public static PatternActionCode Compile(PatternActionCode patternActionCode, Pattern pattern, string action) { if (string.IsNullOrEmpty(action)) { return(patternActionCode); } int lOpenParan = action.IndexOf('('); int lCloseParan = action.IndexOf(')'); if (lOpenParan < 0) { patternActionCode.SetErrorMessage("Action line missing an open parentheses"); return(patternActionCode); } if (lCloseParan < 0) { patternActionCode.SetErrorMessage("Action line missing a close parentheses"); return(patternActionCode); } string lName = action.Substring(0, lOpenParan).Trim(); string lValues = action.Substring(lOpenParan + 1, lCloseParan - lOpenParan - 1).Trim(); PatternFunctionParameters <Coordinate> lPatternFunctionParameters = new PatternFunctionParameters <Coordinate>(); if (!string.IsNullOrEmpty(lValues)) { string[] lParameters = lValues.Split(','); foreach (string lParameter in lParameters) { if (lParameter.Length != 1) { patternActionCode.SetErrorMessage("Invalid action function parameter: " + lParameter); return(patternActionCode); } lPatternFunctionParameters.Add(pattern.GetLetterLocation(lParameter[0])); } } PatternActionFunctions.PatternActionFunction lPatternActionFunction = PatternActionFunctions.GetFunction(lName, lPatternFunctionParameters.Count); if (lPatternActionFunction == null) { patternActionCode.SetErrorMessage("Unknown action function: " + lName + " with " + lPatternFunctionParameters.Count + " parameters"); return(patternActionCode); } patternActionCode.Add(new PatternActionOperand(lPatternActionFunction, lPatternFunctionParameters, pattern.Origin)); return(patternActionCode); }
public PatternActionOperand(PatternActionFunctions.PatternActionFunction function, PatternFunctionParameters<Coordinate> parameters, Coordinate origin) { Function = function; Parameters = parameters; Origin = origin; }