public static PatternActionCode Compile(Pattern pattern, List<string> actions) { PatternActionCode lPatternActionCode = new PatternActionCode(); if (actions != null) foreach (string lAction in actions) lPatternActionCode = Compile(lPatternActionCode, pattern, lAction); return lPatternActionCode; }
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 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 static PatternActionCode Compile(Pattern pattern, List <string> actions) { PatternActionCode lPatternActionCode = new PatternActionCode(); if (actions != null) { foreach (string lAction in actions) { lPatternActionCode = Compile(lPatternActionCode, pattern, lAction); } } return(lPatternActionCode); }
public PatternCompiled(Pattern pattern) { Pattern = pattern; PatternCode = PatternCompiler.Compile(Pattern); if (PatternCode.IsError()) { SetErrorMessage(PatternCode.GetErrorMessage()); return; } PatternInterpretor = new PatternInterpretor(PatternCode, Pattern); PatternAttribute = new PatternAttribute(Pattern.PatternAttributes); if (PatternAttribute.IsError()) { SetErrorMessage(PatternAttribute.GetErrorMessage()); return; } PatternActionAttribute = new PatternActionAttribute(Pattern.ClassificationAttributes); if (PatternActionAttribute.IsError()) { SetErrorMessage(PatternActionAttribute.GetErrorMessage()); return; } PatternConstraintAttribute = new PatternConstraintAttribute(Pattern.ClassificationAttributes); if (PatternConstraintAttribute.IsError()) { SetErrorMessage(PatternConstraintAttribute.GetErrorMessage()); return; } PatternActionCode = PatternActionCompiler.Compile(pattern, pattern.ActionCode); if (PatternActionCode.IsError()) { SetErrorMessage(PatternActionCode.GetErrorMessage()); return; } OptimalDFATransformation = FindMinimizedDFATransformation(); }
public static PatternActionCode Compile(Pattern pattern, string actions) { PatternActionCode lPatternActionCode = new PatternActionCode(); return Compile(lPatternActionCode, pattern, actions); }
public static PatternActionCode Compile(Pattern pattern, string actions) { PatternActionCode lPatternActionCode = new PatternActionCode(); return(Compile(lPatternActionCode, pattern, actions)); }