public static void RenderExpression(StringBuilder sb, Expression exp) { bool first = true; foreach (Term t in exp.Terms) { if (first) { first = false; } else { sb.AppendFormat("{0} ", t.Seperator.HasValue ? t.Seperator.Value.ToString() : ""); } RenderTerm(sb, t); } }
void expr(out Expression exp) { exp = new Expression(); char? sep = null; Term trm = null; term(out trm); exp.Terms.Add(trm); while (la.kind == 4) { Get(); } while (StartOf(11)) { if (la.kind == 25 || la.kind == 45) { if (la.kind == 45) { Get(); sep = '/'; } else { Get(); sep = ','; } while (la.kind == 4) { Get(); } } term(out trm); if (sep.HasValue) { trm.Seperator = sep.Value; } exp.Terms.Add(trm); sep = null; while (la.kind == 4) { Get(); } } }
static string Render(Expression exp) { StringBuilder txt = new StringBuilder(); bool first = true; foreach (Term t in exp.Terms) { if (first) { first = false; } else { txt.AppendFormat("{0} ", t.Seperator.HasValue ? t.Seperator.Value.ToString() : ""); } txt.AppendFormat("<span class=\"term\">{0}</span>", Render(t)); } return txt.ToString(); }