public string get_ascent_types() //タイプを遡って纏めて文字列化。listの先頭のみが対象 { string s = null; Action <VALUE> printtype = null; printtype = (v) => { if (v == null) { return; } if (s != null) { s += "-"; } s += YDEF.get_name(v.type); if (v.list != null && v.list.Count > 0) { printtype(v.list[0]); } }; printtype(this); return(s); }
public override string ToString() { string s = null; s += type.ToString() + ":" + YDEF.get_name(type); return(s + ":" + (o != null ? o.ToString() : "null")); }
public static bool Analyze(List <VALUE> src, out List <VALUE> dst) { const int LOOPMAX = 10000; dst = new List <VALUE>(src); var list = new List <VALUE>(src); for (int loop = 0; loop <= LOOPMAX; loop++) { if (loop == LOOPMAX) { sys.error("yanalyzer Analyze LoopMax:1"); } var syntax_order = YDEF.get_syntax_order(); bool bNeedLoop = false; for (int i = 0; i < syntax_order.Count; i++) { var syntax = syntax_order[i]; var tslist = YDEF.get_syntax_set(syntax); foreach (var ts in tslist) { if (_check_syntax(dst, ts)) { bNeedLoop = true; break; } } if (bNeedLoop) { break; //最初から } } if (!bNeedLoop) { break; } } return(true); }
private static int getyp(object[] o) { return(YDEF.get_type(o)); }
// -- util -- private static string gn(object[] o) { return(YDEF.get_name(o)); }
public List <List <VALUE> > PreProcess(List <List <VALUE> > src) { Hashtable ht = new Hashtable(); //変数用 var out_list = new List <List <VALUE> >(); bool bIfZone = false; bool?bIfTree = null; foreach (var l in src) { if (l.Count == 0) { continue; } VALUE v0 = l[0]; if (v0.IsType(getyp(YDEF.sx_prepro_setence))) //#if #elif #else #endif { if (v0.IsType(getyp(YDEF.sx_pif_sentence))) //#if { if (bIfZone) { sys.error("Not supported Dual #if"); } bIfZone = true; var func = find(v0, YDEF.sx_function); if (func == null) { sys.error("Can not find function for #if", v0); } bIfTree = runtime.PreProcessFunction.Execute(func); continue; } if (v0.IsType(getyp(YDEF.sx_pelif_sentence)))//#elif { if (!bIfZone) { sys.error("Preceed #if does not exist", v0); } if (bIfTree == true) { bIfTree = null; } if (bIfTree == null) { sys.logline("skip"); } var func = find(v0, YDEF.sx_function); if (func == null) { sys.error("Can not find function for #elif", v0); } bIfTree = runtime.PreProcessFunction.Execute(func); continue; } if (v0.IsType(getyp(YDEF.sx_pelse_sentence)))//else { if (!bIfZone) { sys.error("Preceed #if does not exist", v0); } if (bIfTree == true) { bIfTree = null; } if (bIfTree == null) { sys.logline("skip"); } else { bIfTree = true; } continue; } if (v0.IsType(getyp(YDEF.sx_pendif_sentence)))//endif { if (!bIfZone) { sys.error("Preceed #if does not exist", v0); } bIfZone = false; bIfTree = null; continue; } if (v0.IsType(getyp(YDEF.sx_pset_sentence)))//set { //#set will process later. } else //以外はエラー { sys.error("Unexpected", v0); } } if (bIfZone == false || (bIfZone == true && bIfTree == true)) { if (v0.IsType(getyp(YDEF.sx_pset_sentence))) { var varv = find(v0, YDEF.VAR); if (varv == null) { sys.error("Cannot find set variable", v0); } var rest = find(v0, YDEF.REST); if (rest == null) { sys.error("Cannot find set rest", v0); } ht[varv.GetString()] = rest; continue; } var findvar = find_l(l, YDEF.VAR); if (findvar != null) { var key = findvar.GetString(); if (ht.ContainsKey(key)) { if (!replace_l(l, YDEF.VAR, (VALUE)ht[key])) { sys.error("Cannot converted", v0); } } else { sys.error(key + " has not been defined", v0); } } var newl = l; YDEF.insert_rest_children_if_use(ref newl); out_list.Add(newl); } } dbg_out_list = out_list; return(out_list); }
public string get_type_name() { return(YDEF.get_name(type)); }
public bool IsType(string s) { int tp = YDEF.get_type(s); return(IsType(tp)); }