//Adds a single context to the grammar string. private void AddContext(IroContext ctx, IroPrecompileData data, ref PyStringMaker text) { //Open the context. text.AppendLine("'" + ctx.Name + "' : ["); text.TabIn(); //Add context members. foreach (var member in ctx.Members) { AddContextMember(ctx.Name, member, data, ref text); } text.TrimEnd(',', ' '); text.TabOut(); text.AppendLine("],"); }
//Adds a queued context to the text. private void AddQueuedContext(string name, string originalCtx, InlinePushContextMember ilp, IroPrecompileData data, ref PyStringMaker text) { //Open the context. text.AppendLine("'" + name + "' : ["); text.TabIn(); //Add the pop rule. var popStyles = GetPatternStyles(ilp.PopStyles, data); text.AppendLine("(u'" + ilp.PopData.Replace("\\", "\\\\") + "', byGroups(" + string.Join(", ", popStyles.Select(x => x.PygmentsScope)).TrimEnd(',', ' ') + "), '" + originalCtx + "')"); //Add context members. includedThisRun = new List <string>(); foreach (var member in ilp.Patterns) { AddContextMember(name, member, data, ref text); } text.TrimEnd(',', ' '); text.TabOut(); text.AppendLine("],"); }