public override void Write(TemplateEngine engine, StringBuilder line, int depth, StringBuilder preallocInit, ref int pmIndex) { bool useRangeResult = (bool)engine.GetVariable("pass-action-uses-userangeresult"); string chars = Chars.Length > 0 ? "\"" + Chars.EscapeAll().Replace("\\]", "]").Replace("\"", "\\\"") + "\"" : "string.Empty"; string ranges = Ranges.Length > 0 ? "\"" + DoEscape(Ranges).Replace("\"", "\\\"") + "\"" : "string.Empty"; if (depth == 0) { line.AppendFormat("_state = DoParseRange(_state, {0}, {1}, {2}, {3}, {4}, \"{5}\")", useRangeResult ? "results" : "null", Inverted ? "true" : "false", chars, ranges, Categories, this); } else { string s = depth == 1 ? "s" : ("s" + depth); string r = depth == 1 ? "r" : ("r" + depth); string t = new string('\t', 2 + depth); line.AppendLine(); line.Append(t); ++pmIndex; line.AppendFormat("m_ParseMethod{0}", pmIndex); preallocInit.AppendFormat("\t\tm_ParseMethod{0} = (ParseMethod)delegate (State {1}, List<Result> {2}) {{return DoParseRange({1}, {8}, {3}, {4}, {5}, {6}, \"{7}\");}}", pmIndex, s, r, Inverted ? "true" : "false", chars, ranges, Categories, this, useRangeResult ? r : "null"); preallocInit.AppendLine(";"); } }
public override void Write(TemplateEngine engine, StringBuilder line, int depth, StringBuilder preallocInit, ref int pmIndex) { bool useLiteralResult = (bool)engine.GetVariable("pass-action-uses-useliteralresult"); if (depth == 0) { line.AppendFormat("_state = DoParseLiteral(_state, {0}, \"{1}\")", useLiteralResult ? "results" : "null", Literal.Replace("\"", "\\\"")); } else { string s = depth == 1 ? "s" : ("s" + depth); string r = depth == 1 ? "r" : ("r" + depth); string t = new string('\t', 2 + depth); line.AppendLine(); line.Append(t); ++pmIndex; line.AppendFormat("m_ParseMethod{0}", pmIndex); preallocInit.AppendFormat("\t\tm_ParseMethod{0} = (ParseMethod)delegate (State {1}, List<Result> {2}) {{return DoParseLiteral({1}, {4}, \"{3}\");}}", pmIndex, s, r, Literal.Replace("\"", "\\\""), useLiteralResult ? r : "null"); preallocInit.AppendLine(";"); } }