public static kindE kindE_from_PTokE(PTokE ptokE) // this does not destinguish between prop and special_prop { switch (ptokE) { case PTokE.OP_dot: return(kindE.val_field); case PTokE.OP_star: return(kindE.ref_field); case PTokE.OP_percent: return(kindE.property); case PTokE.OP_special_prop: return(kindE.property); default: throw new Exception(); } }
// there is no technical reason to have this in the same static class, since it's not an extension method, there is also little reason not to .... public static IEnumerable <PTokBase> toks_form_JSonValue(JsonArray jArr) { foreach (JsonObject jObj in jArr) { if (jObj["E"] == "Whitespace") { yield return new PTokWhitespace { len = jObj["len"] } } ; else { PTokE E = (PTokE)Enum.Parse(typeof(PTokE), jObj["E"]); yield return(new PTok { E = E, pay = jObj["pay"] }); } } }