public override void Emit(SourceBuilder sourceCode) { if (InParallelizedBody) { sourceCode.AppendFrontFormat("{0}.{1} match = parallelTaskMatches[threadId].GetNextUnfilledPosition();\n", RulePatternClassName, NamesOfEntities.MatchClassName(PatternName)); } else { sourceCode.AppendFrontFormat("{0}.{1} match = matches.GetNextUnfilledPosition();\n", RulePatternClassName, NamesOfEntities.MatchClassName(PatternName)); } // emit match building operations MatchBuildingOperations.Emit(sourceCode); if (InParallelizedBody) { sourceCode.AppendFront("match.IterationNumber = currentIterationNumber;\n"); sourceCode.AppendFront("parallelTaskMatches[threadId].PositionWasFilledFixIt();\n"); } else { sourceCode.AppendFront("matches.PositionWasFilledFixIt();\n"); } }
public override void Emit(SourceBuilder sourceCode) { sourceCode.AppendFront("Stack<GRGEN_LIBGR.IMatch> currentFoundPartialMatch = new Stack<GRGEN_LIBGR.IMatch>();\n"); sourceCode.AppendFront("foundPartialMatches.Add(currentFoundPartialMatch);\n"); sourceCode.AppendFrontFormat("{0}.{1} match = new {0}.{1}();\n", RulePatternClassName, NamesOfEntities.MatchClassName(PatternName)); if (IsIteratedNullMatch) { sourceCode.AppendFront("match._isNullMatch = true; // null match of iterated pattern\n"); } else { MatchBuildingOperations.Emit(sourceCode); // emit match building operations } sourceCode.AppendFront("currentFoundPartialMatch.Push(match);\n"); }
public override void Emit(SourceBuilder sourceCode) { if (Type == PatternAndSubpatternsMatchedType.Iterated) { sourceCode.AppendFront("patternFound = true;\n"); } if (Type != PatternAndSubpatternsMatchedType.Action) { if (sourceCode.CommentSourceCode) { sourceCode.AppendFront("// subpatterns/alternatives were found, extend the partial matches by our local match object\n"); } sourceCode.AppendFront("foreach(Stack<GRGEN_LIBGR.IMatch> currentFoundPartialMatch in matchesList)\n"); sourceCode.AppendFront("{\n"); sourceCode.Indent(); sourceCode.AppendFrontFormat("{0}.{1} match = new {0}.{1}();\n", RulePatternClassName, NamesOfEntities.MatchClassName(PatternName)); if (Type == PatternAndSubpatternsMatchedType.IteratedNullMatch) { sourceCode.AppendFront("match._isNullMatch = true; // null match of iterated pattern\n"); } MatchBuildingOperations.Emit(sourceCode); // emit match building operations sourceCode.AppendFront("currentFoundPartialMatch.Push(match);\n"); sourceCode.Unindent(); sourceCode.AppendFront("}\n"); } else // top-level pattern with subpatterns/alternatives { if (sourceCode.CommentSourceCode) { sourceCode.AppendFront("// subpatterns/alternatives were found, extend the partial matches by our local match object, becoming a complete match object and save it\n"); } sourceCode.AppendFront("foreach(Stack<GRGEN_LIBGR.IMatch> currentFoundPartialMatch in matchesList)\n"); sourceCode.AppendFront("{\n"); sourceCode.Indent(); if (InParallelizedBody) { sourceCode.AppendFrontFormat("{0}.{1} match = parallelTaskMatches[threadId].GetNextUnfilledPosition();\n", RulePatternClassName, NamesOfEntities.MatchClassName(PatternName)); } else { sourceCode.AppendFrontFormat("{0}.{1} match = matches.GetNextUnfilledPosition();\n", RulePatternClassName, NamesOfEntities.MatchClassName(PatternName)); } MatchBuildingOperations.Emit(sourceCode); // emit match building operations if (InParallelizedBody) { sourceCode.AppendFront("match.IterationNumber = currentIterationNumber;\n"); sourceCode.AppendFront("parallelTaskMatches[threadId].PositionWasFilledFixIt();\n"); } else { sourceCode.AppendFront("matches.PositionWasFilledFixIt();\n"); } sourceCode.Unindent(); sourceCode.AppendFront("}\n"); sourceCode.AppendFront("matchesList.Clear();\n"); } }