mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.3.1
This commit is contained in:
@@ -31,7 +31,7 @@ public class GfmlLxr_ {
|
||||
public static final GfmlLxr Null = new GfmlLxr_null();
|
||||
public static final String CmdTknChanged_evt = "Changed";
|
||||
public static GfmlLxr as_(Object obj) {return obj instanceof GfmlLxr ? (GfmlLxr)obj : null;}
|
||||
public static GfmlLxr cast_(Object obj) {try {return (GfmlLxr)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfmlLxr.class, obj);}}
|
||||
public static GfmlLxr cast_(Object obj) {try {return (GfmlLxr)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfmlLxr.class, obj);}}
|
||||
}
|
||||
class GfmlLxr_null implements GfmlLxr {
|
||||
public String Key() {return "gfml.nullLxr";}
|
||||
@@ -95,7 +95,7 @@ class GfmlLxr_group implements GfmlLxr {
|
||||
}
|
||||
public GfmlLxr SubLxr() {throw Err_sublxr();}
|
||||
public void SubLxr_Add(GfmlLxr... lexer) {throw Err_sublxr();}
|
||||
Exc Err_sublxr() {return Exc_.new_unimplemented_w_msg("group lxr does not have subLxrs", "key", key, "output_tkn", outputTkn.Raw()).Stack_erase_1_();}
|
||||
Err Err_sublxr() {return Err_.new_unimplemented_w_msg("group lxr does not have subLxrs", "key", key, "output_tkn", outputTkn.Raw()).Trace_ignore_add_1_();}
|
||||
GfmlTrie trie = GfmlTrie.new_(); String_bldr sb = String_bldr_.new_(); boolean ignoreOutput;
|
||||
public static GfmlLxr_group new_(String key, String[] hooks, GfmlTkn outputTkn, boolean ignoreOutput) {
|
||||
GfmlLxr_group rv = new GfmlLxr_group();
|
||||
@@ -213,5 +213,5 @@ class GfmlLxr_frame extends GfmlLxr_singleton { GfmlFrame frame; GfmlLxr endLxr
|
||||
return rv;
|
||||
} GfmlLxr_frame() {}
|
||||
public static GfmlLxr_frame as_(Object obj) {return obj instanceof GfmlLxr_frame ? (GfmlLxr_frame)obj : null;}
|
||||
public static GfmlLxr_frame cast_(Object obj) {try {return (GfmlLxr_frame)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfmlLxr_frame.class, obj);}}
|
||||
public static GfmlLxr_frame cast_(Object obj) {try {return (GfmlLxr_frame)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfmlLxr_frame.class, obj);}}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,6 @@ class GfmlTkn_composite implements GfmlTkn {
|
||||
public String Val() {return GfmlTknAry_.XtoVal(ary);}
|
||||
public GfmlBldrCmd Cmd_of_Tkn() {return GfmlBldrCmd_.Null;}
|
||||
public GfmlTkn[] SubTkns() {return ary;} GfmlTkn[] ary;
|
||||
public GfmlTkn MakeNew(String rawNew, String valNew) {throw Exc_.new_unimplemented_w_msg(".MakeNew cannot be invoked on GfmlTkn_composite (raw is available, but not val)", "tknType", tknType, "rawNew", rawNew, "valNew", valNew);}
|
||||
public GfmlTkn MakeNew(String rawNew, String valNew) {throw Err_.new_unimplemented_w_msg(".MakeNew cannot be invoked on GfmlTkn_composite (raw is available, but not val)", "tknType", tknType, "rawNew", rawNew, "valNew", valNew);}
|
||||
@gplx.Internal protected GfmlTkn_composite(String tknType, GfmlTkn[] ary) {this.tknType = tknType; this.ary = ary;}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GfmlTrie {
|
||||
return result;
|
||||
}
|
||||
public void Add(String symbol, Object data) {
|
||||
if (data == null) throw Exc_.new_("null objects cannot be registered", "symbol", symbol);
|
||||
if (data == null) throw Err_.new_wo_type("null objects cannot be registered", "symbol", symbol);
|
||||
|
||||
char[] ary = String_.XtoCharAry(symbol); int lastIndex = ary.length - 1;
|
||||
IntObjHash_base curLink = rootLink;
|
||||
|
||||
@@ -20,7 +20,7 @@ class IntObjHash_base {
|
||||
public int Count() {return count;} int count;
|
||||
public boolean Has(int key) {return Get_by(key) != null;}
|
||||
public Object Get_by(int key) {
|
||||
if (key < 0) throw Exc_.new_("key must be >= 0", "key", key);
|
||||
if (key < 0) throw Err_.new_wo_type("key must be >= 0", "key", key);
|
||||
if (key > maxKey) return null;
|
||||
Object[] subAry = FetchSubAry(key);
|
||||
return subAry == null ? null : subAry[subIdx];
|
||||
@@ -40,8 +40,8 @@ class IntObjHash_base {
|
||||
maxKey = -1;
|
||||
}
|
||||
void PutObjAtKey(int key, Object obj, boolean isAdd) {
|
||||
if (key < 0) throw Exc_.new_("key must be >= 0", "key", key);
|
||||
if (obj == null) throw Exc_.new_("Object cannot be null; call .Del on key instead", "key", key);
|
||||
if (key < 0) throw Err_.new_wo_type("key must be >= 0", "key", key);
|
||||
if (obj == null) throw Err_.new_wo_type("Object cannot be null; call .Del on key instead", "key", key);
|
||||
if (key > maxKey) ExpandRootAry(key);
|
||||
Object[] subAry = FetchSubAry(key);
|
||||
if (subAry == null) {
|
||||
@@ -49,8 +49,8 @@ class IntObjHash_base {
|
||||
rootAry[rootIdx] = subAry;
|
||||
}
|
||||
Object curVal = subAry[subIdx];
|
||||
if ( isAdd && curVal != null) throw Exc_.new_(".Add cannot be called on non-null vals; call .Set instead", "key", key, "val", curVal);
|
||||
if (!isAdd && curVal == null) throw Exc_.new_(".Set cannot be called on null vals; call .Add instead", "key", key);
|
||||
if ( isAdd && curVal != null) throw Err_.new_wo_type(".Add cannot be called on non-null vals; call .Set instead", "key", key, "val", curVal);
|
||||
if (!isAdd && curVal == null) throw Err_.new_wo_type(".Set cannot be called on null vals; call .Add instead", "key", key);
|
||||
subAry[subIdx] = obj;
|
||||
if (isAdd) count++;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ public class GfmlFldList {
|
||||
public GfmlFld Get_at(int index) {return (GfmlFld)hash.Get_at(index);}
|
||||
public GfmlFld Get_by(String id) {return (GfmlFld)hash.Get_by(id);}
|
||||
public void Add(GfmlFld fld) {
|
||||
if (String_.Len_eq_0(fld.Name())) throw Exc_.new_("fld name cannot be null");
|
||||
if (hash.Has(fld.Name())) throw Exc_.new_("key already exists", "key", fld.Name()); // FIXME: commented out to allow multiple types with same name; need "_type:invk"
|
||||
if (String_.Len_eq_0(fld.Name())) throw Err_.new_wo_type("fld name cannot be null");
|
||||
if (hash.Has(fld.Name())) throw Err_.new_wo_type("key already exists", "key", fld.Name()); // FIXME: commented out to allow multiple types with same name; need "_type:invk"
|
||||
hash.Add_if_dupe_use_nth(fld.Name(), fld);
|
||||
}
|
||||
public void Del(GfmlFld fld) {
|
||||
|
||||
@@ -19,8 +19,8 @@ package gplx.gfml; import gplx.*;
|
||||
class GfmlTypeHash {
|
||||
public GfmlType Get_by(String key) {return (GfmlType)hash.Get_by(key);}
|
||||
public void Add(GfmlType type) {
|
||||
if (type.IsTypeNull()) throw Exc_.new_("cannot add null type to GfmlTypeHash");
|
||||
if (hash.Has(type.Key())) throw Exc_.new_("type key already exists", "key", type.Key());
|
||||
if (type.IsTypeNull()) throw Err_.new_wo_type("cannot add null type to GfmlTypeHash");
|
||||
if (hash.Has(type.Key())) throw Err_.new_wo_type("type key already exists", "key", type.Key());
|
||||
hash.Add(type.Key(), type);
|
||||
}
|
||||
Hash_adp hash = Hash_adp_.new_();
|
||||
@@ -30,7 +30,7 @@ class GfmlTypRegy {
|
||||
public boolean Has(String typeKey) {return hash.Has(typeKey);}
|
||||
public GfmlType FetchOrNull(String typeKey) {return FetchOrNull(typeKey, GfmlDocPos_.Root);}
|
||||
public GfmlType FetchOrNull(String typeKey, GfmlDocPos pos) {
|
||||
if (typeKey == null) throw Exc_.new_("typeKey cannot be null when added to typRegy");
|
||||
if (typeKey == null) throw Err_.new_wo_type("typeKey cannot be null when added to typRegy");
|
||||
GfmlType rv = (GfmlType)hash.Get_by(typeKey, pos);
|
||||
return rv == null ? GfmlType_.Null : rv;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class GfmlTypeMgr {
|
||||
else
|
||||
typKey = ndeHnd;
|
||||
}
|
||||
if (typKey == null) throw Exc_.new_("could not identity type for node", "ndeKey", ndeKey, "ndeHnd", ndeHnd, "typKey", nde.Type().Key());
|
||||
if (typKey == null) throw Err_.new_wo_type("could not identity type for node", "ndeKey", ndeKey, "ndeHnd", ndeHnd, "typKey", nde.Type().Key());
|
||||
rv = typeRegy.FetchOrNull(typKey, nde.DocPos());
|
||||
return (rv == GfmlType_.Null)
|
||||
? GfmlType_.new_any_() // unknown typeKey; name is not known (see EX:2) -> create new anyType
|
||||
|
||||
@@ -35,8 +35,8 @@ class GfmlUsrMsgs {
|
||||
um.Add("errorPos", bldr.StreamPos());
|
||||
um.Add("errorHighlight", String_.CrLf + String_.Concat_lines_crlf(sh.Gen()));
|
||||
}
|
||||
public static Exc gfmlParseError(GfmlBldr bldr) {
|
||||
Exc rv = Exc_.new_("gfml parse error");
|
||||
public static Err gfmlParseError(GfmlBldr bldr) {
|
||||
Err rv = Err_.new_wo_type("gfml parse error");
|
||||
for (int i = 0; i < bldr.Doc().UsrMsgs().Count(); i++) {
|
||||
UsrMsg um = (UsrMsg)bldr.Doc().UsrMsgs().Get_at(i);
|
||||
rv.Args_add("err" + Int_.Xto_str(i), um.XtoStr());
|
||||
|
||||
@@ -27,7 +27,7 @@ public class GfmlItmKeys {
|
||||
}
|
||||
public String FetchDataOrNull(String key) {return FetchDataOr(key, null);}
|
||||
public String FetchDataOrFail(String key) {
|
||||
GfmlAtr atr = FetchAtr(key); if (atr == null) throw Exc_.new_missing_key(key);
|
||||
GfmlAtr atr = FetchAtr(key); if (atr == null) throw Err_.new_missing_key(key);
|
||||
return atr.DatTkn().Val();
|
||||
}
|
||||
public GfmlTkn FetchDataTknOrNull(String key) {
|
||||
|
||||
@@ -32,7 +32,7 @@ class GfmlPragmaDefault implements GfmlPragma {
|
||||
return list;
|
||||
}
|
||||
@gplx.Internal protected void CompileSubNde(GfmlNde nde, List_adp list) {
|
||||
String typeKey = nde.SubKeys().FetchDataOrNull("typeKey"); if (typeKey == null) throw Exc_.new_missing_key("typeKey");
|
||||
String typeKey = nde.SubKeys().FetchDataOrNull("typeKey"); if (typeKey == null) throw Err_.new_missing_key("typeKey");
|
||||
for (int i = 0; i < nde.SubHnds().Count(); i++) {
|
||||
GfmlNde subNde = (GfmlNde)nde.SubHnds().Get_at(i);
|
||||
GfmlDefaultItem item = CompileItem(subNde, typeKey);
|
||||
@@ -96,7 +96,7 @@ class GfmlDefaultPragma_bgnCmd implements GfmlBldrCmd {
|
||||
GfmlDefaultItem item = (GfmlDefaultItem)itemObj;
|
||||
if (!String_.Eq(item.TypeKey(), type.Key())) {
|
||||
type = regy.FetchOrNull(item.TypeKey(), pos);
|
||||
if (type == GfmlType_.Null) throw Exc_.new_("default type must exist", "typeKey", item.TypeKey());
|
||||
if (type == GfmlType_.Null) throw Err_.new_wo_type("default type must exist", "typeKey", item.TypeKey());
|
||||
}
|
||||
type = type.Clone().DocPos_(pos);
|
||||
regy.Add(type);
|
||||
@@ -119,7 +119,7 @@ class GfmlDefaultPragma_endCmd implements GfmlBldrCmd {
|
||||
GfmlDefaultItem item = (GfmlDefaultItem)itemObj;
|
||||
if (!String_.Eq(item.TypeKey(), type.Key())) {
|
||||
type = regy.FetchOrNull(item.TypeKey());
|
||||
if (type == GfmlType_.Null) throw Exc_.new_("fatal: default type must exist", "typeKey", item.TypeKey());
|
||||
if (type == GfmlType_.Null) throw Err_.new_wo_type("fatal: default type must exist", "typeKey", item.TypeKey());
|
||||
}
|
||||
item.Exec_end(type);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class GfmlPragmaLxrFrm implements GfmlPragma {
|
||||
bldr.Doc().RootLxr().SubLxr_Add(lxr); // FIXME: always add to cur lxr; should be outside if block; also, auto_add=n to skip adding to rootLxr
|
||||
}
|
||||
else {
|
||||
GfmlLxr_frame frameLxr = GfmlLxr_frame.as_(lxr); if (frameLxr == null) throw Exc_.new_("lxr is not GfmlLxr_frame", "key", key, "type", ClassAdp_.NameOf_obj(lxr));
|
||||
GfmlLxr_frame frameLxr = GfmlLxr_frame.as_(lxr); if (frameLxr == null) throw Err_.new_wo_type("lxr is not GfmlLxr_frame", "key", key, "type", ClassAdp_.NameOf_obj(lxr));
|
||||
if (type != null) {
|
||||
// frame = frameLxr.Frame.MakeNew(frameLxr);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class GfmlVarTkn implements GfmlTkn {
|
||||
} String val;
|
||||
public GfmlBldrCmd Cmd_of_Tkn() {return GfmlBldrCmd_.Null;}
|
||||
public GfmlTkn[] SubTkns() {return ary;} GfmlTkn[] ary;
|
||||
public GfmlTkn MakeNew(String rawNew, String valNew) {throw Exc_.new_invalid_op("makeNew cannot make copy of token with only raw").Args_add("key", key, "rawNew", rawNew, "valNew", valNew);}
|
||||
public GfmlTkn MakeNew(String rawNew, String valNew) {throw Err_.new_invalid_op("makeNew cannot make copy of token with only raw").Args_add("key", key, "rawNew", rawNew, "valNew", valNew);}
|
||||
public String TknType() {return "evalTkn";}
|
||||
|
||||
GfmlVarCtx ctx; String varKey;
|
||||
|
||||
@@ -69,7 +69,7 @@ class GfmlFrame_eval extends GfmlFrame_base {
|
||||
static String[] ExtractContextKey(String raw) {
|
||||
String[] ary = String_.Split(raw, ".");
|
||||
if (ary.length == 2) return ary; // NOOP: elems already assigned; context = ary[0]; key = ary[1];
|
||||
if (ary.length > 2) throw Exc_.new_("invalid context key for eval frame; should have 0 or 1 dlms", "key", raw);
|
||||
if (ary.length > 2) throw Err_.new_wo_type("invalid context key for eval frame; should have 0 or 1 dlms", "key", raw);
|
||||
String[] rv = new String[2];
|
||||
rv[0] = GfmlVarCtx_.DefaultKey;
|
||||
rv[1] = ary[0];
|
||||
|
||||
@@ -23,5 +23,5 @@ public class GfmlDataWtrOpts {
|
||||
public boolean IgnoreNullNames() {return ignoreNullNames;} public GfmlDataWtrOpts IgnoreNullNamesOn_() {ignoreNullNames = true; return this;} private boolean ignoreNullNames;
|
||||
public static final GfmlDataWtrOpts _ = new GfmlDataWtrOpts();
|
||||
public static GfmlDataWtrOpts new_() {return new GfmlDataWtrOpts();} GfmlDataWtrOpts() {}
|
||||
public static GfmlDataWtrOpts cast_(Object obj) {try {return (GfmlDataWtrOpts)obj;} catch(Exception exc) {throw Exc_.new_type_mismatch_w_exc(exc, GfmlDataWtrOpts.class, obj);}}
|
||||
public static GfmlDataWtrOpts cast_(Object obj) {try {return (GfmlDataWtrOpts)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfmlDataWtrOpts.class, obj);}}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class z051_GfmlFldPool_keyed_tst {
|
||||
tst_Keyed_PopNext(fldPool, GfmlItmKeys.NullKey);
|
||||
Tfds.Fail("should have failed");
|
||||
}
|
||||
catch (Exception exc) {Exc_.Noop(exc);}
|
||||
catch (Exception exc) {Err_.Noop(exc);}
|
||||
}
|
||||
@Test public void PopByKey_PopNext() {
|
||||
tst_Keyed_PopByKey(fldPool, "y", "y", "x", "z");
|
||||
|
||||
@@ -46,6 +46,6 @@ public class z111_core_comment0_tst {
|
||||
// fx.tst_Err("//", GfmlOutCmds.Frame_danglingBgn_Err_());
|
||||
// Tfds.Fail_expdError();
|
||||
// }
|
||||
// catch (Exception exc) {Exc_.Noop(exc);}
|
||||
// catch (Exception exc) {Err_.Noop(exc);}
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user