mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Refactor: Pull more classes into baselib
This commit is contained in:
@@ -13,8 +13,11 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.core.texts.*; /*CharStream*/
|
||||
import gplx.frameworks.evts.Gfo_evt_itm;
|
||||
import gplx.types.basics.lists.Hash_adp;
|
||||
import gplx.types.basics.lists.Hash_adp_;
|
||||
public interface GfmlLxr extends Gfo_evt_itm {
|
||||
String Key();
|
||||
String[] Hooks();
|
||||
|
||||
@@ -13,30 +13,42 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
import gplx.core.texts.*; /*CharStream*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.commons.KeyVal;
|
||||
import gplx.types.errs.Err;
|
||||
import gplx.core.texts.*; /*CharStream*/
|
||||
import gplx.frameworks.invks.GfoMsg;
|
||||
import gplx.frameworks.invks.Gfo_invk;
|
||||
import gplx.frameworks.invks.Gfo_invk_;
|
||||
import gplx.frameworks.evts.Gfo_evt_itm;
|
||||
import gplx.frameworks.evts.Gfo_evt_mgr;
|
||||
import gplx.frameworks.evts.Gfo_evt_mgr_;
|
||||
import gplx.frameworks.invks.GfsCtx;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import gplx.types.commons.String_bldr;
|
||||
import gplx.types.commons.String_bldr_;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
public class GfmlLxr_ {
|
||||
public static GfmlLxr general_(String key, GfmlTkn protoTkn) {return GfmlLxr_general.new_(key, protoTkn);}
|
||||
public static GfmlLxr solo_(String key, GfmlTkn singletonTkn) {return GfmlLxr_singleton.new_(key, singletonTkn.Raw(), singletonTkn);}
|
||||
public static GfmlLxr range_(String key, String[] ary, GfmlTkn protoTkn, boolean ignoreOutput) {return GfmlLxr_group.new_(key, ary, protoTkn, ignoreOutput);}
|
||||
|
||||
@gplx.Internal protected static GfmlLxr symbol_(String key, String raw, String val, GfmlBldrCmd cmd) {
|
||||
public static GfmlLxr symbol_(String key, String raw, String val, GfmlBldrCmd cmd) {
|
||||
GfmlTkn tkn = GfmlTkn_.singleton_(key, raw, val, cmd);
|
||||
return GfmlLxr_.solo_(key, tkn);
|
||||
}
|
||||
@gplx.Internal protected static GfmlLxr frame_(String key, GfmlFrame frame, String bgn, String end) {return GfmlLxr_frame.new_(key, frame, bgn, end, GfmlBldrCmd_pendingTkns_add.Instance, GfmlBldrCmd_frameEnd.data_());}
|
||||
public static GfmlLxr frame_(String key, GfmlFrame frame, String bgn, String end) {return GfmlLxr_frame.new_(key, frame, bgn, end, GfmlBldrCmd_pendingTkns_add.Instance, GfmlBldrCmd_frameEnd.data_());}
|
||||
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 Err_.new_type_mismatch_w_exc(exc, GfmlLxr.class, obj);}}
|
||||
public static GfmlLxr cast(Object obj) {try {return (GfmlLxr)obj;} catch(Exception exc) {throw ErrUtl.NewCast(exc, GfmlLxr.class, obj);}}
|
||||
}
|
||||
class GfmlLxr_null implements GfmlLxr {
|
||||
public String Key() {return "gfml.nullLxr";}
|
||||
public Gfo_evt_mgr Evt_mgr() {if (evt_mgr == null) evt_mgr = new Gfo_evt_mgr(this); return evt_mgr;} Gfo_evt_mgr evt_mgr;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return Gfo_invk_.Rv_unhandled;}
|
||||
public GfmlTkn CmdTkn() {return GfmlTkn_.Null;} public void CmdTkn_set(GfmlTkn val) {}
|
||||
public String[] Hooks() {return String_.Ary_empty;}
|
||||
public String[] Hooks() {return StringUtl.AryEmpty;}
|
||||
public GfmlTkn MakeTkn(CharStream stream, int hookLength) {return GfmlTkn_.Null;}
|
||||
public void SubLxr_Add(GfmlLxr... lexer) {}
|
||||
public GfmlLxr SubLxr() {return this;}
|
||||
@@ -49,8 +61,8 @@ class GfmlLxr_singleton implements GfmlLxr, Gfo_evt_itm {
|
||||
public void CmdTkn_set(GfmlTkn val) {
|
||||
String oldRaw = singletonTkn.Raw();
|
||||
singletonTkn = val;
|
||||
hooks = String_.Ary(val.Raw());
|
||||
Gfo_evt_mgr_.Pub_vals(this, GfmlLxr_.CmdTknChanged_evt, Keyval_.new_("old", oldRaw), Keyval_.new_("new", val.Raw()), Keyval_.new_("lxr", this));
|
||||
hooks = StringUtl.Ary(val.Raw());
|
||||
Gfo_evt_mgr_.Pub_vals(this, GfmlLxr_.CmdTknChanged_evt, KeyVal.NewStr("old", oldRaw), KeyVal.NewStr("new", val.Raw()), KeyVal.NewStr("lxr", this));
|
||||
}
|
||||
public String[] Hooks() {return hooks;} private String[] hooks;
|
||||
public GfmlTkn MakeTkn(CharStream stream, int hookLength) {
|
||||
@@ -64,9 +76,9 @@ class GfmlLxr_singleton implements GfmlLxr, Gfo_evt_itm {
|
||||
rv.ctor_(key, hook, singletonTkn, GfmlLxr_.Null);
|
||||
return rv;
|
||||
} protected GfmlLxr_singleton() {}
|
||||
@gplx.Internal protected void ctor_(String key, String hook, GfmlTkn singletonTkn, GfmlLxr subLxr) {
|
||||
public void ctor_(String key, String hook, GfmlTkn singletonTkn, GfmlLxr subLxr) {
|
||||
this.key = key;
|
||||
this.hooks = String_.Ary(hook);
|
||||
this.hooks = StringUtl.Ary(hook);
|
||||
this.subLxr = subLxr;
|
||||
this.singletonTkn = singletonTkn;
|
||||
}
|
||||
@@ -80,20 +92,20 @@ class GfmlLxr_group implements GfmlLxr {
|
||||
public GfmlTkn MakeTkn(CharStream stream, int hookLength) {
|
||||
while (stream.AtMid()) {
|
||||
if (!ignoreOutput)
|
||||
sb.Add_mid_len(stream.Ary(), stream.Pos(), hookLength);
|
||||
sb.AddMidLen(stream.Ary(), stream.Pos(), hookLength);
|
||||
stream.MoveNextBy(hookLength);
|
||||
|
||||
String found = String_.cast(trie.FindMatch(stream));
|
||||
String found = StringUtl.Cast(trie.FindMatch(stream));
|
||||
if (found == null) break;
|
||||
hookLength = trie.LastMatchCount;
|
||||
}
|
||||
if (ignoreOutput) return GfmlTkn_.IgnoreOutput;
|
||||
String raw = sb.To_str_and_clear();
|
||||
String raw = sb.ToStrAndClear();
|
||||
return outputTkn.MakeNew(raw, raw);
|
||||
}
|
||||
public GfmlLxr SubLxr() {throw Err_sublxr();}
|
||||
public void SubLxr_Add(GfmlLxr... lexer) {throw Err_sublxr();}
|
||||
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_();}
|
||||
Err Err_sublxr() {return ErrUtl.NewUnimplemented("group lxr does not have subLxrs", "key", key, "output_tkn", outputTkn.Raw());}
|
||||
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();
|
||||
@@ -151,7 +163,7 @@ class GfmlLxr_general implements GfmlLxr, Gfo_invk {
|
||||
return lexer.MakeTkn(stream, length);
|
||||
}
|
||||
GfmlLxr_general_txtBfr txtBfr = new GfmlLxr_general_txtBfr(); GfmlTrie symTrie = GfmlTrie.new_(); GfmlLxr symLxr; int symTknLen;
|
||||
@gplx.Internal protected static GfmlLxr_general new_(String key, GfmlTkn txtTkn) {
|
||||
public static GfmlLxr_general new_(String key, GfmlTkn txtTkn) {
|
||||
GfmlLxr_general rv = new GfmlLxr_general();
|
||||
rv.key = key; rv.txtTkn = txtTkn;
|
||||
return rv;
|
||||
@@ -174,7 +186,7 @@ class GfmlLxr_general_txtBfr {
|
||||
Len++;
|
||||
} static final int NullPos = -1;
|
||||
public GfmlTkn MakeTkn(CharStream stream, GfmlTkn textTkn) {
|
||||
String raw = String_.new_charAry_(stream.Ary(), Bgn, Len);
|
||||
String raw = StringUtl.NewCharAry(stream.Ary(), Bgn, Len);
|
||||
Bgn = -1; Len = 0;
|
||||
return textTkn.MakeNew(raw, raw);
|
||||
}
|
||||
@@ -211,5 +223,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 Err_.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 ErrUtl.NewCast(exc, GfmlLxr_frame.class, obj);}}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,13 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.objects.New;
|
||||
import gplx.types.basics.lists.List_adp_base;
|
||||
public class GfmlObjList extends List_adp_base {
|
||||
@gplx.New public GfmlObj Get_at(int idx) {return (GfmlObj)Get_at_base(idx);}
|
||||
public void Add(GfmlObj tkn) {Add_base(tkn);}
|
||||
public void Add_at(GfmlObj tkn, int idx) {super.AddAt_base(idx, tkn);}
|
||||
public void Del(GfmlObj tkn) {Del_base(tkn);}
|
||||
public static GfmlObjList new_() {return new GfmlObjList();} GfmlObjList() {}
|
||||
}
|
||||
@New public GfmlObj GetAt(int idx) {return (GfmlObj)Get_at_base(idx);}
|
||||
public void Add(GfmlObj tkn) {Add_base(tkn);}
|
||||
public void Add_at(GfmlObj tkn, int idx) {super.AddAt_base(idx, tkn);}
|
||||
public void Del(GfmlObj tkn) {Del_base(tkn);}
|
||||
public static GfmlObjList new_() {return new GfmlObjList();} GfmlObjList() {}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
public interface GfmlTkn extends GfmlObj {
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.commons.String_bldr;
|
||||
import gplx.types.commons.String_bldr_;
|
||||
public interface GfmlTkn extends GfmlObj {
|
||||
String TknType();
|
||||
String Raw();
|
||||
String Val();
|
||||
@@ -23,22 +24,22 @@ public interface GfmlTkn extends GfmlObj {
|
||||
GfmlBldrCmd Cmd_of_Tkn();
|
||||
GfmlTkn MakeNew(String raw, String val);
|
||||
}
|
||||
class GfmlTknAry_ {
|
||||
class GfmlTknAry_ {
|
||||
public static final GfmlTkn[] Empty = new GfmlTkn[0];
|
||||
public static GfmlTkn[] ary_(GfmlTkn... ary) {return ary;}
|
||||
@gplx.Internal protected static String XtoRaw(GfmlTkn[] ary) {
|
||||
public static String XtoRaw(GfmlTkn[] ary) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
for (GfmlTkn tkn : ary)
|
||||
sb.Add(tkn.Raw());
|
||||
return sb.To_str();
|
||||
return sb.ToStr();
|
||||
}
|
||||
@gplx.Internal protected static String XtoVal(GfmlTkn[] ary) {return XtoVal(ary, 0, ary.length);}
|
||||
public static String XtoVal(GfmlTkn[] ary) {return XtoVal(ary, 0, ary.length);}
|
||||
static String XtoVal(GfmlTkn[] ary, int bgn, int end) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
for (int i = bgn; i < end; i++) {
|
||||
GfmlTkn tkn = ary[i];
|
||||
sb.Add(tkn.Val());
|
||||
}
|
||||
return sb.To_str();
|
||||
return sb.ToStr();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,25 +13,26 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
public class GfmlTkn_ {
|
||||
@gplx.Internal protected static final String NullRaw = "", NullVal = ""; static final String Type_base = "gfml.baseTkn";
|
||||
@gplx.Internal protected static final GfmlTkn
|
||||
public static final String NullRaw = "", NullVal = ""; static final String Type_base = "gfml.baseTkn";
|
||||
public static final GfmlTkn
|
||||
Null = new GfmlTkn_base().ctor_GfmlTkn_base("gfml.nullTkn", NullRaw, NullVal, GfmlBldrCmd_.Null)
|
||||
, EndOfStream = GfmlTkn_.raw_("<<End Of Stream>>")
|
||||
, IgnoreOutput = GfmlTkn_.raw_("<<Ignore Output>>");
|
||||
public static GfmlTkn as_(Object obj) {return obj instanceof GfmlTkn ? (GfmlTkn)obj : null;}
|
||||
@gplx.Internal protected static GfmlTkn new_(String raw, String val) {return new GfmlTkn_base().ctor_GfmlTkn_base(Type_base, raw, val, GfmlBldrCmd_.Null);}
|
||||
public static GfmlTkn new_(String raw, String val) {return new GfmlTkn_base().ctor_GfmlTkn_base(Type_base, raw, val, GfmlBldrCmd_.Null);}
|
||||
public static GfmlTkn raw_(String raw) {return new GfmlTkn_base().ctor_GfmlTkn_base(Type_base, raw, raw, GfmlBldrCmd_.Null);}
|
||||
@gplx.Internal protected static GfmlTkn val_(String val) {return new GfmlTkn_base().ctor_GfmlTkn_base(Type_base, NullRaw, val, GfmlBldrCmd_.Null);}
|
||||
@gplx.Internal protected static GfmlTkn cmd_(String tknType, GfmlBldrCmd cmd) {return new GfmlTkn_base().ctor_GfmlTkn_base(tknType, NullRaw, NullVal, cmd);}
|
||||
@gplx.Internal protected static GfmlTkn valConst_(String tknType, String val, GfmlBldrCmd cmd) {return new GfmlTkn_valConst().ctor_GfmlTkn_base(tknType, GfmlTkn_.NullRaw, val, cmd);}
|
||||
@gplx.Internal protected static GfmlTkn singleton_(String tknType, String raw, String val, GfmlBldrCmd cmd) {return new GfmlTkn_singleton().ctor_GfmlTkn_base(tknType, raw, val, cmd);}
|
||||
@gplx.Internal protected static GfmlTkn composite_(String tknType, GfmlTkn[] ary) {return new GfmlTkn_composite(tknType, ary);}
|
||||
@gplx.Internal protected static GfmlTkn composite_list_(String tknType, GfmlObjList list) {
|
||||
public static GfmlTkn val_(String val) {return new GfmlTkn_base().ctor_GfmlTkn_base(Type_base, NullRaw, val, GfmlBldrCmd_.Null);}
|
||||
public static GfmlTkn cmd_(String tknType, GfmlBldrCmd cmd) {return new GfmlTkn_base().ctor_GfmlTkn_base(tknType, NullRaw, NullVal, cmd);}
|
||||
public static GfmlTkn valConst_(String tknType, String val, GfmlBldrCmd cmd) {return new GfmlTkn_valConst().ctor_GfmlTkn_base(tknType, GfmlTkn_.NullRaw, val, cmd);}
|
||||
public static GfmlTkn singleton_(String tknType, String raw, String val, GfmlBldrCmd cmd) {return new GfmlTkn_singleton().ctor_GfmlTkn_base(tknType, raw, val, cmd);}
|
||||
public static GfmlTkn composite_(String tknType, GfmlTkn[] ary) {return new GfmlTkn_composite(tknType, ary);}
|
||||
public static GfmlTkn composite_list_(String tknType, GfmlObjList list) {
|
||||
GfmlTkn[] ary = new GfmlTkn[list.Len()];
|
||||
for (int i = 0; i < list.Len(); i++)
|
||||
ary[i] = (GfmlTkn)list.Get_at(i);
|
||||
ary[i] = (GfmlTkn)list.GetAt(i);
|
||||
return GfmlTkn_.composite_(tknType, ary);
|
||||
}
|
||||
}
|
||||
@@ -43,7 +44,7 @@ class GfmlTkn_base implements GfmlTkn {
|
||||
public GfmlBldrCmd Cmd_of_Tkn() {return cmd;} GfmlBldrCmd cmd;
|
||||
public GfmlTkn[] SubTkns() {return GfmlTknAry_.Empty;}
|
||||
public GfmlTkn MakeNew(String rawNew, String valNew) {return new GfmlTkn_base().ctor_GfmlTkn_base(tknType, rawNew, valNew, cmd);}
|
||||
@gplx.Internal protected GfmlTkn_base ctor_GfmlTkn_base(String tknType, String raw, String val, GfmlBldrCmd cmd) {this.tknType = tknType; this.raw = raw; this.val = val; this.cmd = cmd; return this;}
|
||||
public GfmlTkn_base ctor_GfmlTkn_base(String tknType, String raw, String val, GfmlBldrCmd cmd) {this.tknType = tknType; this.raw = raw; this.val = val; this.cmd = cmd; return this;}
|
||||
}
|
||||
class GfmlTkn_valConst extends GfmlTkn_base {
|
||||
@Override public GfmlTkn MakeNew(String rawNew, String valNew) {return new GfmlTkn_base().ctor_GfmlTkn_base(this.TknType(), rawNew, this.Val(), this.Cmd_of_Tkn());}
|
||||
@@ -58,6 +59,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 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;}
|
||||
public GfmlTkn MakeNew(String rawNew, String valNew) {throw ErrUtl.NewUnimplemented(".MakeNew cannot be invoked on GfmlTkn_composite (raw is available, but not val)", "tknType", tknType, "rawNew", rawNew, "valNew", valNew);}
|
||||
public GfmlTkn_composite(String tknType, GfmlTkn[] ary) {this.tknType = tknType; this.ary = ary;}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,17 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.texts.*; /*CharStream*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.Ordered_hash;
|
||||
import gplx.types.basics.lists.Ordered_hash_;
|
||||
import gplx.core.texts.CharStream;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public class GfmlTrie {
|
||||
public String[] Symbols() {
|
||||
String[] rv = new String[symbols.Len()];
|
||||
for (int i = 0; i < rv.length; i++)
|
||||
rv[i] = String_.cast(symbols.Get_at(i));
|
||||
rv[i] = StringUtl.Cast(symbols.GetAt(i));
|
||||
return rv;
|
||||
} Ordered_hash symbols = Ordered_hash_.New();
|
||||
public int LastMatchCount; // PERF: prop is faster than method
|
||||
@@ -46,9 +50,9 @@ public class GfmlTrie {
|
||||
return result;
|
||||
}
|
||||
public void Add(String symbol, Object data) {
|
||||
if (data == null) throw Err_.new_wo_type("null objects cannot be registered", "symbol", symbol);
|
||||
if (data == null) throw ErrUtl.NewArgs("null objects cannot be registered", "symbol", symbol);
|
||||
|
||||
char[] ary = String_.XtoCharAry(symbol); int lastIndex = ary.length - 1;
|
||||
char[] ary = StringUtl.ToCharAry(symbol); int lastIndex = ary.length - 1;
|
||||
IntObjHash_base curLink = rootLink;
|
||||
for (int i = 0; i < ary.length; i++) {
|
||||
char c = ary[i];
|
||||
@@ -80,7 +84,7 @@ public class GfmlTrie {
|
||||
symbols.AddIfDupeUseNth(symbol, symbol);
|
||||
}
|
||||
public void Del(String symbol) {
|
||||
char[] ary = String_.XtoCharAry(symbol); int lastIndex = ary.length - 1;
|
||||
char[] ary = StringUtl.ToCharAry(symbol); int lastIndex = ary.length - 1;
|
||||
IntObjHash_base[] linkAry = new IntObjHash_base[ary.length]; // first, get linkAry -- one link for each symbol
|
||||
IntObjHash_base link = rootLink;
|
||||
for (int i = 0; i < ary.length; i++) {
|
||||
|
||||
@@ -13,13 +13,14 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.objects.arrays.ArrayUtl;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.ArrayUtl;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
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 Err_.new_wo_type("key must be >= 0", "key", key);
|
||||
if (key < 0) throw ErrUtl.NewArgs("key must be >= 0", "key", key);
|
||||
if (key > maxKey) return null;
|
||||
Object[] subAry = FetchSubAry(key);
|
||||
return subAry == null ? null : subAry[subIdx];
|
||||
@@ -39,8 +40,8 @@ class IntObjHash_base {
|
||||
maxKey = -1;
|
||||
}
|
||||
void PutObjAtKey(int key, Object obj, boolean isAdd) {
|
||||
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 < 0) throw ErrUtl.NewArgs("key must be >= 0", "key", key);
|
||||
if (obj == null) throw ErrUtl.NewArgs("Object cannot be null; call .Del on key instead", "key", key);
|
||||
if (key > maxKey) ExpandRootAry(key);
|
||||
Object[] subAry = FetchSubAry(key);
|
||||
if (subAry == null) {
|
||||
@@ -48,8 +49,8 @@ class IntObjHash_base {
|
||||
rootAry[rootIdx] = subAry;
|
||||
}
|
||||
Object curVal = subAry[subIdx];
|
||||
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);
|
||||
if ( isAdd && curVal != null) throw ErrUtl.NewArgs(".Add cannot be called on non-null vals; call .Set instead", "key", key, "val", curVal);
|
||||
if (!isAdd && curVal == null) throw ErrUtl.NewArgs(".Set cannot be called on null vals; call .Add instead", "key", key);
|
||||
subAry[subIdx] = obj;
|
||||
if (isAdd) count++;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
public class GfmlFld {
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.commons.String_bldr;
|
||||
import gplx.types.commons.String_bldr_;
|
||||
public class GfmlFld {
|
||||
public String Name() {return name;} private String name;
|
||||
public boolean Name_isKey() {return name_isKey;} private boolean name_isKey;
|
||||
public String TypeKey() {return typeKey;} private String typeKey;
|
||||
@@ -26,8 +27,8 @@ public class GfmlFld {
|
||||
rv.defaultTkn = defaultTkn; // FIXME: defaultTkn.clone_()
|
||||
return rv;
|
||||
}
|
||||
public String To_str() {String_bldr sb = String_bldr_.new_(); this.To_str(sb); return sb.To_str_and_clear();}
|
||||
public void To_str(String_bldr sb) {sb.Add_fmt("name={0} typeKey={1}", name, typeKey);}
|
||||
public String To_str() {String_bldr sb = String_bldr_.new_(); this.To_str(sb); return sb.ToStrAndClear();}
|
||||
public void To_str(String_bldr sb) {sb.AddFmt("name={0} typeKey={1}", name, typeKey);}
|
||||
|
||||
public static final GfmlFld Null = new_(false, GfmlItmKeys.NullKey, GfmlType_.AnyKey);
|
||||
public static GfmlFld new_(boolean name_isKey, String name, String typeKey) {
|
||||
|
||||
@@ -13,14 +13,18 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.Ordered_hash;
|
||||
import gplx.types.basics.lists.Ordered_hash_;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public class GfmlFldList {
|
||||
public int Count() {return hash.Len();}
|
||||
public GfmlFld Get_at(int index) {return (GfmlFld)hash.Get_at(index);}
|
||||
public GfmlFld Get_at(int index) {return (GfmlFld)hash.GetAt(index);}
|
||||
public GfmlFld Get_by(String id) {return (GfmlFld)hash.GetByOrNull(id);}
|
||||
public void Add(GfmlFld fld) {
|
||||
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"
|
||||
if (StringUtl.IsNullOrEmpty(fld.Name())) throw ErrUtl.NewArgs("fld name cannot be null");
|
||||
if (hash.Has(fld.Name())) throw ErrUtl.NewArgs("key already exists", "key", fld.Name()); // FIXME: commented out to allow multiple types with same name; need "_type:invk"
|
||||
hash.AddIfDupeUseNth(fld.Name(), fld);
|
||||
}
|
||||
public void Del(GfmlFld fld) {
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
public class GfmlType implements GfmlScopeItm {
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public class GfmlType implements GfmlScopeItm {
|
||||
public String Key() {return key;} private String key; // key for typeRegy; EX: itm/rect
|
||||
public String NdeName() {return ndeName;} private String ndeName; // name for typeResolver; EX: rect
|
||||
public GfmlDocPos DocPos() {return docPos;} public GfmlType DocPos_(GfmlDocPos val) {docPos = val; return this;} GfmlDocPos docPos = GfmlDocPos_.Null;
|
||||
@@ -27,15 +28,15 @@ public class GfmlType implements GfmlScopeItm {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public boolean IsTypeAny() {return String_.Eq(key, GfmlType_.AnyKey);}
|
||||
public boolean IsTypeNull() {return String_.Eq(key, GfmlType_.NullKey);}
|
||||
@gplx.Internal protected GfmlType ctor_GfmlType_(String key, String ndeName) {
|
||||
public boolean IsTypeAny() {return StringUtl.Eq(key, GfmlType_.AnyKey);}
|
||||
public boolean IsTypeNull() {return StringUtl.Eq(key, GfmlType_.NullKey);}
|
||||
public GfmlType ctor_GfmlType_(String key, String ndeName) {
|
||||
this.key = key;
|
||||
this.ndeName = ndeName;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class GfmlType_ {
|
||||
class GfmlType_ {
|
||||
public static final String
|
||||
AnyKey = "gfml.any"
|
||||
, StringKey = "gfml.String"
|
||||
@@ -45,7 +46,7 @@ class GfmlType_ {
|
||||
public static final GfmlType String = new_(StringKey, StringKey);
|
||||
public static final GfmlType Null = new_(NullKey, NullKey);
|
||||
|
||||
@gplx.Internal protected static GfmlType new_(String key, String ndeName) {return new GfmlType().ctor_GfmlType_(key, ndeName);}
|
||||
@gplx.Internal protected static GfmlType new_any_() {return new_(AnyKey, AnyKey);}
|
||||
@gplx.Internal protected static String MakeKey(String ownerKey, String ndeName) {return String_.Concat(ownerKey, "/", ndeName);}
|
||||
public static GfmlType new_(String key, String ndeName) {return new GfmlType().ctor_GfmlType_(key, ndeName);}
|
||||
public static GfmlType new_any_() {return new_(AnyKey, AnyKey);}
|
||||
public static String MakeKey(String ownerKey, String ndeName) {return StringUtl.Concat(ownerKey, "/", ndeName);}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.Ordered_hash;
|
||||
class GfmlTypeCompiler {
|
||||
@gplx.Internal protected static GfmlType Compile(GfmlNde nde, GfmlType owner, GfmlTypRegy typeRegy, Ordered_hash results) {return Compile(nde, owner, true, typeRegy, results);}
|
||||
public static GfmlType Compile(GfmlNde nde, GfmlType owner, GfmlTypRegy typeRegy, Ordered_hash results) {return Compile(nde, owner, true, typeRegy, results);}
|
||||
static GfmlType Compile(GfmlNde nde, GfmlType owner, boolean isTopLevel, GfmlTypRegy typeRegy, Ordered_hash results) {
|
||||
String name = nde.SubKeys().FetchDataOrFail("name");
|
||||
String typeKey = FetchTypeKey(nde, owner, isTopLevel, name);
|
||||
@@ -81,7 +82,7 @@ class GfmlTypeCompiler {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@gplx.Internal protected static void AddDefaultAtrs(GfmlNde nde, GfmlType type, GfmlTypRegy regy) {
|
||||
public static void AddDefaultAtrs(GfmlNde nde, GfmlType type, GfmlTypRegy regy) {
|
||||
if (type.IsTypeAny()) return;
|
||||
for (int i = 0; i < type.SubFlds().Count(); i++) {
|
||||
GfmlFld subFld = (GfmlFld)type.SubFlds().Get_at(i);
|
||||
|
||||
@@ -13,12 +13,15 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.Hash_adp;
|
||||
import gplx.types.basics.lists.Hash_adp_;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
class GfmlTypeHash {
|
||||
public GfmlType Get_by(String key) {return (GfmlType)hash.GetByOrNull(key);}
|
||||
public void Add(GfmlType type) {
|
||||
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());
|
||||
if (type.IsTypeNull()) throw ErrUtl.NewArgs("cannot add null type to GfmlTypeHash");
|
||||
if (hash.Has(type.Key())) throw ErrUtl.NewArgs("type key already exists", "key", type.Key());
|
||||
hash.Add(type.Key(), type);
|
||||
}
|
||||
Hash_adp hash = Hash_adp_.New();
|
||||
@@ -28,7 +31,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 Err_.new_wo_type("typeKey cannot be null when added to typRegy");
|
||||
if (typeKey == null) throw ErrUtl.NewArgs("typeKey cannot be null when added to typRegy");
|
||||
GfmlType rv = (GfmlType)hash.Get_by(typeKey, pos);
|
||||
return rv == null ? GfmlType_.Null : rv;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
class GfmlTypeMakr {
|
||||
public GfmlType Owner() {return owner;}
|
||||
public GfmlType MakeRootType(String key, String name, String... flds) {
|
||||
|
||||
@@ -13,8 +13,13 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.lists.*;/*StackAdp*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.Ordered_hash;
|
||||
import gplx.types.basics.lists.Ordered_hash_;
|
||||
import gplx.core.lists.StackAdp;
|
||||
import gplx.core.lists.StackAdp_;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlTypeMgr {
|
||||
public GfmlTypRegy TypeRegy() {return typeRegy;} GfmlTypRegy typeRegy = GfmlTypRegy.new_();
|
||||
public GfmlFldPool FldPool() {return fldPool;} GfmlFldPool fldPool = GfmlFldPool.new_(GfmlType_.new_any_());
|
||||
@@ -36,7 +41,7 @@ class GfmlTypeMgr {
|
||||
}
|
||||
public void AtrExec(GfmlNde nde, GfmlAtr atr) {
|
||||
String atrKey = atr.Key();
|
||||
boolean isNull = String_.Eq(atrKey, GfmlTkn_.NullRaw);
|
||||
boolean isNull = StringUtl.Eq(atrKey, GfmlTkn_.NullRaw);
|
||||
GfmlFld atrFld = isNull
|
||||
? fldPool.Keyed_PopNext()
|
||||
: fldPool.Keyed_PopByKey(atrKey);
|
||||
@@ -47,9 +52,9 @@ class GfmlTypeMgr {
|
||||
}
|
||||
void Resolve(GfmlNde nde, String ownerTypeKey) {
|
||||
GfmlType type = GfmlType_.Null;
|
||||
if (!String_.Eq(ownerTypeKey, GfmlType_.AnyKey)) { // ownerType is specificType (!AnyType); lookup nde by ownerTypeKey + nde.Hnd
|
||||
String ndeHndOrKey = String_.Len_eq_0(nde.Hnd()) ? nde.Key() : nde.Hnd();
|
||||
if (String_.Len_eq_0(ndeHndOrKey)) ndeHndOrKey = nde.Hnd();
|
||||
if (!StringUtl.Eq(ownerTypeKey, GfmlType_.AnyKey)) { // ownerType is specificType (!AnyType); lookup nde by ownerTypeKey + nde.Hnd
|
||||
String ndeHndOrKey = StringUtl.IsNullOrEmpty(nde.Hnd()) ? nde.Key() : nde.Hnd();
|
||||
if (StringUtl.IsNullOrEmpty(ndeHndOrKey)) ndeHndOrKey = nde.Hnd();
|
||||
String typeKey = GfmlType_.MakeKey(ownerTypeKey, ndeHndOrKey);
|
||||
type = typeRegy.FetchOrNull(typeKey, nde.DocPos());
|
||||
}
|
||||
@@ -65,10 +70,10 @@ class GfmlTypeMgr {
|
||||
String ndeKey = nde.Key(), ndeHnd = nde.Hnd();
|
||||
String typKey = nde.Type().Key(); GfmlFld fld;
|
||||
if (nde.KeyedSubObj()) {
|
||||
if (String_.Len_eq_0(ndeKey)) {
|
||||
if (StringUtl.IsNullOrEmpty(ndeKey)) {
|
||||
fld = fldPool.Keyed_PopNext();
|
||||
typKey = (fld == GfmlFld.Null) ? GfmlType_.AnyKey : fld.TypeKey();
|
||||
if (ownerNde != null && !String_.Len_eq_0(fld.Name())) // HACK: String_.Len_eq_0(fld.Name()) needed for DoesNotUsurpDatTknForName
|
||||
if (ownerNde != null && !StringUtl.IsNullOrEmpty(fld.Name())) // HACK: String_.Len_eq_0(fld.Name()) needed for DoesNotUsurpDatTknForName
|
||||
ownerNde.SubKeys().RegisterKey(fld.Name(), nde);
|
||||
}
|
||||
else {
|
||||
@@ -77,16 +82,16 @@ class GfmlTypeMgr {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (String_.Len_eq_0(ndeHnd)) {
|
||||
if (StringUtl.IsNullOrEmpty(ndeHnd)) {
|
||||
fld = fldPool.DefaultMember();
|
||||
typKey = (fld == GfmlFld.Null) ? GfmlType_.AnyKey : fld.TypeKey();
|
||||
if (String_.Len_eq_0(nde.Hnd())) // type found, and curNde.Id is null; generate Id (DataRdr depends on this)
|
||||
if (StringUtl.IsNullOrEmpty(nde.Hnd())) // type found, and curNde.Id is null; generate Id (DataRdr depends on this)
|
||||
nde.Hnd_set(fld.Name());
|
||||
}
|
||||
else
|
||||
typKey = ndeHnd;
|
||||
}
|
||||
if (typKey == null) throw Err_.new_wo_type("could not identity type for node", "ndeKey", ndeKey, "ndeHnd", ndeHnd, "typKey", nde.Type().Key());
|
||||
if (typKey == null) throw ErrUtl.NewArgs("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
|
||||
@@ -105,7 +110,7 @@ class GfmlFldPool {
|
||||
public GfmlTkn Keyed_PopNextAsTkn() {return GfmlTkn_.val_(Keyed_PopNext().Name());} // helper method for GfmlFrame_nde
|
||||
public GfmlFld Keyed_PopNext() {
|
||||
if (keyedRegy.Len() == 0) return GfmlFld.Null;
|
||||
GfmlFld rv = (GfmlFld)keyedRegy.Get_at(0);
|
||||
GfmlFld rv = (GfmlFld)keyedRegy.GetAt(0);
|
||||
keyedRegy.Del(rv.Name());
|
||||
return rv;
|
||||
}
|
||||
@@ -114,10 +119,10 @@ class GfmlFldPool {
|
||||
keyedRegy.Del(rv.Name());
|
||||
return rv;
|
||||
}
|
||||
@gplx.Internal protected int Keyd_Count() {return keyedRegy.Len();}
|
||||
@gplx.Internal protected GfmlFld Keyd_FetchAt(int i) {return (GfmlFld)keyedRegy.Get_at(i);}
|
||||
public int Keyd_Count() {return keyedRegy.Len();}
|
||||
public GfmlFld Keyd_FetchAt(int i) {return (GfmlFld)keyedRegy.GetAt(i);}
|
||||
public GfmlFld DefaultMember() {return defaultMember;} GfmlFld defaultMember = GfmlFld.Null;
|
||||
@gplx.Internal protected GfmlType Type() {return type;} GfmlType type = GfmlType_.Null;
|
||||
public GfmlType Type() {return type;} GfmlType type = GfmlType_.Null;
|
||||
void InitByType(GfmlType type) {
|
||||
this.type = type;
|
||||
for (int i = 0; i < type.SubFlds().Count(); i++) {
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public class GfmlAtr implements GfmlItm {
|
||||
public int ObjType() {return GfmlObj_.Type_atr;}
|
||||
public GfmlTkn KeyTkn() {return keyTkn;} GfmlTkn keyTkn; public String Key() {return keyTkn.Val();}
|
||||
@@ -21,10 +22,10 @@ public class GfmlAtr implements GfmlItm {
|
||||
public GfmlType Type() {return type;} GfmlType type;
|
||||
public boolean KeyedSubObj() {return true;}
|
||||
public int SubObjs_Count() {return subObjs.Len();}
|
||||
public GfmlObj SubObjs_GetAt(int i) {return (GfmlObj)subObjs.Get_at(i);} GfmlObjList subObjs = GfmlObjList.new_(); // PERF?: make capacity 3 instead of 8
|
||||
public GfmlObj SubObjs_GetAt(int i) {return (GfmlObj)subObjs.GetAt(i);} GfmlObjList subObjs = GfmlObjList.new_(); // PERF?: make capacity 3 instead of 8
|
||||
public void SubObjs_Add(GfmlObj o) {subObjs.Add(o);}
|
||||
public String To_str() {return String_.Concat(this.Key(), "=", this.DatTkn().Val());}
|
||||
@gplx.Internal protected void Key_set(String v) {keyTkn = GfmlTkn_.val_(v);} // used for 1 test
|
||||
public String ToStr() {return StringUtl.Concat(this.Key(), "=", this.DatTkn().Val());}
|
||||
public void Key_set(String v) {keyTkn = GfmlTkn_.val_(v);} // used for 1 test
|
||||
|
||||
public static GfmlAtr as_(Object obj) {return obj instanceof GfmlAtr ? (GfmlAtr)obj : null;}
|
||||
public static GfmlAtr string_(GfmlTkn keyTkn, GfmlTkn datTkn) {return new_(keyTkn, datTkn, GfmlType_.String);}
|
||||
@@ -48,7 +49,7 @@ public class GfmlAtr implements GfmlItm {
|
||||
}
|
||||
int GetTknIdx(GfmlTkn t) {
|
||||
for (int i = 0; i < subObjs.Len(); i++) {
|
||||
GfmlObj obj = (GfmlObj)subObjs.Get_at(i);
|
||||
GfmlObj obj = (GfmlObj)subObjs.GetAt(i);
|
||||
if (obj == t) return i;
|
||||
}
|
||||
return -1;
|
||||
@@ -58,15 +59,15 @@ public class GfmlAtr implements GfmlItm {
|
||||
if (oldTkn.SubTkns().length > 0) {
|
||||
GfmlTkn bgn = oldTkn.SubTkns()[0];
|
||||
GfmlTkn end = oldTkn.SubTkns()[oldTkn.SubTkns().length - 1];
|
||||
newStr = String_.Replace(newStr, bgn.Raw(), bgn.Raw() + bgn.Raw());
|
||||
newStr = StringUtl.Replace(newStr, bgn.Raw(), bgn.Raw() + bgn.Raw());
|
||||
if (bgn.Raw() != end.Raw())
|
||||
newStr = String_.Replace(newStr, end.Raw(), end.Raw() + end.Raw());
|
||||
newStr = StringUtl.Replace(newStr, end.Raw(), end.Raw() + end.Raw());
|
||||
return GfmlTkn_.composite_(oldTkn.TknType(), GfmlTknAry_.ary_(bgn, GfmlTkn_.raw_(newStr), end));
|
||||
}
|
||||
else {
|
||||
boolean hasQuote = String_.Has(newStr, "'");
|
||||
boolean hasQuote = StringUtl.Has(newStr, "'");
|
||||
if (hasQuote)
|
||||
return GfmlTkn_.composite_("composite", GfmlTknAry_.ary_(GfmlTkn_.new_("'", ""), GfmlTkn_.raw_(String_.Replace(newStr, "'", "''")), GfmlTkn_.new_("'", "")));
|
||||
return GfmlTkn_.composite_("composite", GfmlTknAry_.ary_(GfmlTkn_.new_("'", ""), GfmlTkn_.raw_(StringUtl.Replace(newStr, "'", "''")), GfmlTkn_.new_("'", "")));
|
||||
else
|
||||
return GfmlTkn_.raw_(newStr);
|
||||
}
|
||||
|
||||
@@ -13,21 +13,23 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
public class GfmlDoc {
|
||||
public GfmlNde RootNde() {return rootNde;} GfmlNde rootNde;
|
||||
@gplx.Internal protected List_adp UsrMsgs() {return usrMsgs;} List_adp usrMsgs = List_adp_.New();
|
||||
@gplx.Internal protected GfmlLxrRegy LxrRegy() {return lxrRegy;} GfmlLxrRegy lxrRegy = new GfmlLxrRegy();
|
||||
@gplx.Internal protected GfmlBldrCmdRegy CmdRegy() {return cmdRegy;} GfmlBldrCmdRegy cmdRegy = GfmlBldrCmdRegy.new_();
|
||||
@gplx.Internal protected GfmlPragmaMgr PragmaMgr() {return pragmaMgr;} GfmlPragmaMgr pragmaMgr = GfmlPragmaMgr.new_();
|
||||
@gplx.Internal protected GfmlLxr RootLxr() {return rootLxr;} GfmlLxr rootLxr;
|
||||
@gplx.Internal protected void RootLxr_set(GfmlLxr v) {rootLxr = v;}
|
||||
@gplx.Internal protected void Clear() {
|
||||
public List_adp UsrMsgs() {return usrMsgs;} List_adp usrMsgs = List_adp_.New();
|
||||
public GfmlLxrRegy LxrRegy() {return lxrRegy;} GfmlLxrRegy lxrRegy = new GfmlLxrRegy();
|
||||
public GfmlBldrCmdRegy CmdRegy() {return cmdRegy;} GfmlBldrCmdRegy cmdRegy = GfmlBldrCmdRegy.new_();
|
||||
public GfmlPragmaMgr PragmaMgr() {return pragmaMgr;} GfmlPragmaMgr pragmaMgr = GfmlPragmaMgr.new_();
|
||||
public GfmlLxr RootLxr() {return rootLxr;} GfmlLxr rootLxr;
|
||||
public void RootLxr_set(GfmlLxr v) {rootLxr = v;}
|
||||
public void Clear() {
|
||||
usrMsgs.Clear();
|
||||
rootNde = GfmlNde.named_(GfmlTkn_.cmd_("tkn.gfml.root_tkn", GfmlBldrCmd_pendingTkns_add.Instance), GfmlType_.Null);
|
||||
rootNde.DocPos_(GfmlDocPos_.Root);
|
||||
}
|
||||
@gplx.Internal protected static GfmlDoc new_() {
|
||||
public static GfmlDoc new_() {
|
||||
GfmlDoc rv = new GfmlDoc();
|
||||
rv.Clear();
|
||||
return rv;
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlDocLxrs {
|
||||
@gplx.Internal protected static void Default_lxr(GfmlLxrRegy regy, GfmlLxr rootLxr) {
|
||||
public static void Default_lxr(GfmlLxrRegy regy, GfmlLxr rootLxr) {
|
||||
GfmlLxr[] ary = new GfmlLxr[] { GfmlDocLxrs.Whitespace_lxr()
|
||||
, GfmlDocLxrs.Quote0_Eval0_lxr()
|
||||
, GfmlDocLxrs.Quote1_lxr()
|
||||
@@ -44,10 +45,10 @@ class GfmlDocLxrs {
|
||||
}
|
||||
public static GfmlLxr Whitespace_lxr() {
|
||||
GfmlTkn tkn = GfmlTkn_.cmd_("key:gfml.whitespace_0", GfmlBldrCmd_whitespace.Instance);
|
||||
GfmlLxr rv = GfmlLxr_.range_("lxr:gfml.whitespace_0", String_.Ary(" ", String_.Tab, String_.CrLf, String_.Lf), tkn, false);
|
||||
GfmlLxr rv = GfmlLxr_.range_("lxr:gfml.whitespace_0", StringUtl.Ary(" ", StringUtl.Tab, StringUtl.CrLf, StringUtl.Nl), tkn, false);
|
||||
return rv;
|
||||
}
|
||||
public static GfmlLxr Comment0_lxr() {return GfmlLxr_.frame_("gfml.comment_0", GfmlFrame_.comment_(), "//", String_.Lf);}
|
||||
public static GfmlLxr Comment0_lxr() {return GfmlLxr_.frame_("gfml.comment_0", GfmlFrame_.comment_(), "//", StringUtl.Nl);}
|
||||
// public static GfmlLxr Comment0a_lxr() {return GfmlLxr_.frame_("gfml.comment_0b", GfmlFrame_.comment_(), "//", "\n");}
|
||||
public static GfmlLxr Comment1_lxr() {
|
||||
GfmlLxr rv = GfmlLxr_.frame_("gfml.comment_1", GfmlFrame_.comment_(), "/*", "*/");
|
||||
@@ -102,7 +103,7 @@ class GfmlDocLxrs {
|
||||
GfmlLxr rv = GfmlLxr_.frame_("gfml.quote_fold_0", GfmlFrame_.quote_(), "^'", "'^");
|
||||
|
||||
GfmlTkn tkn = GfmlTkn_.valConst_("key:gfml.quote_fold_0_whitespace", GfmlTkn_.NullVal, GfmlBldrCmd_whitespace.Instance);
|
||||
GfmlLxr whitespace = GfmlLxr_.range_("lxr:gfml.quote_fold_0_whitespace", String_.Ary(String_.Tab, String_.CrLf, String_.Lf), tkn, false);
|
||||
GfmlLxr whitespace = GfmlLxr_.range_("lxr:gfml.quote_fold_0_whitespace", StringUtl.Ary(StringUtl.Tab, StringUtl.CrLf, StringUtl.Nl), tkn, false);
|
||||
GfmlLxr escapeBgn = lxr_escape_("gfml.quote_fold_0_escape_bgn", "^'^'", "^'");
|
||||
GfmlLxr escapeEnd = lxr_escape_("gfml.quote_fold_0_escape_end", "'^'^", "'^");
|
||||
rv.SubLxr_Add(whitespace, escapeBgn, escapeEnd, rv); // NOTE: adding rv makes it recursive
|
||||
|
||||
@@ -13,10 +13,12 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
import gplx.objects.lists.CompareAble;
|
||||
import gplx.objects.lists.CompareAbleUtl;
|
||||
package gplx.gfml;
|
||||
import gplx.types.commons.lists.CompareAble;
|
||||
import gplx.types.commons.lists.CompareAbleUtl;
|
||||
import gplx.types.basics.utls.IntUtl;
|
||||
import gplx.types.commons.String_bldr;
|
||||
import gplx.types.commons.String_bldr_;
|
||||
public class GfmlDocPos implements CompareAble {
|
||||
public String Path() {if (path == null) MakePath(); return path;} private String path;
|
||||
public int compareTo(Object obj) {
|
||||
@@ -33,7 +35,7 @@ public class GfmlDocPos implements CompareAble {
|
||||
else if (origVal > compVal) return CompareAbleUtl.More;
|
||||
}
|
||||
if (ary.length < comp.ary.length) return CompareAbleUtl.Less; // less ary than comp, and whatever ary they share are equal; must be less
|
||||
return Int_.Compare(idx, comp.idx); // compare idx
|
||||
return IntUtl.Compare(idx, comp.idx); // compare idx
|
||||
}
|
||||
public GfmlDocPos NewClone() {return new GfmlDocPos(ary, idx);}
|
||||
public GfmlDocPos NewDown(int newIdx) {
|
||||
@@ -60,10 +62,10 @@ public class GfmlDocPos implements CompareAble {
|
||||
sb.Add("_");
|
||||
}
|
||||
sb.Add(idx);
|
||||
path = sb.To_str();
|
||||
path = sb.ToStr();
|
||||
}
|
||||
int[] ary; int idx;
|
||||
@gplx.Internal protected GfmlDocPos(int[] ary, int idx) {this.ary = ary; this.idx = idx;}
|
||||
public GfmlDocPos(int[] ary, int idx) {this.ary = ary; this.idx = idx;}
|
||||
}
|
||||
class GfmlDocPos_ {
|
||||
public static final GfmlDocPos Null = new GfmlDocPos(new int[0], -1);
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.commons.String_bldr;
|
||||
import gplx.types.commons.String_bldr_;
|
||||
public class GfmlDocWtr_ {
|
||||
public String To_str_and_clear() {return sb.To_str_and_clear();}
|
||||
public String To_str_and_clear() {return sb.ToStrAndClear();}
|
||||
public void BuildAttrib(GfmlAtr atr) {Build(atr);}
|
||||
public void BuildNode(GfmlNde nde) {Build(nde);}
|
||||
void Build(GfmlItm owner) {
|
||||
|
||||
@@ -13,9 +13,14 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.errs.Err;
|
||||
import gplx.libs.dlgs.UsrMsg;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
import gplx.types.basics.utls.IntUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public class GfmlDoc_ {
|
||||
public static GfmlDoc parse_any_eol_(String raw) {return parse(String_.Replace(raw, String_.CrLf, String_.Lf));}
|
||||
public static GfmlDoc parse_any_eol_(String raw) {return parse(StringUtl.Replace(raw, StringUtl.CrLf, StringUtl.Nl));}
|
||||
public static GfmlDoc parse(String raw) {
|
||||
GfmlBldr bldr = GfmlBldr_.default_();
|
||||
return bldr.XtoGfmlDoc(raw);
|
||||
@@ -31,13 +36,13 @@ class GfmlUsrMsgs {
|
||||
GfmlStringHighlighter sh = GfmlStringHighlighter.new_();
|
||||
sh.Raw_(raw).Mark_(bldr.StreamPos(), '*', "failed");
|
||||
um.Add("errorPos", bldr.StreamPos());
|
||||
um.Add("errorHighlight", String_.CrLf + String_.Concat_lines_crlf(sh.Gen()));
|
||||
um.Add("errorHighlight", StringUtl.CrLf + StringUtl.ConcatLinesCrlf(sh.Gen()));
|
||||
}
|
||||
public static Err gfmlParseError(GfmlBldr bldr) {
|
||||
Err rv = Err_.new_wo_type("gfml parse error");
|
||||
Err rv = ErrUtl.NewArgs("gfml parse error");
|
||||
for (int i = 0; i < bldr.Doc().UsrMsgs().Len(); i++) {
|
||||
UsrMsg um = (UsrMsg)bldr.Doc().UsrMsgs().Get_at(i);
|
||||
rv.Args_add("err" + Int_.To_str(i), um.To_str());
|
||||
UsrMsg um = (UsrMsg)bldr.Doc().UsrMsgs().GetAt(i);
|
||||
rv.ArgsAdd("err" + IntUtl.ToStr(i), um.To_str());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -13,15 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
public interface GfmlItm extends GfmlObj, To_str_able {
|
||||
GfmlTkn KeyTkn(); String Key(); // Key() is alternative to Key().Val()
|
||||
GfmlType Type();
|
||||
boolean KeyedSubObj();
|
||||
int SubObjs_Count();
|
||||
GfmlObj SubObjs_GetAt(int i);
|
||||
void SubObjs_Add(GfmlObj obj);
|
||||
}
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.objects.ToStrAble;
|
||||
public interface GfmlItm extends GfmlObj, ToStrAble {
|
||||
GfmlTkn KeyTkn(); String Key(); // Key() is alternative to Key().Val()
|
||||
GfmlType Type();
|
||||
boolean KeyedSubObj();
|
||||
int SubObjs_Count();
|
||||
GfmlObj SubObjs_GetAt(int i);
|
||||
void SubObjs_Add(GfmlObj obj);
|
||||
}
|
||||
class GfmlItm_ {
|
||||
public static GfmlItm as_(Object obj) {return obj instanceof GfmlItm ? (GfmlItm)obj : null;}
|
||||
}
|
||||
public static GfmlItm as_(Object obj) {return obj instanceof GfmlItm ? (GfmlItm)obj : null;}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,12 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
public class GfmlItmHnds {
|
||||
public int Count() {return list.Len();} List_adp list = List_adp_.New();
|
||||
public GfmlNde Get_at(int idx) {return (GfmlNde)list.Get_at(idx);}
|
||||
public GfmlNde Get_at(int idx) {return (GfmlNde)list.GetAt(idx);}
|
||||
public void Add(GfmlNde nde) {list.Add(nde);}
|
||||
public static GfmlItmHnds new_() {return new GfmlItmHnds();} GfmlItmHnds() {}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,17 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
import gplx.types.basics.lists.Hash_adp;
|
||||
import gplx.types.basics.lists.Hash_adp_;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public class GfmlItmKeys {
|
||||
public int Count() {return list.Len();}
|
||||
public boolean Has(String key) {return hash.Has(key);}
|
||||
public GfmlItm Get_at(int i) {return (GfmlItm)list.Get_at(i);}
|
||||
public GfmlItm Get_at(int i) {return (GfmlItm)list.GetAt(i);}
|
||||
public GfmlItm Get_by(String key) {return (GfmlItm)hash.GetByOrNull(key);}
|
||||
public String FetchDataOr(String key, String or) {
|
||||
GfmlAtr atr = FetchAtr(key);
|
||||
@@ -25,7 +31,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 Err_.new_missing_key(key);
|
||||
GfmlAtr atr = FetchAtr(key); if (atr == null) throw ErrUtl.NewMissingKey(key);
|
||||
return atr.DatTkn().Val();
|
||||
}
|
||||
public GfmlTkn FetchDataTknOrNull(String key) {
|
||||
@@ -36,10 +42,10 @@ public class GfmlItmKeys {
|
||||
String key = itm.Key();
|
||||
if (hash.Has(key)) DelDefault(itm); // default attribs are added automatically; drop default when adding newElm
|
||||
list.Add(itm);
|
||||
if (!String_.Eq(key, GfmlItmKeys.NullKey))
|
||||
if (!StringUtl.Eq(key, GfmlItmKeys.NullKey))
|
||||
RegisterKey(key, itm);
|
||||
}
|
||||
@gplx.Internal protected void RegisterKey(String key, GfmlItm itm) {
|
||||
public void RegisterKey(String key, GfmlItm itm) {
|
||||
if (hash.Has(key)) hash.Del(key); // replace default
|
||||
hash.Add(key, itm);
|
||||
}
|
||||
@@ -47,13 +53,13 @@ public class GfmlItmKeys {
|
||||
GfmlItm toDel = null;
|
||||
for (Object subObj : list) {
|
||||
GfmlItm sub = (GfmlItm)subObj;
|
||||
if (String_.Eq(sub.Key(), elm.Key()))
|
||||
if (StringUtl.Eq(sub.Key(), elm.Key()))
|
||||
toDel = sub;
|
||||
}
|
||||
if (toDel != null) list.Del(toDel);
|
||||
}
|
||||
GfmlAtr FetchAtr(String key) {return GfmlAtr.as_(hash.GetByOrNull(key));}
|
||||
List_adp list = List_adp_.New(); Hash_adp hash = Hash_adp_.New();
|
||||
List_adp list = List_adp_.New(); Hash_adp hash = Hash_adp_.New();
|
||||
public static GfmlItmKeys new_() {return new GfmlItmKeys();} GfmlItmKeys() {}
|
||||
@gplx.Internal protected static final String NullKey = "";
|
||||
public static final String NullKey = "";
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public class GfmlNde implements GfmlItm {
|
||||
public static final int OBJ_TYPE = GfmlObj_.Type_nde;
|
||||
public int ObjType() {return objType;} int objType = GfmlObj_.Type_nde;
|
||||
@@ -22,7 +23,7 @@ public class GfmlNde implements GfmlItm {
|
||||
public boolean KeyedSubObj() {return keyedSubObj;} public GfmlNde KeyedSubObj_(boolean v) {keyedSubObj = v; return this;} private boolean keyedSubObj;
|
||||
public int ChainId() {return chainId;} public GfmlNde ChainId_(int v) {chainId = v; return this;} int chainId; // can use boolean chainHead, but this is easier for debugging
|
||||
public int SubObjs_Count() {return subObjs.Len();} GfmlObjList subObjs = GfmlObjList.new_();
|
||||
public GfmlObj SubObjs_GetAt(int i) {return (GfmlObj)subObjs.Get_at(i);}
|
||||
public GfmlObj SubObjs_GetAt(int i) {return (GfmlObj)subObjs.GetAt(i);}
|
||||
public void SubObjs_Add(GfmlObj gobj) {
|
||||
subObjs.Add(gobj);
|
||||
GfmlItm subItm = GfmlItm_.as_(gobj);
|
||||
@@ -38,11 +39,11 @@ public class GfmlNde implements GfmlItm {
|
||||
public GfmlDocPos DocPos() {return docPos;} GfmlDocPos docPos = GfmlDocPos_.Null;
|
||||
public GfmlItmKeys SubKeys() {return subKeys;} GfmlItmKeys subKeys = GfmlItmKeys.new_();
|
||||
public GfmlItmHnds SubHnds() {return subHnds;} GfmlItmHnds subHnds = GfmlItmHnds.new_();
|
||||
public String To_str() {return GfmlDocWtr_.xtoStr_(this);}
|
||||
public String ToStr() {return GfmlDocWtr_.xtoStr_(this);}
|
||||
public void UpdateNde(String hnd) {
|
||||
for (int i = 0; i < subHnds.Count(); i++) {
|
||||
GfmlNde nde = (GfmlNde)subHnds.Get_at(i);
|
||||
if (String_.Eq(nde.hndTkn.Raw(), hnd)) return;
|
||||
if (StringUtl.Eq(nde.hndTkn.Raw(), hnd)) return;
|
||||
}
|
||||
int endAtrPos = PosOf(false, ";", "}");
|
||||
GfmlTkn bgnParen = GfmlTkn_.new_("(", "");
|
||||
@@ -65,10 +66,10 @@ public class GfmlNde implements GfmlItm {
|
||||
int end = fwd ? subObjs.Len() : 0;
|
||||
int dif = fwd ? 1 : -1;
|
||||
for (int i = bgn; i != end; i+=dif) {
|
||||
GfmlObj subObj = (GfmlObj)subObjs.Get_at(i);
|
||||
GfmlObj subObj = (GfmlObj)subObjs.GetAt(i);
|
||||
GfmlTkn subTkn = GfmlTkn_.as_(subObj);
|
||||
if (subTkn == null) continue;
|
||||
if (String_.In(subTkn.Raw(), find)) {
|
||||
if (StringUtl.In(subTkn.Raw(), find)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -77,7 +78,7 @@ public class GfmlNde implements GfmlItm {
|
||||
public void UpdateAtr(String key, String val) {
|
||||
GfmlAtr atr = (GfmlAtr)subKeys.Get_by(key);
|
||||
if (atr != null) {atr.UpdateAtr(key, val); return;}
|
||||
val = String_.Replace(val, "'", "''");
|
||||
val = StringUtl.Replace(val, "'", "''");
|
||||
GfmlTkn quote = GfmlTkn_.new_("'", "");
|
||||
GfmlTkn keyTkn = GfmlTkn_.raw_(key);
|
||||
GfmlTkn valTkn = GfmlTkn_.composite_("composite", GfmlTknAry_.ary_(quote, GfmlTkn_.raw_(val), quote));
|
||||
@@ -94,18 +95,18 @@ public class GfmlNde implements GfmlItm {
|
||||
subObjs.Add_at(atr, endAtrPos);
|
||||
}
|
||||
|
||||
@gplx.Internal protected void ObjType_set_pragma() {objType = GfmlObj_.Type_prg;}
|
||||
@gplx.Internal protected void KeyTkn_set(GfmlTkn gobj) {keyTkn = gobj;}
|
||||
@gplx.Internal protected void Type_set(GfmlType val) {type = val;}
|
||||
@gplx.Internal protected void SubObjs_Clear() {subObjs.Clear();}
|
||||
@gplx.Internal protected GfmlTkn HndTkn() {return hndTkn;}
|
||||
@gplx.Internal protected void HndTkn_set(GfmlTkn tkn) {hndTkn = tkn;}
|
||||
@gplx.Internal protected void Hnd_set(String v) {hndTkn = String_.Len_eq_0(v) ? GfmlTkn_.Null : GfmlTkn_.val_(v);} // NOTE: v is empty for types with empty fldNames
|
||||
@gplx.Internal protected GfmlNde DocPos_(GfmlDocPos val) {docPos = val; return this;}
|
||||
public void ObjType_set_pragma() {objType = GfmlObj_.Type_prg;}
|
||||
public void KeyTkn_set(GfmlTkn gobj) {keyTkn = gobj;}
|
||||
public void Type_set(GfmlType val) {type = val;}
|
||||
public void SubObjs_Clear() {subObjs.Clear();}
|
||||
public GfmlTkn HndTkn() {return hndTkn;}
|
||||
public void HndTkn_set(GfmlTkn tkn) {hndTkn = tkn;}
|
||||
public void Hnd_set(String v) {hndTkn = StringUtl.IsNullOrEmpty(v) ? GfmlTkn_.Null : GfmlTkn_.val_(v);} // NOTE: v is empty for types with empty fldNames
|
||||
public GfmlNde DocPos_(GfmlDocPos val) {docPos = val; return this;}
|
||||
|
||||
public static GfmlNde as_(Object obj) {return obj instanceof GfmlNde ? (GfmlNde)obj : null;}
|
||||
@gplx.Internal protected static GfmlNde named_(GfmlTkn hndTkn, GfmlType type) {return new GfmlNde(hndTkn, type, false);}
|
||||
@gplx.Internal protected static GfmlNde new_(GfmlTkn hndTkn, GfmlType type, boolean keyedSubObj) {return new GfmlNde(hndTkn, type, keyedSubObj);}
|
||||
public static GfmlNde named_(GfmlTkn hndTkn, GfmlType type) {return new GfmlNde(hndTkn, type, false);}
|
||||
public static GfmlNde new_(GfmlTkn hndTkn, GfmlType type, boolean keyedSubObj) {return new GfmlNde(hndTkn, type, keyedSubObj);}
|
||||
GfmlNde(GfmlTkn hndTkn, GfmlType type, boolean keyedSubObj) {
|
||||
this.hndTkn = hndTkn; this.type = type; this.keyedSubObj = keyedSubObj;}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,12 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.objects.lists.CompareAbleUtl;
|
||||
package gplx.gfml;
|
||||
import gplx.types.commons.lists.CompareAbleUtl;
|
||||
import gplx.types.basics.lists.Hash_adp;
|
||||
import gplx.types.basics.lists.Hash_adp_;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
interface GfmlScopeItm {
|
||||
String Key();
|
||||
GfmlDocPos DocPos();
|
||||
|
||||
@@ -13,8 +13,11 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.core.lists.*;/*Hash_adp_list*/
|
||||
import gplx.types.basics.lists.Hash_adp;
|
||||
import gplx.types.basics.lists.Hash_adp_;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
interface GfmlPragma {
|
||||
String KeyOfPragma();
|
||||
void Exec(GfmlBldr bldr, GfmlNde pragmaNde);
|
||||
@@ -39,7 +42,7 @@ class GfmlPragmaMgr {
|
||||
static void Exec(GfmlDocPos pos, GfmlBldr bldr, Hash_adp_list cmds) {
|
||||
List_adp list = cmds.GetByOrNull(pos.Path()); if (list == null) return;
|
||||
for (int i = 0; i < list.Len(); i++) {
|
||||
GfmlBldrCmd cmd = (GfmlBldrCmd)list.Get_at(i);
|
||||
GfmlBldrCmd cmd = (GfmlBldrCmd)list.GetAt(i);
|
||||
cmd.Exec(bldr, GfmlTkn_.Null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,11 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlPragmaDefault implements GfmlPragma {
|
||||
public String KeyOfPragma() {return "_default";}
|
||||
public void Exec(GfmlBldr bldr, GfmlNde pragmaNde) {
|
||||
@@ -21,7 +25,7 @@ class GfmlPragmaDefault implements GfmlPragma {
|
||||
GfmlDefaultPragma_bgnCmd.ExecList(bldr.TypeMgr().TypeRegy(), bldr.CurNdeFrame().CurDocPos(), list);
|
||||
// bldr.PragmaMgr.EndCmds_add(GfmlDocPos_.up_(bldr.CurNdeFrame.DocPos), GfmlDefaultPragma_endCmd.new_(list));
|
||||
}
|
||||
@gplx.Internal protected List_adp Compile(GfmlNde pragmaNde) {
|
||||
public List_adp Compile(GfmlNde pragmaNde) {
|
||||
List_adp list = List_adp_.New();
|
||||
for (int i = 0; i < pragmaNde.SubHnds().Count(); i++) {
|
||||
GfmlNde subNde = (GfmlNde)pragmaNde.SubHnds().Get_at(i);
|
||||
@@ -29,15 +33,15 @@ 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 Err_.new_missing_key("typeKey");
|
||||
public void CompileSubNde(GfmlNde nde, List_adp list) {
|
||||
String typeKey = nde.SubKeys().FetchDataOrNull("typeKey"); if (typeKey == null) throw ErrUtl.NewMissingKey("typeKey");
|
||||
for (int i = 0; i < nde.SubHnds().Count(); i++) {
|
||||
GfmlNde subNde = (GfmlNde)nde.SubHnds().Get_at(i);
|
||||
GfmlDefaultItem item = CompileItem(subNde, typeKey);
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
@gplx.Internal protected GfmlDefaultItem CompileItem(GfmlNde nde, String typeKey) {
|
||||
public GfmlDefaultItem CompileItem(GfmlNde nde, String typeKey) {
|
||||
String key = nde.SubKeys().FetchDataOrFail("key");
|
||||
GfmlTkn valTkn = nde.SubKeys().FetchDataTknOrNull("val");
|
||||
return GfmlDefaultItem.new_(typeKey, key, valTkn);
|
||||
@@ -55,7 +59,7 @@ class GfmlDefaultItem {
|
||||
public String TypeKey() {return typeKey;} private String typeKey;
|
||||
public String Key() {return key;} private String key;
|
||||
public GfmlObj Val() {return val;} GfmlObj val;
|
||||
public GfmlObj ValPrev() {return valPrev;} @gplx.Internal protected GfmlDefaultItem ValPrev_(GfmlObj tkn) {valPrev = tkn; return this;} GfmlObj valPrev;
|
||||
public GfmlObj ValPrev() {return valPrev;} public GfmlDefaultItem ValPrev_(GfmlObj tkn) {valPrev = tkn; return this;} GfmlObj valPrev;
|
||||
|
||||
public void Exec_bgn(GfmlType type) {
|
||||
GfmlFld fld = type.SubFlds().Get_by(key);
|
||||
@@ -88,13 +92,13 @@ class GfmlDefaultItem {
|
||||
class GfmlDefaultPragma_bgnCmd implements GfmlBldrCmd {
|
||||
public String Key() {return "pragma:gfml.default.bgnCmd";}
|
||||
public void Exec(GfmlBldr bldr, GfmlTkn tkn) {ExecList(bldr.TypeMgr().TypeRegy(), bldr.CurNdeFrame().CurDocPos(), list);}
|
||||
@gplx.Internal protected static void ExecList(GfmlTypRegy regy, GfmlDocPos pos, List_adp list) {
|
||||
public static void ExecList(GfmlTypRegy regy, GfmlDocPos pos, List_adp list) {
|
||||
GfmlType type = GfmlType_.Null;
|
||||
for (Object itemObj : list) {
|
||||
GfmlDefaultItem item = (GfmlDefaultItem)itemObj;
|
||||
if (!String_.Eq(item.TypeKey(), type.Key())) {
|
||||
if (!StringUtl.Eq(item.TypeKey(), type.Key())) {
|
||||
type = regy.FetchOrNull(item.TypeKey(), pos);
|
||||
if (type == GfmlType_.Null) throw Err_.new_wo_type("default type must exist", "typeKey", item.TypeKey());
|
||||
if (type == GfmlType_.Null) throw ErrUtl.NewArgs("default type must exist", "typeKey", item.TypeKey());
|
||||
}
|
||||
type = type.Clone().DocPos_(pos);
|
||||
regy.Add(type);
|
||||
@@ -115,9 +119,9 @@ class GfmlDefaultPragma_endCmd implements GfmlBldrCmd {
|
||||
GfmlType type = GfmlType_.Null;
|
||||
for (Object itemObj : list) {
|
||||
GfmlDefaultItem item = (GfmlDefaultItem)itemObj;
|
||||
if (!String_.Eq(item.TypeKey(), type.Key())) {
|
||||
if (!StringUtl.Eq(item.TypeKey(), type.Key())) {
|
||||
type = regy.FetchOrNull(item.TypeKey());
|
||||
if (type == GfmlType_.Null) throw Err_.new_wo_type("fatal: default type must exist", "typeKey", item.TypeKey());
|
||||
if (type == GfmlType_.Null) throw ErrUtl.NewArgs("fatal: default type must exist", "typeKey", item.TypeKey());
|
||||
}
|
||||
item.Exec_end(type);
|
||||
}
|
||||
|
||||
@@ -1,30 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.ClassUtl;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlPragmaLxrFrm implements GfmlPragma {
|
||||
public String KeyOfPragma() {return "_lxr_frame";}
|
||||
public void Exec(GfmlBldr bldr, GfmlNde pragmaNde) {
|
||||
Compile(bldr, pragmaNde);
|
||||
}
|
||||
@gplx.Internal protected static GfmlLxr Compile(GfmlBldr bldr, GfmlNde ownerNde) {
|
||||
public static GfmlLxr Compile(GfmlBldr bldr, GfmlNde ownerNde) {
|
||||
String key = ownerNde.SubKeys().FetchDataOrFail("key");
|
||||
String type = ownerNde.SubKeys().FetchDataOrNull("type");
|
||||
String bgn = ownerNde.SubKeys().FetchDataOrFail("bgn");
|
||||
String end = ownerNde.SubKeys().FetchDataOrFail("end");
|
||||
GfmlFrame frame = String_.Eq(type, "comment") ? GfmlFrame_.comment_() : GfmlFrame_.quote_();
|
||||
GfmlFrame frame = StringUtl.Eq(type, "comment") ? GfmlFrame_.comment_() : GfmlFrame_.quote_();
|
||||
|
||||
GfmlLxr lxr = bldr.Doc().LxrRegy().Get_by(key);
|
||||
if (lxr == null) {
|
||||
@@ -33,7 +36,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 Err_.new_wo_type("lxr is not GfmlLxr_frame", "key", key, "type", Type_.Name_by_obj(lxr));
|
||||
GfmlLxr_frame frameLxr = GfmlLxr_frame.as_(lxr); if (frameLxr == null) throw ErrUtl.NewArgs("lxr is not GfmlLxr_frame", "key", key, "type", ClassUtl.NameByObj(lxr));
|
||||
if (type != null) {
|
||||
// frame = frameLxr.Frame.MakeNew(frameLxr);
|
||||
}
|
||||
@@ -48,7 +51,7 @@ class GfmlPragmaLxrFrm implements GfmlPragma {
|
||||
for (int i = 0; i < ownerNde.SubHnds().Count(); i++) {
|
||||
GfmlNde subNde = (GfmlNde)ownerNde.SubHnds().Get_at(i);
|
||||
GfmlLxr subLxr = null;
|
||||
if (String_.Eq(subNde.Hnd(), "sym"))
|
||||
if (StringUtl.Eq(subNde.Hnd(), "sym"))
|
||||
subLxr = GfmlPragmaLxrSym.Compile(bldr, subNde);
|
||||
lxr.SubLxr_Add(subLxr);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlPragmaLxrSym implements GfmlPragma {
|
||||
public String KeyOfPragma() {return "_lxr_sym";}
|
||||
public void Exec(GfmlBldr bldr, GfmlNde pragmaNde) {
|
||||
Compile(bldr, pragmaNde);
|
||||
}
|
||||
@gplx.Internal protected static GfmlLxr Compile(GfmlBldr bldr, GfmlNde ownerNde) {
|
||||
public static GfmlLxr Compile(GfmlBldr bldr, GfmlNde ownerNde) {
|
||||
String key = ownerNde.SubKeys().FetchDataOrFail("key");
|
||||
String raw = ownerNde.SubKeys().FetchDataOrFail("raw");
|
||||
String val = ownerNde.SubKeys().FetchDataOr("val", raw);
|
||||
@@ -36,7 +37,7 @@ class GfmlPragmaLxrSym implements GfmlPragma {
|
||||
GfmlTkn curTkn = lxr.CmdTkn();
|
||||
if (raw == null) raw = curTkn.Raw();
|
||||
if (val == null) val = curTkn.Val();
|
||||
if (String_.Eq(cmdTkn.Raw(), GfmlTkn_.NullRaw)) cmd = bldr.Doc().CmdRegy().GetOrFail(curTkn.Cmd_of_Tkn().Key());
|
||||
if (StringUtl.Eq(cmdTkn.Raw(), GfmlTkn_.NullRaw)) cmd = bldr.Doc().CmdRegy().GetOrFail(curTkn.Cmd_of_Tkn().Key());
|
||||
|
||||
GfmlTkn tkn = GfmlTkn_.singleton_(key, raw, val, cmd);
|
||||
lxr.CmdTkn_set(tkn);
|
||||
|
||||
@@ -13,8 +13,11 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.lists.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import gplx.types.basics.lists.Ordered_hash;
|
||||
import gplx.types.basics.lists.Ordered_hash_;
|
||||
class GfmlPragmaType implements GfmlPragma {
|
||||
public String KeyOfPragma() {return pragmaKey;} private String pragmaKey = "_type";
|
||||
public void Exec(GfmlBldr bldr, GfmlNde pragmaNde) {
|
||||
@@ -46,7 +49,7 @@ class GfmlPragmaType implements GfmlPragma {
|
||||
return makr.Xto_bry();
|
||||
}
|
||||
public static final String CacheLog_key = "log:type";
|
||||
@gplx.Internal protected static void ExecList(GfmlTypRegy regy, Ordered_hash list, List_adp replaced) {
|
||||
public static void ExecList(GfmlTypRegy regy, Ordered_hash list, List_adp replaced) {
|
||||
for (Object typeObj : list) {
|
||||
GfmlType type = (GfmlType)typeObj;
|
||||
if (regy.Has(type.Key()))
|
||||
@@ -58,7 +61,7 @@ class GfmlPragmaType implements GfmlPragma {
|
||||
class GfmlPragmaType_endCmd implements GfmlBldrCmd {
|
||||
public String Key() {return "cmd.gfml.type.end";}
|
||||
public void Exec(GfmlBldr bldr, GfmlTkn tkn) {ExecList(bldr.TypeMgr().TypeRegy(), list, replaced);}
|
||||
@gplx.Internal protected static void ExecList(GfmlTypRegy regy, Ordered_hash list, List_adp replaced) {
|
||||
public static void ExecList(GfmlTypRegy regy, Ordered_hash list, List_adp replaced) {
|
||||
for (Object typeObj : list) {
|
||||
GfmlType type = (GfmlType)typeObj;
|
||||
regy.Del(type);
|
||||
|
||||
@@ -1,27 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
class GfmlPragmaVar implements GfmlPragma {
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.Hash_adp;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlPragmaVar implements GfmlPragma {
|
||||
public String KeyOfPragma() {return pragmaKey;} public void PragmaKey_set(String v) {pragmaKey = v;} private String pragmaKey = "_var";
|
||||
public void Exec(GfmlBldr bldr, GfmlNde pragmaNde) {
|
||||
List_adp list = Compile(pragmaNde);
|
||||
ExecList(bldr.Vars(), list);
|
||||
bldr.Doc().PragmaMgr().EndCmds_add(bldr.CurNdeFrame().CurDocPos().NewUp(), GfmlPragmaVar_scopeEndCmd.new_(list));
|
||||
}
|
||||
@gplx.Internal protected List_adp Compile(GfmlNde pragmaNde) {
|
||||
public List_adp Compile(GfmlNde pragmaNde) {
|
||||
List_adp list = List_adp_.New();
|
||||
for (int i = 0; i < pragmaNde.SubHnds().Count(); i++) {
|
||||
GfmlNde subNde = (GfmlNde)pragmaNde.SubHnds().Get_at(i);
|
||||
@@ -30,7 +34,7 @@ class GfmlPragmaVar implements GfmlPragma {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@gplx.Internal protected GfmlVarItm CompileItmNde(GfmlNde subNde) {
|
||||
public GfmlVarItm CompileItmNde(GfmlNde subNde) {
|
||||
String key = subNde.SubKeys().FetchDataOrFail("key");
|
||||
GfmlAtr valAtr = (GfmlAtr)subNde.SubKeys().Get_by("val");
|
||||
String ctx = subNde.SubKeys().FetchDataOrNull("ctx"); if (ctx == null) ctx = GfmlVarCtx_.DefaultKey;
|
||||
@@ -51,12 +55,12 @@ class GfmlPragmaVar implements GfmlPragma {
|
||||
}
|
||||
public static GfmlPragmaVar new_() {return new GfmlPragmaVar();} GfmlPragmaVar() {}
|
||||
public static GfmlVarCtx FetchIfNew(GfmlVarCtx ctx, GfmlVarItm var, Hash_adp cache) {// reused in two procs
|
||||
if (ctx == null || !String_.Eq(ctx.Key(), var.CtxKey()))
|
||||
if (ctx == null || !StringUtl.Eq(ctx.Key(), var.CtxKey()))
|
||||
ctx = GfmlVarCtx_.FetchFromCacheOrNew(cache, var.CtxKey());
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
class GfmlPragmaVar_scopeEndCmd implements GfmlBldrCmd {
|
||||
class GfmlPragmaVar_scopeEndCmd implements GfmlBldrCmd {
|
||||
public String Key() {return "cmd:gfml.var.expire";}
|
||||
public void Exec(GfmlBldr bldr, GfmlTkn tkn) {
|
||||
Hash_adp cache = bldr.Vars();
|
||||
|
||||
@@ -13,7 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.Hash_adp;
|
||||
import gplx.types.basics.lists.Hash_adp_;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlVarCtx {
|
||||
public String Key() {return key;} private String key;
|
||||
public void Add_if_dupe_use_nth(GfmlVarItm itm) {hash.AddIfDupeUseNth(itm.Key(), itm);}
|
||||
@@ -34,7 +37,7 @@ class GfmlVarCtx_ {
|
||||
Hash_adp ctxRegy = FetchRegyOrNew(cache);
|
||||
GfmlVarCtx rv = (GfmlVarCtx)ctxRegy.GetByOrNull(ctxKey);
|
||||
if (rv == null) {
|
||||
rv = (String_.Eq(ctxKey, DefaultKey))
|
||||
rv = (StringUtl.Eq(ctxKey, DefaultKey))
|
||||
? default_(ctxKey)
|
||||
: GfmlVarCtx.new_(ctxKey);
|
||||
ctxRegy.Add(rv.Key(), rv);
|
||||
@@ -44,7 +47,7 @@ class GfmlVarCtx_ {
|
||||
static GfmlVarCtx default_(String ctxKey) {
|
||||
GfmlVarCtx rv = GfmlVarCtx.new_(ctxKey);
|
||||
rv.Add_if_dupe_use_nth(GfmlVarItm.new_("t", GfmlTkn_.raw_("\t"), GfmlVarCtx_.DefaultKey));
|
||||
rv.Add_if_dupe_use_nth(GfmlVarItm.new_("n", GfmlTkn_.raw_(String_.CrLf), GfmlVarCtx_.DefaultKey));
|
||||
rv.Add_if_dupe_use_nth(GfmlVarItm.new_("n", GfmlTkn_.raw_(StringUtl.CrLf), GfmlVarCtx_.DefaultKey));
|
||||
return rv;
|
||||
}
|
||||
static Hash_adp FetchRegyOrNew(Hash_adp cache) {
|
||||
|
||||
@@ -13,18 +13,18 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml; import gplx.*;
|
||||
class GfmlVarItm implements GfmlScopeItm {
|
||||
public String Key() {return key;} private String key;
|
||||
public GfmlDocPos DocPos() {return docPos;} public GfmlVarItm DocPos_(GfmlDocPos v) {docPos = v; return this;} GfmlDocPos docPos = GfmlDocPos_.Null;
|
||||
public GfmlTkn Tkn() {return tkn;} public void Tkn_set(GfmlTkn v) {tkn = v;} GfmlTkn tkn;
|
||||
public String TknVal() {return tkn.Val();}
|
||||
public String CtxKey() {return ctxKey;} private String ctxKey;
|
||||
@gplx.Internal protected void Scope_bgn(GfmlVarCtx ctx) {ctx.Add_if_dupe_use_nth(this);}
|
||||
@gplx.Internal protected void Scope_end(GfmlVarCtx ctx) {ctx.Del(key);}
|
||||
public static GfmlVarItm new_(String key, GfmlTkn tkn, String ctxKey) {
|
||||
GfmlVarItm rv = new GfmlVarItm();
|
||||
rv.key = key; rv.tkn = tkn; rv.ctxKey = ctxKey;
|
||||
return rv;
|
||||
} GfmlVarItm() {}
|
||||
}
|
||||
public String Key() {return key;} private String key;
|
||||
public GfmlDocPos DocPos() {return docPos;} public GfmlVarItm DocPos_(GfmlDocPos v) {docPos = v; return this;} GfmlDocPos docPos = GfmlDocPos_.Null;
|
||||
public GfmlTkn Tkn() {return tkn;} public void Tkn_set(GfmlTkn v) {tkn = v;} GfmlTkn tkn;
|
||||
public String TknVal() {return tkn.Val();}
|
||||
public String CtxKey() {return ctxKey;} private String ctxKey;
|
||||
public void Scope_bgn(GfmlVarCtx ctx) {ctx.Add_if_dupe_use_nth(this);}
|
||||
public void Scope_end(GfmlVarCtx ctx) {ctx.Del(key);}
|
||||
public static GfmlVarItm new_(String key, GfmlTkn tkn, String ctxKey) {
|
||||
GfmlVarItm rv = new GfmlVarItm();
|
||||
rv.key = key; rv.tkn = tkn; rv.ctxKey = ctxKey;
|
||||
return rv;
|
||||
} GfmlVarItm() {}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
class GfmlVarTkn implements GfmlTkn {
|
||||
public int ObjType() {return GfmlObj_.Type_tkn;}
|
||||
public String Key() {return key;} private String key;
|
||||
@@ -25,11 +26,11 @@ 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 Err_.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 ErrUtl.NewInvalidOp("makeNew cannot make copy of token with only raw").ArgsAdd("key", key).ArgsAdd("rawNew", rawNew).ArgsAdd("valNew", valNew);}
|
||||
public String TknType() {return "evalTkn";}
|
||||
|
||||
GfmlVarCtx ctx; String varKey;
|
||||
@gplx.Internal protected GfmlVarTkn(String key, GfmlTkn[] ary, GfmlVarCtx ctx, String varKey) {
|
||||
public GfmlVarTkn(String key, GfmlTkn[] ary, GfmlVarCtx ctx, String varKey) {
|
||||
this.key = key; this.ary = ary;
|
||||
this.ctx = ctx; this.varKey = varKey;
|
||||
this.val = ctx.Fetch_Val(varKey);
|
||||
|
||||
@@ -13,19 +13,22 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.texts.*; /*CharStream*/
|
||||
package gplx.gfml;
|
||||
import gplx.core.texts.*; /*CharStream*/
|
||||
import gplx.libs.dlgs.UsrMsg;
|
||||
import gplx.types.basics.lists.Hash_adp;
|
||||
import gplx.types.basics.lists.Hash_adp_;
|
||||
public class GfmlBldr {
|
||||
@gplx.Internal protected GfmlDoc Doc() {return gdoc;} GfmlDoc gdoc = GfmlDoc.new_();
|
||||
@gplx.Internal protected GfmlFrame CurFrame() {return curFrame;} GfmlFrame curFrame;
|
||||
@gplx.Internal protected GfmlFrame_nde CurNdeFrame() {return curNdeFrame;} GfmlFrame_nde curNdeFrame;
|
||||
@gplx.Internal protected GfmlNde CurNde() {return curNdeFrame.CurNde();}
|
||||
@gplx.Internal protected GfmlTypeMgr TypeMgr() {return typeMgr;} GfmlTypeMgr typeMgr = GfmlTypeMgr.new_();
|
||||
@gplx.Internal protected Hash_adp Vars() {return vars;} Hash_adp vars = Hash_adp_.New();
|
||||
@gplx.Internal protected int StreamPos() {return streamPos;} int streamPos;
|
||||
@gplx.Internal protected void ThrowErrors_set(boolean v) {throwErrors = v;} private boolean throwErrors = true;
|
||||
@gplx.Internal protected int PrvSymType() {return prvSymType;} @gplx.Internal protected void PrvSymType_set(int v) {prvSymType = v;} int prvSymType = GfmlNdeSymType.Null;
|
||||
@gplx.Internal protected int ChainIdNext() {return chainIdNext++;} int chainIdNext = 1;
|
||||
public GfmlDoc Doc() {return gdoc;} GfmlDoc gdoc = GfmlDoc.new_();
|
||||
public GfmlFrame CurFrame() {return curFrame;} GfmlFrame curFrame;
|
||||
public GfmlFrame_nde CurNdeFrame() {return curNdeFrame;} GfmlFrame_nde curNdeFrame;
|
||||
public GfmlNde CurNde() {return curNdeFrame.CurNde();}
|
||||
public GfmlTypeMgr TypeMgr() {return typeMgr;} GfmlTypeMgr typeMgr = GfmlTypeMgr.new_();
|
||||
public Hash_adp Vars() {return vars;} Hash_adp vars = Hash_adp_.New();
|
||||
public int StreamPos() {return streamPos;} int streamPos;
|
||||
public void ThrowErrors_set(boolean v) {throwErrors = v;} private boolean throwErrors = true;
|
||||
public int PrvSymType() {return prvSymType;} public void PrvSymType_set(int v) {prvSymType = v;} int prvSymType = GfmlNdeSymType.Null;
|
||||
public int ChainIdNext() {return chainIdNext++;} int chainIdNext = 1;
|
||||
public GfmlDoc XtoGfmlDoc(String raw) {
|
||||
Init(raw);
|
||||
CharStream stream = CharStream.pos0_(raw);
|
||||
@@ -49,12 +52,12 @@ public class GfmlBldr {
|
||||
curNdeFrame.NullArea_set(true);
|
||||
curFrame = curNdeFrame;
|
||||
}
|
||||
@gplx.Internal protected void Frames_push(GfmlFrame newFrame) {
|
||||
public void Frames_push(GfmlFrame newFrame) {
|
||||
frameStack.Push(curFrame);
|
||||
curFrame = newFrame;
|
||||
if (curFrame.FrameType() == GfmlFrame_.Type_nde) curNdeFrame = GfmlFrame_nde_.as_(curFrame);
|
||||
}
|
||||
@gplx.Internal protected void Frames_end() {
|
||||
public void Frames_end() {
|
||||
if (frameStack.Count() == 0) {
|
||||
UsrMsgs_fail(GfmlUsrMsgs.fail_Frame_danglingBgn());
|
||||
return;
|
||||
@@ -64,7 +67,7 @@ public class GfmlBldr {
|
||||
oldFrame.Build_end(this, curFrame);
|
||||
if (curFrame.FrameType() == GfmlFrame_.Type_nde) curNdeFrame = GfmlFrame_nde_.as_(curFrame);
|
||||
}
|
||||
@gplx.Internal protected void UsrMsgs_fail(UsrMsg um) {
|
||||
public void UsrMsgs_fail(UsrMsg um) {
|
||||
GfmlUsrMsgs.MakeErr(this, um, raw);
|
||||
stopBldr = true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.Hash_adp;
|
||||
import gplx.types.basics.lists.Hash_adp_;
|
||||
public interface GfmlBldrCmd {
|
||||
String Key();
|
||||
void Exec(GfmlBldr bldr, GfmlTkn tkn);
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlBldrCmd_pendingTkns_add implements GfmlBldrCmd {
|
||||
public String Key() {return "gfml.pendingTkns_add";}
|
||||
public void Exec(GfmlBldr bldr, GfmlTkn tkn) {bldr.CurFrame().WaitingTkns().Add(tkn);}
|
||||
@@ -38,7 +39,7 @@ class GfmlBldrCmd_ndeBody_bgn implements GfmlBldrCmd {
|
||||
public String Key() {return "gfml.nodeBody_bgn";}
|
||||
public void Exec(GfmlBldr bldr, GfmlTkn tkn) {
|
||||
bldr.CurNdeFrame().NdeBody_bgn(tkn);
|
||||
bldr.CurNdeFrame().BgnPos_set(bldr.StreamPos() - String_.Len(tkn.Raw()));// stream has already advanced tkn.len so subtract
|
||||
bldr.CurNdeFrame().BgnPos_set(bldr.StreamPos() - StringUtl.Len(tkn.Raw()));// stream has already advanced tkn.len so subtract
|
||||
}
|
||||
public static final GfmlBldrCmd_ndeBody_bgn Instance = new GfmlBldrCmd_ndeBody_bgn(); GfmlBldrCmd_ndeBody_bgn() {}
|
||||
}
|
||||
@@ -78,7 +79,7 @@ class GfmlBldrCmd_frameBgn implements GfmlBldrCmd {
|
||||
GfmlFrame newFrame = frame.MakeNew(lxr.SubLxr());
|
||||
bldr.Frames_push(newFrame);
|
||||
bldr.CurFrame().WaitingTkns().Add(tkn);
|
||||
bldr.CurNdeFrame().BgnPos_set(bldr.StreamPos() - String_.Len(tkn.Raw()));// stream has already advanced tkn.len so subtract
|
||||
bldr.CurNdeFrame().BgnPos_set(bldr.StreamPos() - StringUtl.Len(tkn.Raw()));// stream has already advanced tkn.len so subtract
|
||||
}
|
||||
GfmlLxr lxr; GfmlFrame frame;
|
||||
public static GfmlBldrCmd_frameBgn new_(GfmlFrame frame, GfmlLxr lxr) {
|
||||
@@ -97,7 +98,7 @@ class GfmlBldrCmd_frameEnd implements GfmlBldrCmd {
|
||||
else
|
||||
bldr.CurFrame().WaitingTkns().Add(tkn);
|
||||
if (bldr.CurNdeFrame().CurNdeStartType() == GfmlNdeStartType.Prop
|
||||
&& String_.Eq(tkn.Raw(), "}")) return;
|
||||
&& StringUtl.Eq(tkn.Raw(), "}")) return;
|
||||
bldr.Frames_end();
|
||||
}
|
||||
int ndeSymType;
|
||||
@@ -112,7 +113,7 @@ class GfmlBldrCmd_whitespace implements GfmlBldrCmd {
|
||||
public String Key() {return "gfml.whitespace_exec";}
|
||||
public void Exec(GfmlBldr bldr, GfmlTkn tkn) {
|
||||
if (bldr.CurNdeFrame().waitingTkns.Len() > 0) {
|
||||
GfmlObj t = (GfmlObj)bldr.CurNdeFrame().waitingTkns.Get_at(bldr.CurNdeFrame().waitingTkns.Len() - 1);
|
||||
GfmlObj t = (GfmlObj)bldr.CurNdeFrame().waitingTkns.GetAt(bldr.CurNdeFrame().waitingTkns.Len() - 1);
|
||||
if (t.ObjType() == GfmlObj_.Type_nde)
|
||||
bldr.CurNdeFrame().IdxNdeBgn_set(bldr.CurNdeFrame().WaitingTkns().Len() + 1);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
class GfmlBldr_ {
|
||||
@gplx.Internal protected static GfmlBldr new_() {return new GfmlBldr();}
|
||||
@gplx.Internal protected static GfmlBldr default_() {
|
||||
public static GfmlBldr new_() {return new GfmlBldr();}
|
||||
public static GfmlBldr default_() {
|
||||
GfmlBldr rv = new GfmlBldr();
|
||||
GfmlLxr rootLxr = GfmlDocLxrs.Root_lxr();
|
||||
GfmlDocLxrs.Default_lxr(rv.Doc().LxrRegy(), rootLxr);
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlFrame_ {
|
||||
public static GfmlFrame comment_() {return new GfmlFrame_comment();}
|
||||
public static GfmlFrame quote_() {return new GfmlFrame_quote();}
|
||||
@@ -28,7 +30,7 @@ abstract class GfmlFrame_base implements GfmlFrame {
|
||||
public GfmlLxr Lxr() {return lxr;} GfmlLxr lxr;
|
||||
public abstract int FrameType();
|
||||
public int BgnPos() {return bgnPos;} public void BgnPos_set(int v) {bgnPos = v;} int bgnPos;
|
||||
public GfmlObjList WaitingTkns() {return waitingTkns;} @gplx.Internal protected final GfmlObjList waitingTkns = GfmlObjList.new_();
|
||||
public GfmlObjList WaitingTkns() {return waitingTkns;} public final GfmlObjList waitingTkns = GfmlObjList.new_();
|
||||
public GfmlFrame MakeNew(GfmlLxr newLxr) {GfmlFrame_base rv = MakeNew_hook(); rv.ctor_(newLxr); return rv;}
|
||||
public abstract void Build_end(GfmlBldr bldr, GfmlFrame ownerFrame);
|
||||
protected abstract GfmlFrame_base MakeNew_hook();
|
||||
@@ -65,9 +67,9 @@ class GfmlFrame_eval extends GfmlFrame_base {
|
||||
return new GfmlVarTkn("tkn:eval", composite.SubTkns(), evalContext, varKey);
|
||||
}
|
||||
static String[] ExtractContextKey(String raw) {
|
||||
String[] ary = String_.Split(raw, ".");
|
||||
String[] ary = StringUtl.Split(raw, ".");
|
||||
if (ary.length == 2) return ary; // NOOP: elems already assigned; context = ary[0]; key = ary[1];
|
||||
if (ary.length > 2) throw Err_.new_wo_type("invalid context key for eval frame; should have 0 or 1 dlms", "key", raw);
|
||||
if (ary.length > 2) throw ErrUtl.NewArgs("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];
|
||||
@@ -75,7 +77,7 @@ class GfmlFrame_eval extends GfmlFrame_base {
|
||||
}
|
||||
}
|
||||
class GfmlFrameUtl {
|
||||
@gplx.Internal protected static void AddFrameTkn(GfmlFrame ownerFrame, GfmlTkn frameTkn) {
|
||||
public static void AddFrameTkn(GfmlFrame ownerFrame, GfmlTkn frameTkn) {
|
||||
GfmlFrame_nde nodeFrame = GfmlFrame_nde_.as_(ownerFrame);
|
||||
if (nodeFrame != null) // ownerFrame is node: set frameTkn as dataTkn
|
||||
nodeFrame.DatTkn_set(frameTkn);
|
||||
|
||||
@@ -162,8 +162,8 @@ class GfmlFrame_nde extends GfmlFrame_base {
|
||||
}
|
||||
@Override protected GfmlFrame_base MakeNew_hook() {return new GfmlFrame_nde();}
|
||||
public void IdxNdeBgn_set(int v) {tknMgr.IdxNdeBgn_set(v);}
|
||||
@gplx.Internal protected void WaitingTkns_AddSym(GfmlTkn tkn, int type) {waitingTkns.Add(tkn); bldr.PrvSymType_set(type);}
|
||||
@gplx.Internal protected void HndTkn_SetFromDatTkn() {
|
||||
public void WaitingTkns_AddSym(GfmlTkn tkn, int type) {waitingTkns.Add(tkn); bldr.PrvSymType_set(type);}
|
||||
public void HndTkn_SetFromDatTkn() {
|
||||
GfmlTkn hndTkn = tknMgr.DatTkn_pop();
|
||||
if (hndTkn != GfmlTkn_.Null)
|
||||
nde.HndTkn_set(hndTkn);
|
||||
@@ -201,22 +201,22 @@ class GfmlFrame_nde extends GfmlFrame_base {
|
||||
class GfmlFrame_nde_ {
|
||||
public static GfmlFrame_nde as_(Object obj) {return obj instanceof GfmlFrame_nde ? (GfmlFrame_nde)obj : null;}
|
||||
public static GfmlFrame_nde node_(GfmlBldr bldr, GfmlNde newNde) {return GfmlFrame_nde.new_(bldr, newNde, bldr.CurFrame().Lxr());}
|
||||
@gplx.Internal protected static GfmlFrame_nde root_(GfmlBldr bldr, GfmlNde newNde, GfmlLxr newLxr) {return GfmlFrame_nde.new_(bldr, newNde, newLxr);}
|
||||
@gplx.Internal protected static final GfmlFrame_nde OwnerRoot_ = null;
|
||||
@gplx.Internal protected static void TransferToNde(GfmlObjList waitingTkns, GfmlNde nde, int bgn) {
|
||||
public static GfmlFrame_nde root_(GfmlBldr bldr, GfmlNde newNde, GfmlLxr newLxr) {return GfmlFrame_nde.new_(bldr, newNde, newLxr);}
|
||||
public static final GfmlFrame_nde OwnerRoot_ = null;
|
||||
public static void TransferToNde(GfmlObjList waitingTkns, GfmlNde nde, int bgn) {
|
||||
int end = waitingTkns.Len();
|
||||
for (int i = bgn; i < end; i++) {
|
||||
GfmlObj tkn = waitingTkns.Get_at(i);
|
||||
GfmlObj tkn = waitingTkns.GetAt(i);
|
||||
nde.SubObjs_Add(tkn);
|
||||
}
|
||||
if (bgn != end) // ignore if bgn == end
|
||||
waitingTkns.DelRange(bgn, end - 1);
|
||||
}
|
||||
@gplx.Internal protected static void TransferToAtr(GfmlObjList src, GfmlAtr trg, int bgn, int end) {
|
||||
public static void TransferToAtr(GfmlObjList src, GfmlAtr trg, int bgn, int end) {
|
||||
int len = end - bgn;
|
||||
if (len <= 0 || end == -1) return; // -1 b/c calling proc passes end - 1, and end may be 0
|
||||
for (int i = 0; i < len; i++)
|
||||
trg.SubObjs_Add(src.Get_at(i + bgn));
|
||||
trg.SubObjs_Add(src.GetAt(i + bgn));
|
||||
src.DelRange(bgn, end - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,14 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlFrame_ndeTknMgr {
|
||||
public int IdxAtrBgn() {return idxAtrBgn;} int idxAtrBgn, idxAtrEnd;
|
||||
public int IdxNdeBgn() {return idxNdeBgn;} public void IdxNdeBgn_set(int v) {idxNdeBgn = v;} int idxNdeBgn = 0;
|
||||
void IdxAtr_clear() {idxAtrBgn = 0; idxAtrEnd = -1;}
|
||||
@gplx.Internal protected void IdxAtrBgn_setHack(int v) {idxAtrBgn = v; idxAtrEnd = v + 1;}
|
||||
@gplx.Internal protected void IdxNdeBgn_setToAtrBgn() {
|
||||
public void IdxAtrBgn_setHack(int v) {idxAtrBgn = v; idxAtrEnd = v + 1;}
|
||||
public void IdxNdeBgn_setToAtrBgn() {
|
||||
if (idxAtrEnd == -1) return;
|
||||
idxNdeBgn = idxAtrBgn;
|
||||
this.IdxAtr_clear(); // newNode starting; old atr range no longer valid
|
||||
@@ -29,7 +30,7 @@ class GfmlFrame_ndeTknMgr {
|
||||
if (datTkn == GfmlTkn_.Null) return;
|
||||
hndTkn = DatTkn_pop();
|
||||
}
|
||||
@gplx.Internal protected void HndTkn_setByDatTknOrFail() {
|
||||
public void HndTkn_setByDatTknOrFail() {
|
||||
if (datTkn == GfmlTkn_.Null) {bldr.UsrMsgs_fail(GfmlUsrMsgs.fail_DatTkn_notFound()); return;} // ex: < : >
|
||||
if (hndTkn != GfmlTkn_.Null) {bldr.UsrMsgs_fail(GfmlUsrMsgs.fail_HndTkn_alreadyExists()); return;} // ex: < a:b: >
|
||||
hndTkn = DatTkn_pop();
|
||||
@@ -44,29 +45,29 @@ class GfmlFrame_ndeTknMgr {
|
||||
if (keyTkn != GfmlTkn_.Null) {bldr.UsrMsgs_fail(GfmlUsrMsgs.fail_KeyTkn_alreadyExists()); return;} // ex: < a=[b=] >
|
||||
keyTkn = DatTkn_pop();
|
||||
}
|
||||
@gplx.Internal protected GfmlTkn DatTkn_pop() {GfmlTkn rv = datTkn; datTkn = GfmlTkn_.Null; return rv;} GfmlTkn datTkn = GfmlTkn_.Null;
|
||||
@gplx.Internal protected void DatTkn_set(GfmlTkn tkn) {
|
||||
public GfmlTkn DatTkn_pop() {GfmlTkn rv = datTkn; datTkn = GfmlTkn_.Null; return rv;} GfmlTkn datTkn = GfmlTkn_.Null;
|
||||
public void DatTkn_set(GfmlTkn tkn) {
|
||||
this.ConsumeWaitingDatTkn(frame.CurNde());
|
||||
idxAtrBgn = frame.waitingTkns.Len();
|
||||
idxAtrEnd = idxAtrBgn + 1;
|
||||
frame.waitingTkns.Add(tkn);
|
||||
datTkn = tkn;
|
||||
}
|
||||
@gplx.Internal protected void ExecMakeAtr(GfmlTkn itmKeyTkn, GfmlTkn valTkn) {
|
||||
public void ExecMakeAtr(GfmlTkn itmKeyTkn, GfmlTkn valTkn) {
|
||||
frame.waitingTkns.Add(valTkn);
|
||||
idxAtrEnd = frame.waitingTkns.Len();
|
||||
this.MakeAtr(itmKeyTkn, valTkn);
|
||||
}
|
||||
@gplx.Internal protected void ExecXferTkns_ndeAll(GfmlNde nde) {ExecXferTkns(nde, 0);}
|
||||
@gplx.Internal protected void ExecXferTkns_ndeBgn(GfmlNde nde) {ExecXferTkns(nde, this.IdxNdeBgn());}
|
||||
public void ExecXferTkns_ndeAll(GfmlNde nde) {ExecXferTkns(nde, 0);}
|
||||
public void ExecXferTkns_ndeBgn(GfmlNde nde) {ExecXferTkns(nde, this.IdxNdeBgn());}
|
||||
void ExecXferTkns(GfmlNde nde, int from) {
|
||||
this.ConsumeWaitingDatTkn(nde);
|
||||
GfmlFrame_nde_.TransferToNde(frame.waitingTkns, nde, from);
|
||||
}
|
||||
@gplx.Internal protected void ConsumeWaitingDatTkn(GfmlNde nde) {
|
||||
public void ConsumeWaitingDatTkn(GfmlNde nde) {
|
||||
if (datTkn == GfmlTkn_.Null) return; // no datTkn; return;
|
||||
if ( bldr.CurNdeFrame().CurNdeStartType() == GfmlNdeStartType.Dot
|
||||
&& String_.Len_eq_0(nde.Hnd())) // if cur hnd is empty, use datTkn for hndTkn
|
||||
&& StringUtl.IsNullOrEmpty(nde.Hnd())) // if cur hnd is empty, use datTkn for hndTkn
|
||||
frame.HndTkn_SetFromDatTkn();
|
||||
else
|
||||
this.MakeAtr(GfmlTkn_.Null, this.DatTkn_pop());
|
||||
|
||||
@@ -13,8 +13,13 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import gplx.types.basics.utls.IntUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import gplx.types.commons.String_bldr;
|
||||
import gplx.types.commons.String_bldr_;
|
||||
class GfmlStringHighlighter {
|
||||
public String Raw() {return raw;} public GfmlStringHighlighter Raw_(String v) {raw = v; return this;} private String raw;
|
||||
public int ExcerptLen() {return excerptLen;} public GfmlStringHighlighter ExcerptLen_(int v) {excerptLen = v; return this;} int excerptLen = 40;
|
||||
@@ -31,24 +36,24 @@ class GfmlStringHighlighter {
|
||||
String_bldr posBfr = String_bldr_.new_(), rawBfr = String_bldr_.new_(), symBfr = String_bldr_.new_();
|
||||
List_adp symList = List_adp_.New();
|
||||
int bgnPos = 0, endPos = 0;
|
||||
int rawLen = String_.Len(raw); int rawLenDigits = Int_.DigitCount(rawLen);
|
||||
int rawLen = StringUtl.Len(raw); int rawLenDigits = IntUtl.CountDigits(rawLen);
|
||||
int rawBfrBgn = -1, marksLastIdx = marks.IdxLast();
|
||||
for (int i = 0; i < marks.Len(); i++) {
|
||||
GfmlStringHighlighterMarker curMark = (GfmlStringHighlighterMarker)marks.Get_at(i);
|
||||
GfmlStringHighlighterMarker nxtMark = i == marksLastIdx ? GfmlStringHighlighterMarker.Null : (GfmlStringHighlighterMarker)marks.Get_at(i + 1);
|
||||
GfmlStringHighlighterMarker curMark = (GfmlStringHighlighterMarker)marks.GetAt(i);
|
||||
GfmlStringHighlighterMarker nxtMark = i == marksLastIdx ? GfmlStringHighlighterMarker.Null : (GfmlStringHighlighterMarker)marks.GetAt(i + 1);
|
||||
// bgnPos
|
||||
bgnPos = XtoBgnPos(curMark.Pos(), endPos);
|
||||
if (i == 0) rawBfrBgn = bgnPos;
|
||||
|
||||
// endPos
|
||||
int nxtMarkPos = nxtMark == GfmlStringHighlighterMarker.Null ? Int_.Max_value : nxtMark.Pos();
|
||||
int nxtMarkPos = nxtMark == GfmlStringHighlighterMarker.Null ? IntUtl.MaxValue : nxtMark.Pos();
|
||||
endPos = curMark.Pos() + excerptLen;
|
||||
if (endPos >= nxtMarkPos) endPos = nxtMarkPos;
|
||||
if (endPos > rawLen ) endPos = rawLen + 1;
|
||||
|
||||
// build bfrs
|
||||
for (int j = bgnPos; j < endPos; j++) {
|
||||
char rawChar = j == rawLen ? ' ' : String_.CharAt(raw, j);
|
||||
char rawChar = j == rawLen ? ' ' : StringUtl.CharAt(raw, j);
|
||||
if (rawChar == '\t') {posBfr.Add("t"); rawBfr.Add(" ");}
|
||||
else if (rawChar == '\n') {posBfr.Add("n"); rawBfr.Add(" ");}
|
||||
else {
|
||||
@@ -64,27 +69,27 @@ class GfmlStringHighlighter {
|
||||
int nxtMarkBgn = XtoBgnPos(nxtMark.Pos(), endPos);
|
||||
int gap = nxtMarkBgn - endPos;
|
||||
if (gap > 0) {
|
||||
int gapDigits = Int_.DigitCount(gap);
|
||||
posBfr.Add_fmt("[{0}]", Int_.To_str_pad_bgn_zero(gap, gapDigits));
|
||||
rawBfr.Add_fmt("[{0}]", String_.Repeat(".", gapDigits));
|
||||
symBfr.Add_fmt(" {0} ", String_.Repeat(" ", gapDigits));
|
||||
int gapDigits = IntUtl.CountDigits(gap);
|
||||
posBfr.AddFmt("[{0}]", IntUtl.ToStrPadBgnZero(gap, gapDigits));
|
||||
rawBfr.AddFmt("[{0}]", StringUtl.Repeat(".", gapDigits));
|
||||
symBfr.AddFmt(" {0} ", StringUtl.Repeat(" ", gapDigits));
|
||||
}
|
||||
if (curMark.Sym() != ' ')
|
||||
symList.Add(String_.Format("[{0}] {1} {2}", Int_.To_str_pad_bgn_zero(curMark.Pos(), rawLenDigits), curMark.Sym(), curMark.Msg()));
|
||||
symList.Add(StringUtl.Format("[{0}] {1} {2}", IntUtl.ToStrPadBgnZero(curMark.Pos(), rawLenDigits), curMark.Sym(), curMark.Msg()));
|
||||
}
|
||||
if (rawBfrBgn == 0) {
|
||||
posBfr.Add_at(0, "<");
|
||||
rawBfr.Add_at(0, " ");
|
||||
symBfr.Add_at(0, " ");
|
||||
posBfr.AddAt(0, "<");
|
||||
rawBfr.AddAt(0, " ");
|
||||
symBfr.AddAt(0, " ");
|
||||
}
|
||||
List_adp rv = List_adp_.New();
|
||||
rv.Add(posBfr.To_str());
|
||||
rv.Add(rawBfr.To_str());
|
||||
rv.Add(symBfr.To_str());
|
||||
rv.Add(posBfr.ToStr());
|
||||
rv.Add(rawBfr.ToStr());
|
||||
rv.Add(symBfr.ToStr());
|
||||
if (symList.Len() > 0)
|
||||
rv.Add("");
|
||||
for (int i = 0; i < symList.Len(); i++)
|
||||
rv.Add((String)symList.Get_at(i));
|
||||
rv.Add((String)symList.GetAt(i));
|
||||
return rv.ToStrAry();
|
||||
}
|
||||
List_adp marks = List_adp_.New();
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.core.stores.*; import gplx.core.gfo_ndes.*;
|
||||
import gplx.frameworks.invks.GfoMsg;
|
||||
import gplx.frameworks.invks.GfoMsg_;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public class GfmlDataNde {
|
||||
public GfmlDoc Doc() {return gdoc;} GfmlDoc gdoc;
|
||||
public DataRdr XtoRdr() {
|
||||
@@ -27,7 +30,7 @@ public class GfmlDataNde {
|
||||
rv.Doc_set(gdoc);
|
||||
return rv;
|
||||
}
|
||||
public static GfmlDataNde new_any_eol_(String raw) {return new_(String_.Replace(raw, String_.CrLf, String_.Lf));}
|
||||
public static GfmlDataNde new_any_eol_(String raw) {return new_(StringUtl.Replace(raw, StringUtl.CrLf, StringUtl.Nl));}
|
||||
public static GfmlDataNde new_(String raw) {
|
||||
GfmlDataNde rv = new GfmlDataNde();
|
||||
GfmlBldr bldr = GfmlBldr_.default_();
|
||||
@@ -49,14 +52,15 @@ public class GfmlDataNde {
|
||||
GfoMsg msg = XtoMsg(gdoc.RootNde());
|
||||
return (GfoMsg)msg.Subs_getAt(0);
|
||||
}
|
||||
private static String StringUtl_Coalesce(String s, String alt) {return StringUtl.IsNullOrEmpty(s) ? alt : s;}
|
||||
static GfoMsg XtoMsg(GfmlNde gnde) {
|
||||
String msgKey = String_.Coalesce(gnde.Key(), gnde.Hnd());
|
||||
String msgKey = StringUtl_Coalesce(gnde.Key(), gnde.Hnd());
|
||||
GfoMsg msg = GfoMsg_.new_parse_(msgKey);
|
||||
for (int i = 0; i < gnde.SubKeys().Count(); i++) {
|
||||
GfmlItm subItm = (GfmlItm)gnde.SubKeys().Get_at(i);
|
||||
if (subItm.ObjType() == GfmlObj_.Type_atr) {
|
||||
GfmlAtr subAtr = (GfmlAtr)subItm;
|
||||
String subAtrKey = String_.Len_eq_0(subAtr.Key()) ? "" : subAtr.Key(); // NOTE: needs to be "" or else will fail in GfoConsole; key will be evaluated against NullKey in GfsCtx
|
||||
String subAtrKey = StringUtl.IsNullOrEmpty(subAtr.Key()) ? "" : subAtr.Key(); // NOTE: needs to be "" or else will fail in GfoConsole; key will be evaluated against NullKey in GfsCtx
|
||||
msg.Add(subAtrKey, subAtr.DatTkn().Val());
|
||||
}
|
||||
else {
|
||||
@@ -93,7 +97,7 @@ class GfmlDataWtr2 extends DataWtr_base implements DataWtr {
|
||||
String To_str(Object obj) {
|
||||
if (obj == null) return "''";
|
||||
String s = obj.toString();
|
||||
return String_.Concat("'", String_.Replace(s, "'", "''"), "'");
|
||||
return StringUtl.Concat("'", StringUtl.Replace(s, "'", "''"), "'");
|
||||
}
|
||||
@Override public SrlMgr SrlMgr_new(Object o) {return new GfmlDataWtr2();}
|
||||
public void Doc_set(GfmlDoc v) {gdoc = v;} GfmlDoc gdoc;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.stores.*;
|
||||
public class GfmlDataRdr extends GfmlDataRdr_base {
|
||||
@@ -36,7 +36,7 @@ public class GfmlDataRdr extends GfmlDataRdr_base {
|
||||
}
|
||||
public static DataRdr wtr_(DataWtr wtr) {return raw_root_(wtr.To_str());}
|
||||
@Override public SrlMgr SrlMgr_new(Object o) {return new GfmlDataRdr();}
|
||||
@gplx.Internal protected GfmlDataRdr() {
|
||||
public GfmlDataRdr() {
|
||||
this.Parse_set(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.core.stores.*; /*DataRdr_base*/
|
||||
public abstract class GfmlDataRdr_base extends DataRdr_base implements DataRdr {
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public abstract class GfmlDataRdr_base extends DataRdr_base implements DataRdr {
|
||||
@Override public String NameOfNode() {return curNde.Hnd();}
|
||||
@Override public int FieldCount() {return curNde.SubKeys().Count();}
|
||||
@Override public String KeyAt(int idx) {return curNde.SubKeys().Get_at(idx).KeyTkn().Val();}
|
||||
@@ -46,13 +47,13 @@ public abstract class GfmlDataRdr_base extends DataRdr_base implements DataRdr {
|
||||
if ( sub.Type().IsTypeAny()) // isAnyType b/c match may not be exact; ex: type can be defined as item:key name; but actlNde may be item:key name size;
|
||||
//|| sub.Type().IsTypeNull())
|
||||
typeName = sub.Hnd();
|
||||
if (String_.Eq(typeName, name))
|
||||
if (StringUtl.Eq(typeName, name))
|
||||
rv.list.Add(sub);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Rls() {}
|
||||
public String To_str() {return curNde.To_str();}
|
||||
@gplx.Internal protected void SetNode(GfmlNde curNde) {this.curNde = curNde; this.list = curNde.SubHnds();}
|
||||
public String To_str() {return curNde.ToStr();}
|
||||
public void SetNode(GfmlNde curNde) {this.curNde = curNde; this.list = curNde.SubHnds();}
|
||||
GfmlNde curNde; GfmlItmHnds list; int pos = -1;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.core.lists.*; /*StackAdp*/ import gplx.core.gfo_ndes.*; import gplx.core.stores.*;
|
||||
import gplx.types.basics.utls.ObjectUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
public class GfmlDataWtr extends DataWtr_base implements DataWtr {
|
||||
public void InitWtr(String key, Object val) {
|
||||
if (!String_.Eq(key, GfmlDataWtrOpts.Key_const)) return;
|
||||
if (!StringUtl.Eq(key, GfmlDataWtrOpts.Key_const)) return;
|
||||
GfmlDataWtrOpts layout = GfmlDataWtrOpts.cast(val);
|
||||
keyedSpr = layout.KeyedSpr();
|
||||
indentNodes = layout.IndentNodes();
|
||||
@@ -37,14 +39,14 @@ public class GfmlDataWtr extends DataWtr_base implements DataWtr {
|
||||
if (stack.Count() != 1 // not root
|
||||
&& nde.SubHnds().Count() == 0) { // first subNde
|
||||
AddTkn_nullVal("{");
|
||||
if (indentNodes) AddTkn_nullVal(String_.CrLf);
|
||||
if (indentNodes) AddTkn_nullVal(StringUtl.CrLf);
|
||||
}
|
||||
if (indentNodes) AddTkn_nullVal(String_.Repeat("\t", stack.Count() - 1));
|
||||
if (indentNodes) AddTkn_nullVal(StringUtl.Repeat("\t", stack.Count() - 1));
|
||||
GfmlTkn nameTkn = null;
|
||||
if (ignoreNullNames && String_.Eq(nodeName, ""))
|
||||
if (ignoreNullNames && StringUtl.Eq(nodeName, ""))
|
||||
nameTkn = GfmlTkn_.Null;
|
||||
else {
|
||||
nameTkn = AddTkn_raw(String_.Eq(nodeName, "") ? "%" : nodeName);
|
||||
nameTkn = AddTkn_raw(StringUtl.Eq(nodeName, "") ? "%" : nodeName);
|
||||
AddTkn_nullVal(":");
|
||||
}
|
||||
nde = GfmlNde.named_(nameTkn, GfmlType_.new_any_());
|
||||
@@ -54,10 +56,10 @@ public class GfmlDataWtr extends DataWtr_base implements DataWtr {
|
||||
if (nde.SubHnds().Count() == 0)
|
||||
AddTkn_nullVal(";");
|
||||
else {
|
||||
if (indentNodes) AddTkn_nullVal(String_.Repeat("\t", stack.Count() - 1));
|
||||
if (indentNodes) AddTkn_nullVal(StringUtl.Repeat("\t", stack.Count() - 1));
|
||||
AddTkn_nullVal("}");
|
||||
}
|
||||
if (indentNodes) AddTkn_nullVal(String_.CrLf);
|
||||
if (indentNodes) AddTkn_nullVal(StringUtl.CrLf);
|
||||
GfmlNde finishedNde = nde;
|
||||
nde = GfmlNde.as_(stack.Pop());
|
||||
nde.SubObjs_Add(finishedNde);
|
||||
@@ -78,8 +80,8 @@ public class GfmlDataWtr extends DataWtr_base implements DataWtr {
|
||||
}
|
||||
String To_str(Object obj) {
|
||||
if (obj == null) return "''";
|
||||
String s = Object_.Xto_str_strict_or_empty(obj);
|
||||
return String_.Concat("'", String_.Replace(s, "'", "''"), "'");
|
||||
String s = ObjectUtl.ToStrOrEmpty(obj);
|
||||
return StringUtl.Concat("'", StringUtl.Replace(s, "'", "''"), "'");
|
||||
}
|
||||
GfmlTkn AddTkn_raw(String raw) {return AddTkn(raw, raw);}
|
||||
GfmlTkn AddTkn_nullVal(String raw) {return AddTkn(raw, GfmlTkn_.NullVal);}
|
||||
|
||||
@@ -13,13 +13,14 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.errs.ErrUtl;
|
||||
public class GfmlDataWtrOpts {
|
||||
public static final String Key_const = "GfmlDataWtrOpts";
|
||||
public String KeyedSpr() {return keyedSeparator;} public GfmlDataWtrOpts KeyedSeparator_(String val) {keyedSeparator = val; return this;} private String keyedSeparator = " ";
|
||||
public boolean IndentNodes() {return indentNodes;} public GfmlDataWtrOpts IndentNodesOn_() {indentNodes = true; return this;} private boolean indentNodes;
|
||||
public boolean IgnoreNullNames() {return ignoreNullNames;} public GfmlDataWtrOpts IgnoreNullNamesOn_() {ignoreNullNames = true; return this;} private boolean ignoreNullNames;
|
||||
public static final GfmlDataWtrOpts Instance = new GfmlDataWtrOpts();
|
||||
public static GfmlDataWtrOpts new_() {return new GfmlDataWtrOpts();} GfmlDataWtrOpts() {}
|
||||
public static GfmlDataWtrOpts cast(Object obj) {try {return (GfmlDataWtrOpts)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfmlDataWtrOpts.class, obj);}}
|
||||
}
|
||||
public static final String Key_const = "GfmlDataWtrOpts";
|
||||
public String KeyedSpr() {return keyedSeparator;} public GfmlDataWtrOpts KeyedSeparator_(String val) {keyedSeparator = val; return this;} private String keyedSeparator = " ";
|
||||
public boolean IndentNodes() {return indentNodes;} public GfmlDataWtrOpts IndentNodesOn_() {indentNodes = true; return this;} private boolean indentNodes;
|
||||
public boolean IgnoreNullNames() {return ignoreNullNames;} public GfmlDataWtrOpts IgnoreNullNamesOn_() {ignoreNullNames = true; return this;} private boolean ignoreNullNames;
|
||||
public static final GfmlDataWtrOpts Instance = new GfmlDataWtrOpts();
|
||||
public static GfmlDataWtrOpts new_() {return new GfmlDataWtrOpts();} GfmlDataWtrOpts() {}
|
||||
public static GfmlDataWtrOpts cast(Object obj) {try {return (GfmlDataWtrOpts)obj;} catch(Exception exc) {throw ErrUtl.NewCast(exc, GfmlDataWtrOpts.class, obj);}}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.gfo_regys.*;
|
||||
public class GfoMsgParser_gfml implements GfoMsgParser {
|
||||
public GfoMsg ParseToMsg(String s) {return GfmlDataNde.XtoMsg(s);}
|
||||
public static final GfoMsgParser_gfml Instance = new GfoMsgParser_gfml(); GfoMsgParser_gfml() {}
|
||||
}
|
||||
package gplx.gfml;
|
||||
import gplx.core.gfo_regys.*;
|
||||
import gplx.frameworks.invks.GfoMsg;
|
||||
public class GfoMsgParser_gfml implements GfoMsgParser {
|
||||
public GfoMsg ParseToMsg(String s) {return GfmlDataNde.XtoMsg(s);}
|
||||
public static final GfoMsgParser_gfml Instance = new GfoMsgParser_gfml(); GfoMsgParser_gfml() {}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import gplx.types.commons.String_bldr;
|
||||
import gplx.types.commons.String_bldr_;
|
||||
public class SqlDoc {
|
||||
public static GfmlDoc XtoDoc(String raw) {
|
||||
GfmlBldr bldr = GfmlBldr_.new_();
|
||||
@@ -43,7 +45,7 @@ public class SqlDoc {
|
||||
}
|
||||
static GfmlLxr whitespace_(GfmlLxr lxr) {
|
||||
GfmlTkn tkn = GfmlTkn_.cmd_("key:gfml.whitespace_0", GfmlBldrCmd_.Null);
|
||||
GfmlLxr rv = GfmlLxr_.range_("lxr:gfml.whitespace_0", String_.Ary(" ", String_.Tab, String_.CrLf, String_.Lf), tkn, false);
|
||||
GfmlLxr rv = GfmlLxr_.range_("lxr:gfml.whitespace_0", StringUtl.Ary(" ", StringUtl.Tab, StringUtl.CrLf, StringUtl.Nl), tkn, false);
|
||||
lxr.SubLxr_Add(rv);
|
||||
return rv;
|
||||
}
|
||||
@@ -77,11 +79,11 @@ class SqlCmd_quote_end implements GfmlBldrCmd {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
GfmlObjList list = bldr.CurFrame().WaitingTkns();
|
||||
for (int i = 0; i < list.Len(); i++) {
|
||||
GfmlTkn pnd = (GfmlTkn)list.Get_at(i);
|
||||
GfmlTkn pnd = (GfmlTkn)list.GetAt(i);
|
||||
sb.Add(pnd.Val());
|
||||
}
|
||||
//Int_.To_str(bldr.CurNdeFrame().Nde().SubTkns().length)
|
||||
GfmlAtr atr = GfmlAtr.new_(GfmlTkn_.raw_("word"), GfmlTkn_.raw_(sb.To_str()), GfmlType_.String);
|
||||
//IntUtl.To_str(bldr.CurNdeFrame().Nde().SubTkns().length)
|
||||
GfmlAtr atr = GfmlAtr.new_(GfmlTkn_.raw_("word"), GfmlTkn_.raw_(sb.ToStr()), GfmlType_.String);
|
||||
bldr.CurNdeFrame().CurNde().SubObjs_Add(atr);
|
||||
bldr.Frames_end();
|
||||
}
|
||||
|
||||
@@ -13,26 +13,29 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import gplx.types.commons.GfoDateUtl;
|
||||
import org.junit.*; import gplx.core.stores.*;
|
||||
public class GfmlDataRdr_tst {
|
||||
@Test public void Raw() {
|
||||
raw = "root:{}";
|
||||
rdr = rdr_(raw);
|
||||
|
||||
Tfds.Eq(rdr.NameOfNode(), "root");
|
||||
GfoTstr.EqObj(rdr.NameOfNode(), "root");
|
||||
}
|
||||
@Test public void Atrs() {
|
||||
raw = "root:id=1 name=me isPresent=true dateOf='2006-12-08';";
|
||||
rdr = rdr_(raw);
|
||||
|
||||
Tfds.Eq(rdr.ReadInt("id"), 1);
|
||||
Tfds.Eq(rdr.ReadStr("name"), "me");
|
||||
Tfds.Eq(rdr.ReadBool("isPresent"), true);
|
||||
Tfds.Eq_date(rdr.ReadDate("dateOf"), DateAdp_.parse_gplx("2006-12-08"));
|
||||
GfoTstr.EqObj(rdr.ReadInt("id"), 1);
|
||||
GfoTstr.EqObj(rdr.ReadStr("name"), "me");
|
||||
GfoTstr.EqObj(rdr.ReadBool("isPresent"), true);
|
||||
GfoTstr.Eq(rdr.ReadDate("dateOf"), GfoDateUtl.ParseGplx("2006-12-08"));
|
||||
}
|
||||
@Test public void Subs() {
|
||||
raw = String_.Concat_any(
|
||||
raw = StringUtl.ConcatObjs(
|
||||
"root:{",
|
||||
" computers:id=1 {",
|
||||
" item:name=cpu;",
|
||||
@@ -49,22 +52,22 @@ public class GfmlDataRdr_tst {
|
||||
int idx = 0;
|
||||
while (computers.MoveNextPeer()) {
|
||||
int expd = idx == 0 ? 1 : 2;
|
||||
Tfds.Eq(computers.ReadInt("id"), expd);
|
||||
GfoTstr.EqObj(computers.ReadInt("id"), expd);
|
||||
idx++;
|
||||
}
|
||||
Tfds.Eq(idx, 2);
|
||||
GfoTstr.EqObj(idx, 2);
|
||||
|
||||
DataRdr items = computers.Subs();
|
||||
idx = 0;
|
||||
while (items.MoveNextPeer()) {
|
||||
String expdStr = idx == 0 ? "hardDrive" : "networkCard";
|
||||
Tfds.Eq(items.ReadStr("name"), expdStr);
|
||||
GfoTstr.EqObj(items.ReadStr("name"), expdStr);
|
||||
idx++;
|
||||
}
|
||||
Tfds.Eq(idx, 2);
|
||||
GfoTstr.EqObj(idx, 2);
|
||||
}
|
||||
@Test public void SelectRdr() {
|
||||
raw = String_.Concat_any(
|
||||
raw = StringUtl.ConcatObjs(
|
||||
"root:{",
|
||||
" person:name=me {}",
|
||||
" computer:brand=noname {}",
|
||||
@@ -72,11 +75,11 @@ public class GfmlDataRdr_tst {
|
||||
rdr = rdr_(raw);
|
||||
|
||||
DataRdr person = rdr.Subs_byName_moveFirst("person");
|
||||
Tfds.Eq(person.NameOfNode(), "person");
|
||||
Tfds.Eq(person.ReadStr("name"), "me");
|
||||
GfoTstr.EqObj(person.NameOfNode(), "person");
|
||||
GfoTstr.EqObj(person.ReadStr("name"), "me");
|
||||
DataRdr computer = rdr.Subs_byName_moveFirst("computer");
|
||||
Tfds.Eq(computer.NameOfNode(), "computer");
|
||||
Tfds.Eq(computer.ReadStr("brand"), "noname");
|
||||
GfoTstr.EqObj(computer.NameOfNode(), "computer");
|
||||
GfoTstr.EqObj(computer.ReadStr("brand"), "noname");
|
||||
}
|
||||
// @Test public void Subs_byKey() {
|
||||
// raw = String_.Concat_any(
|
||||
|
||||
@@ -13,7 +13,13 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.libs.dlgs.UsrMsg;
|
||||
import gplx.frameworks.tests.TfdsTstr_fxt;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import gplx.types.commons.KeyVal;
|
||||
class GfmlParse_fxt {
|
||||
public GfmlNde_mok nde_() {return GfmlNde_mok.new_();}
|
||||
public GfmlTkn_mok tkn_grp_ary_(String... ary) {return GfmlTkn_mok.new_().Subs_(GfmlTkn_mok.Xto_bry(ary));}
|
||||
@@ -58,15 +64,15 @@ class GfmlParse_fxt {
|
||||
UsrMsg_mok actlUmm = UsrMsg_mok.new_(actlUm);
|
||||
tstr.Eq_str(expdUm.Main(), actlUmm.Main(), "main");
|
||||
for (int j = 0; j < expdUm.Args().Len(); j++) {
|
||||
Keyval expdKv = (Keyval)expdUm.Args().Get_at(j);
|
||||
Keyval actlKv = (Keyval)actlUmm.Args().GetByOrNull(expdKv.Key());
|
||||
Object actlVal = actlKv == null ? String_.Null_mark : actlKv.Val();
|
||||
tstr.Eq_str(expdKv.Val(), actlVal, expdKv.Key());
|
||||
KeyVal expdKv = (KeyVal)expdUm.Args().GetAt(j);
|
||||
KeyVal actlKv = (KeyVal)actlUmm.Args().GetByOrNull(expdKv.KeyToStr());
|
||||
Object actlVal = actlKv == null ? StringUtl.NullMark : actlKv.Val();
|
||||
tstr.Eq_str(expdKv.Val(), actlVal, expdKv.KeyToStr());
|
||||
}
|
||||
for (int j = 0; j < expdUm.Required().Len(); j++) {
|
||||
String expdKv = (String)expdUm.Required().Get_at(j);
|
||||
Keyval actlKv = (Keyval)actlUmm.Args().GetByOrNull(expdKv);
|
||||
Object actlVal = actlKv == null ? String_.Null_mark : actlKv.Val();
|
||||
String expdKv = (String)expdUm.Required().GetAt(j);
|
||||
KeyVal actlKv = (KeyVal)actlUmm.Args().GetByOrNull(expdKv);
|
||||
Object actlVal = actlKv == null ? StringUtl.NullMark : actlKv.Val();
|
||||
Object actlValV = actlKv == null ? "<<REQD>>" : actlKv.Val();
|
||||
tstr.Eq_str(actlValV, actlVal, expdKv);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.TfdsTstr_fxt;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.Ordered_hash;
|
||||
import gplx.types.basics.lists.Ordered_hash_;
|
||||
import gplx.types.basics.utls.IntUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlTypeCompiler_fxt {
|
||||
public GfmlTyp_mok typ_() {return GfmlTyp_mok.new_();}
|
||||
public GfmlNde_mok nde_() {return GfmlNde_mok.new_();}
|
||||
public GfmlFld_mok fld_() {return GfmlFld_mok.new_();}
|
||||
public GfmlTypRegy Regy() {return typBldr.TypeRegy();}
|
||||
public void ini_Typ(List_adp typs, GfmlTyp_mok typ) {typs.Add(typ);}
|
||||
@gplx.Internal protected void run_InitPragma(GfmlTypRegy regy, GfmlPragma pragma) {
|
||||
public void run_InitPragma(GfmlTypRegy regy, GfmlPragma pragma) {
|
||||
GfmlTypeMakr makr = GfmlTypeMakr.new_();
|
||||
GfmlType[] typeAry = pragma.MakePragmaTypes(makr);
|
||||
regy.Add_ary(typeAry);
|
||||
@@ -55,7 +61,7 @@ class GfmlTypeCompiler_fxt {
|
||||
for (int i = 0; i < max; i++) {
|
||||
GfmlFld_mok expdFld = (GfmlFld_mok)tstr.List_FetchAtOrNull(expd.Subs(), i);
|
||||
GfmlFld_mok actlFld = (GfmlFld_mok)tstr.List_FetchAtOrNull(actl.Subs(), i);
|
||||
tstr.SubName_push(Int_.To_str(i) + " fld");
|
||||
tstr.SubName_push(IntUtl.ToStr(i) + " fld");
|
||||
tst(tstr, expdFld, actlFld);
|
||||
tstr.SubName_pop();
|
||||
}
|
||||
@@ -66,7 +72,7 @@ class GfmlTypeCompiler_fxt {
|
||||
if (expd.TypeKey() != null) tstr.Eq_str(expd.TypeKey(), actl.TypeKey(), "typekey");
|
||||
if (expd.DefaultTkn() != null) tstr.Eq_str(expd.DefaultTknRaw(), actl.DefaultTknRaw(), "default");
|
||||
}
|
||||
static GfmlFld_mok NullObj(GfmlFld_mok v) {return (v == null) ? GfmlFld_mok.new_().ini_ndk_(String_.Null_mark, "") : v;}
|
||||
static GfmlFld_mok NullObj(GfmlFld_mok v) {return (v == null) ? GfmlFld_mok.new_().ini_ndk_(StringUtl.NullMark, "") : v;}
|
||||
public void tst_Resolve(GfmlTyp_mok typ, GfmlNde_mok nde, GfmlNde_mok expd) {
|
||||
typBldr.TypeRegy().Add(typ.XtoGfmlType());
|
||||
tst_Resolve(nde, expd);
|
||||
|
||||
@@ -13,8 +13,14 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.TfdsTstr_fxt;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import gplx.types.basics.utls.IntUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import gplx.types.commons.String_bldr;
|
||||
import gplx.types.commons.String_bldr_;
|
||||
interface GfmlItm_mok {
|
||||
int ObjType();
|
||||
}
|
||||
@@ -28,10 +34,10 @@ class GfmlAtr_mok implements GfmlItm_mok {
|
||||
}
|
||||
public String XtoStrStub() {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
sb.Add_kv("key=", key).Add_kv("val=", val);
|
||||
return sb.To_str();
|
||||
sb.AddKv("key=", key).AddKv("val=", val);
|
||||
return sb.ToStr();
|
||||
}
|
||||
public static final GfmlAtr_mok Null = new GfmlAtr_mok().Key_(String_.Null_mark).Val_(String_.Null_mark);
|
||||
public static final GfmlAtr_mok Null = new GfmlAtr_mok().Key_(StringUtl.NullMark).Val_(StringUtl.NullMark);
|
||||
public static GfmlAtr_mok as_(Object obj) {return obj instanceof GfmlAtr_mok ? (GfmlAtr_mok)obj : null;}
|
||||
public static GfmlAtr_mok new_(String key, String val) {
|
||||
GfmlAtr_mok rv = new GfmlAtr_mok();
|
||||
@@ -51,8 +57,8 @@ class GfmlNde_mok implements GfmlItm_mok {
|
||||
public List_adp Subs() {return subs;}
|
||||
public String XtoStrStub() {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
sb.Add_kv("key=", key).Add_kv("hnd=", hnd).Add_kv("typ=", typ).Add_kv("subs=", Int_.To_str(subs.Len()));
|
||||
return sb.To_str();
|
||||
sb.AddKv("key=", key).AddKv("hnd=", hnd).AddKv("typ=", typ).AddKv("subs=", IntUtl.ToStr(subs.Len()));
|
||||
return sb.ToStr();
|
||||
}
|
||||
public GfmlNde_mok Subs_(GfmlItm_mok... ary) {
|
||||
for (GfmlItm_mok itm : ary)
|
||||
@@ -76,7 +82,7 @@ class GfmlNde_mok implements GfmlItm_mok {
|
||||
if (ownerMok.keyed) rv.KeyedSubObj_(ownerMok.keyed);
|
||||
if (ownerMok.key != null) rv.KeyTkn_set(GfmlTkn_.val_(ownerMok.key));
|
||||
for (int i = 0; i < ownerMok.subs.Len(); i++) {
|
||||
GfmlItm_mok itm = (GfmlItm_mok)ownerMok.subs.Get_at(i);
|
||||
GfmlItm_mok itm = (GfmlItm_mok)ownerMok.subs.GetAt(i);
|
||||
if (itm.ObjType() == GfmlObj_.Type_nde) {
|
||||
GfmlNde_mok itmMok = (GfmlNde_mok)itm;
|
||||
rv.SubObjs_Add(itmMok.XtoGfmlItm(regy));
|
||||
@@ -89,7 +95,7 @@ class GfmlNde_mok implements GfmlItm_mok {
|
||||
return rv;
|
||||
}
|
||||
public static GfmlNde_mok as_(Object obj) {return obj instanceof GfmlNde_mok ? (GfmlNde_mok)obj : null;}
|
||||
public static final GfmlNde_mok Null = new GfmlNde_mok().Hnd_(String_.Null_mark).Typ_(String_.Null_mark);
|
||||
public static final GfmlNde_mok Null = new GfmlNde_mok().Hnd_(StringUtl.NullMark).Typ_(StringUtl.NullMark);
|
||||
public static final GfmlNde_mok ErrAtr = new GfmlNde_mok().Hnd_("<<ErrAtr>>").Typ_("<<ErrAtr>>");
|
||||
public static GfmlNde_mok new_() {return new GfmlNde_mok();} GfmlNde_mok() {}
|
||||
public static GfmlNde_mok gfmlNde_(GfmlNde nde) {return InitNde(nde);}
|
||||
@@ -105,7 +111,7 @@ class GfmlNde_mok implements GfmlItm_mok {
|
||||
if (subItm.ObjType() == GfmlObj_.Type_atr) {
|
||||
GfmlAtr subAtr = (GfmlAtr)subItm;
|
||||
GfmlAtr_mok mokAtr = GfmlAtr_mok.new_(subAtr.Key(), subAtr.DatTkn().Val());
|
||||
if (!String_.Len_eq_0(subAtr.Key())) mokAtr.Key_(subAtr.Key());
|
||||
if (!StringUtl.IsNullOrEmpty(subAtr.Key())) mokAtr.Key_(subAtr.Key());
|
||||
rv.subs.Add(mokAtr);
|
||||
}
|
||||
else {
|
||||
@@ -140,7 +146,7 @@ class GfmlTypeResolver_fxt {
|
||||
for (int i = 0; i < max; i++) {
|
||||
GfmlItm_mok expdSub = (GfmlItm_mok)tstr.List_FetchAtOrNull(expd.Subs(), i);
|
||||
GfmlItm_mok actlSub = (GfmlItm_mok)tstr.List_FetchAtOrNull(actl.Subs(), i);
|
||||
tstr.SubName_push(Int_.To_str(i));
|
||||
tstr.SubName_push(IntUtl.ToStr(i));
|
||||
if (expdSub == null) {
|
||||
GfmlNde_mok mm = GfmlNde_mok.as_(actlSub);
|
||||
String actlSubStr = mm == null ? "sub:null" : mm.XtoStrStub();
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.TfdsTstr_fxt;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import gplx.types.basics.utls.IntUtl;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlTkn_mok {
|
||||
public String Raw() {return raw;} public GfmlTkn_mok Raw_(String v) {raw = v; return this;} private String raw;
|
||||
public List_adp Subs() {return list;} List_adp list = List_adp_.New();
|
||||
@@ -66,10 +71,10 @@ class GfmlTkn_mok {
|
||||
for (int i = 0; i < max; i++) {
|
||||
GfmlTkn_mok expdSub = (GfmlTkn_mok)tstr.List_FetchAtOrNull(expd.Subs(), i);
|
||||
GfmlTkn_mok actlSub = (GfmlTkn_mok)tstr.List_FetchAtOrNull(actl.Subs(), i);
|
||||
tstr.SubName_push(Int_.To_str(i));
|
||||
tstr.SubName_push(IntUtl.ToStr(i));
|
||||
tst(tstr, expdSub, actlSub);
|
||||
tstr.SubName_pop();
|
||||
}
|
||||
}
|
||||
static GfmlTkn_mok NullObj(GfmlTkn_mok v) {return v == null ? GfmlTkn_mok.new_().Raw_(String_.Null_mark) : v;}
|
||||
static GfmlTkn_mok NullObj(GfmlTkn_mok v) {return v == null ? GfmlTkn_mok.new_().Raw_(StringUtl.NullMark) : v;}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
class GfmlFld_mok {
|
||||
public String Name() {return name;} public GfmlFld_mok Name_(String v) {name = v; return this;} private String name;
|
||||
public String TypeKey() {return typeKey;} public GfmlFld_mok TypeKey_(String v) {typeKey = v; return this;} private String typeKey;
|
||||
@@ -31,11 +34,11 @@ class GfmlFld_mok {
|
||||
public GfmlFld_mok ini_ndk_(String name, String typKey) {this.name = name; this.typeKey = typKey; this.keyed = true; return this;}
|
||||
public static GfmlFld_mok new_() {return new GfmlFld_mok();} GfmlFld_mok() {}
|
||||
public static String XtoRaw(GfmlObj gobj) {
|
||||
if (gobj == null) return String_.Null_mark;
|
||||
if (gobj == null) return StringUtl.NullMark;
|
||||
GfmlTkn tkn = GfmlTkn_.as_(gobj);
|
||||
if (tkn != null) return tkn.Raw();
|
||||
GfmlNde nde = GfmlNde.as_(gobj);
|
||||
return nde.To_str();
|
||||
return nde.ToStr();
|
||||
}
|
||||
}
|
||||
class GfmlTyp_mok {
|
||||
@@ -55,7 +58,7 @@ class GfmlTyp_mok {
|
||||
public GfmlType XtoGfmlType() {
|
||||
GfmlType rv = GfmlType_.new_(key, name); // all types in tests are top-level
|
||||
for (int i = 0; i < subFlds.Len(); i++) {
|
||||
GfmlFld_mok fld = (GfmlFld_mok)subFlds.Get_at(i);
|
||||
GfmlFld_mok fld = (GfmlFld_mok)subFlds.GetAt(i);
|
||||
rv.SubFlds().Add(fld.XtoGfmlFld());
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -13,10 +13,14 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.libs.dlgs.UsrMsg;
|
||||
import gplx.types.commons.KeyVal;
|
||||
import gplx.types.basics.lists.Ordered_hash;
|
||||
import gplx.types.basics.lists.Ordered_hash_;
|
||||
class UsrMsg_mok {
|
||||
public String Main() {return main;} public UsrMsg_mok Main_(String v) {main = v; return this;} private String main;
|
||||
public UsrMsg_mok Add_(String k, Object o) {hash.Add(k, Keyval_.new_(k, o)); return this;}
|
||||
public UsrMsg_mok Add_(String k, Object o) {hash.Add(k, KeyVal.NewStr(k, o)); return this;}
|
||||
public UsrMsg_mok Require_(String k) {required.Add(k, k); return this;}
|
||||
public Ordered_hash Args() {return hash;} Ordered_hash hash = Ordered_hash_.New();
|
||||
public Ordered_hash Required() {return required;} Ordered_hash required = Ordered_hash_.New();
|
||||
@@ -25,8 +29,8 @@ class UsrMsg_mok {
|
||||
if (um != null) {
|
||||
rv.main = um.Hdr();
|
||||
for (int i = 0; i < um.Args().Len(); i++) {
|
||||
Keyval kv = (Keyval)um.Args().Get_at(i);
|
||||
rv.Add_(kv.Key(), kv.Val());
|
||||
KeyVal kv = (KeyVal)um.Args().GetAt(i);
|
||||
rv.Add_(kv.KeyToStr(), kv.Val());
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import org.junit.*;
|
||||
public class z011_IntObjHash_tst {
|
||||
@Before public void setup() {
|
||||
@@ -56,6 +57,6 @@ public class z011_IntObjHash_tst {
|
||||
tst_Fetch(17, null); // works
|
||||
tst_Fetch(16, null); // used to fail
|
||||
}
|
||||
void tst_Fetch(int key, Object expd) {Tfds.Eq(expd, hash.Get_by(key));}
|
||||
void tst_Count(int expd) {Tfds.Eq(expd, hash.Count());}
|
||||
void tst_Fetch(int key, Object expd) {GfoTstr.EqObj(expd, hash.Get_by(key));}
|
||||
void tst_Count(int expd) {GfoTstr.EqObj(expd, hash.Count());}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import org.junit.*;
|
||||
import gplx.core.texts.*; /*CharStream*/
|
||||
public class z012_GfmlTrie_tst {
|
||||
@@ -66,6 +67,6 @@ public class z012_GfmlTrie_tst {
|
||||
void tst_FindMatch_first(String text, String expd) {
|
||||
CharStream stream = CharStream.pos0_(text);
|
||||
String actl = (String)trie.FindMatch(stream);
|
||||
Tfds.Eq(expd, actl);
|
||||
GfoTstr.EqObj(expd, actl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.objects.lists.CompareAbleUtl;
|
||||
package gplx.gfml;
|
||||
import gplx.types.commons.lists.CompareAbleUtl;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import org.junit.*;
|
||||
public class z015_GfmlDocPos_tst {
|
||||
GfmlDocPos root = GfmlDocPos_.Root;
|
||||
@@ -46,6 +47,6 @@ public class z015_GfmlDocPos_tst {
|
||||
tst_CompareTo(lhs, rhs, CompareAbleUtl.Less);
|
||||
tst_CompareTo(rhs, lhs, CompareAbleUtl.More);
|
||||
}
|
||||
void tst_Path(GfmlDocPos pos, String expdPath) {Tfds.Eq(expdPath, pos.Path());}
|
||||
void tst_CompareTo(GfmlDocPos lhs, GfmlDocPos rhs, int expd) {Tfds.Eq(expd, lhs.compareTo(rhs));}
|
||||
void tst_Path(GfmlDocPos pos, String expdPath) {GfoTstr.EqObj(expdPath, pos.Path());}
|
||||
void tst_CompareTo(GfmlDocPos lhs, GfmlDocPos rhs, int expd) {GfoTstr.EqObj(expd, lhs.compareTo(rhs));}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.objects.arrays.ArrayUtl;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.utls.ArrayUtl;
|
||||
import org.junit.*;
|
||||
public class z016_GfmlScopeList_tst {
|
||||
@Before public void setup() {
|
||||
@@ -49,6 +50,6 @@ public class z016_GfmlScopeList_tst {
|
||||
void tst_Itm(GfmlScopeList list, GfmlDocPos pos, String expd) {
|
||||
GfmlVarItm itm = (GfmlVarItm)list.Get_by(pos);
|
||||
String actl = itm == null ? null : itm.TknVal();
|
||||
Tfds.Eq(expd, actl);
|
||||
GfoTstr.EqObj(expd, actl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import org.junit.*;
|
||||
public class z017_GfmlStringHighlighter_tst {
|
||||
@Test public void Short() {
|
||||
@@ -46,6 +47,6 @@ public class z017_GfmlStringHighlighter_tst {
|
||||
GfmlStringHighlighter sh_() {return GfmlStringHighlighter.new_();}
|
||||
void tst_Err(GfmlStringHighlighter sh, String... expdLines) {
|
||||
String[] actlLines = sh.Gen();
|
||||
Tfds.Eq_ary_str(expdLines, actlLines);
|
||||
GfoTstr.EqLines(expdLines, actlLines);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
public class z051_GfmlFldPool_keyed_tst {
|
||||
@Before public void setup() {
|
||||
GfmlTypeMakr makr = GfmlTypeMakr.new_();
|
||||
@@ -46,9 +48,9 @@ public class z051_GfmlFldPool_keyed_tst {
|
||||
tst_Keyed_PopNext(fldPool, "z");
|
||||
try {
|
||||
tst_Keyed_PopNext(fldPool, GfmlItmKeys.NullKey);
|
||||
Tfds.Fail("should have failed");
|
||||
GfoTstr.Fail("should have failed");
|
||||
}
|
||||
catch (Exception exc) {Err_.Noop(exc);}
|
||||
catch (Exception exc) {}
|
||||
}
|
||||
@Test public void PopByKey_PopNext() {
|
||||
tst_Keyed_PopByKey(fldPool, "y", "y", "x", "z");
|
||||
@@ -56,20 +58,20 @@ public class z051_GfmlFldPool_keyed_tst {
|
||||
}
|
||||
void tst_Keyed_PopByKey(GfmlFldPool fldPool, String key, String expdFldId, String... expdSubs) {
|
||||
GfmlFld actlFld = fldPool.Keyed_PopByKey(key);
|
||||
Tfds.Eq(expdFldId, actlFld.Name());
|
||||
GfoTstr.EqObj(expdFldId, actlFld.Name());
|
||||
String[] actlSubs = new String[fldPool.Keyd_Count()];
|
||||
for (int i = 0; i < actlSubs.length; i++) {
|
||||
actlSubs[i] = fldPool.Keyd_FetchAt(i).Name();
|
||||
}
|
||||
Tfds.Eq_ary(expdSubs, actlSubs);
|
||||
GfoTstr.EqLines(expdSubs, actlSubs);
|
||||
}
|
||||
void tst_Keyed_PopNext(GfmlFldPool fldPool, String expdFldId, String... expdSubs) {
|
||||
GfmlFld actlFld = fldPool.Keyed_PopNext();
|
||||
Tfds.Eq(expdFldId, actlFld.Name());
|
||||
GfoTstr.EqObj(expdFldId, actlFld.Name());
|
||||
String[] actlSubs = new String[fldPool.Keyd_Count()];
|
||||
for (int i = 0; i < actlSubs.length; i++) {
|
||||
actlSubs[i] = fldPool.Keyd_FetchAt(i).Name();
|
||||
}
|
||||
Tfds.Eq_ary(expdSubs, actlSubs);
|
||||
GfoTstr.EqLines(expdSubs, actlSubs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import org.junit.*; import gplx.core.stores.*;
|
||||
public class z081_GfmlDataWtr_tst {
|
||||
@Before public void setup() {
|
||||
@@ -64,6 +65,6 @@ public class z081_GfmlDataWtr_tst {
|
||||
}
|
||||
void tst_XtoStr(DataWtr wtr, String expd) {
|
||||
String actl = wtr.To_str();
|
||||
Tfds.Eq(expd, actl);
|
||||
GfoTstr.EqObj(expd, actl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*; import gplx.core.stores.*;
|
||||
public class z082_GfmlDataWtrOpts_tst {
|
||||
@Before public void setup() {
|
||||
@@ -31,7 +33,7 @@ public class z082_GfmlDataWtrOpts_tst {
|
||||
wtr.WriteNodeBgn("nde1");
|
||||
wtr.WriteNodeBgn("nde2");
|
||||
wtr.WriteNodeEnd();
|
||||
tst_XtoStr(wtr, String_.Concat_lines_crlf
|
||||
tst_XtoStr(wtr, StringUtl.ConcatLinesCrlf
|
||||
( "root:{"
|
||||
, " nde1:{"
|
||||
, " nde2:;"
|
||||
@@ -43,10 +45,10 @@ public class z082_GfmlDataWtrOpts_tst {
|
||||
wtr.InitWtr(GfmlDataWtrOpts.Key_const, GfmlDataWtrOpts.new_().IgnoreNullNamesOn_());
|
||||
wtr.WriteNodeBgn("");
|
||||
wtr.WriteData("key1", "data1");
|
||||
tst_XtoStr(wtr, String_.Concat("root:{key1='data1';}"));
|
||||
tst_XtoStr(wtr, StringUtl.Concat("root:{key1='data1';}"));
|
||||
}
|
||||
void tst_XtoStr(DataWtr wtr, String expd) {
|
||||
String actl = wtr.To_str();
|
||||
Tfds.Eq(expd, actl);
|
||||
GfoTstr.EqObj(expd, actl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import org.junit.*;
|
||||
import gplx.core.texts.*; /*CharStream*/
|
||||
public class z091_GfmlLxr_basic_tst {
|
||||
@@ -60,7 +63,7 @@ public class z091_GfmlLxr_basic_tst {
|
||||
list.Add(tkn.Raw());
|
||||
}
|
||||
String[] actl = (String[])list.ToAry(String.class);
|
||||
Tfds.Eq_ary(expd, actl);
|
||||
GfoTstr.EqLines(expd, actl);
|
||||
return tkn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z102_core_whitespace_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@@ -38,7 +39,7 @@ public class z102_core_whitespace_tst {
|
||||
fx.tst_Doc("a\tb;", fx.nde_().Atru_("a").Atru_("b"));
|
||||
}
|
||||
@Test public void NewLine() {
|
||||
fx.tst_Doc(String_.Format("a{0}b;", String_.CrLf), fx.nde_().Atru_("a").Atru_("b"));
|
||||
fx.tst_Doc(StringUtl.Format("a{0}b;", StringUtl.CrLf), fx.nde_().Atru_("a").Atru_("b"));
|
||||
}
|
||||
@Test public void MergeSameWs() {
|
||||
fx.tst_Doc("a b;", fx.nde_().Atru_("a").Atru_("b"));
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z111_core_comment0_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@@ -25,18 +26,18 @@ public class z111_core_comment0_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("//a" + String_.Lf);
|
||||
fx.tst_Tkn("//a" + String_.Lf
|
||||
, fx.tkn_grp_ary_("//", "a", String_.Lf)
|
||||
fx.tst_Doc("//a" + StringUtl.Nl);
|
||||
fx.tst_Tkn("//a" + StringUtl.Nl
|
||||
, fx.tkn_grp_ary_("//", "a", StringUtl.Nl)
|
||||
);
|
||||
}
|
||||
@Test public void Data() {
|
||||
fx.tst_Doc("a;//b" + String_.Lf, fx.nde_().Atru_("a"));
|
||||
fx.tst_Tkn("a;//b" + String_.Lf
|
||||
fx.tst_Doc("a;//b" + StringUtl.Nl, fx.nde_().Atru_("a"));
|
||||
fx.tst_Tkn("a;//b" + StringUtl.Nl
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_itm_(";"))
|
||||
, fx.tkn_grp_ary_("//", "b", String_.Lf)
|
||||
, fx.tkn_grp_ary_("//", "b", StringUtl.Nl)
|
||||
);
|
||||
}
|
||||
// @Test public void DanglingBgn() {
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z124_quotes_quoteFold_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@@ -36,7 +37,7 @@ public class z124_quotes_quoteFold_tst {
|
||||
);
|
||||
}
|
||||
@Test public void NewLine() {
|
||||
fx.tst_Doc(String_.Concat("^'a", String_.CrLf, "b'^;"), fx.nde_().Atru_("ab"));
|
||||
fx.tst_Doc(StringUtl.Concat("^'a", StringUtl.CrLf, "b'^;"), fx.nde_().Atru_("ab"));
|
||||
}
|
||||
@Test public void Eval() {
|
||||
fx.tst_Doc("^'a<~t>b'^;", fx.nde_().Atru_("a\tb"));
|
||||
@@ -51,7 +52,7 @@ public class z124_quotes_quoteFold_tst {
|
||||
fx.tst_Doc("^'a'^'^b'^;", fx.nde_().Atru_("a'^b"));
|
||||
}
|
||||
@Test public void Comment0() {
|
||||
fx.tst_Doc(String_.Concat("^'a//comment", String_.CrLf, "b'^;"), fx.nde_().Atru_("ab"));
|
||||
fx.tst_Doc(StringUtl.Concat("^'a//comment", StringUtl.CrLf, "b'^;"), fx.nde_().Atru_("ab"));
|
||||
}
|
||||
@Test public void Comment1() {
|
||||
fx.tst_Doc("^'a/*comment*/b'^;", fx.nde_().Atru_("ab"));
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z151_ndeSubs_basic_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@@ -46,7 +47,7 @@ public class z151_ndeSubs_basic_tst {
|
||||
));
|
||||
}
|
||||
@Test public void Complex() {
|
||||
fx.tst_Doc(String_.Concat
|
||||
fx.tst_Doc(StringUtl.Concat
|
||||
( "{"
|
||||
, "{"
|
||||
, "{}"
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import org.junit.*;
|
||||
public class z400_GfmlTypeMakr_tst {
|
||||
@Before public void setup() {
|
||||
@@ -51,7 +52,7 @@ public class z400_GfmlTypeMakr_tst {
|
||||
tst_XtoAry(makr, "item", "item/pos");
|
||||
}
|
||||
void tst_Owner(GfmlTypeMakr typeMakr, String expdKey) {
|
||||
Tfds.Eq(expdKey, typeMakr.Owner().Key());
|
||||
GfoTstr.EqObj(expdKey, typeMakr.Owner().Key());
|
||||
}
|
||||
void tst_XtoAry(GfmlTypeMakr typeMakr, String... expdAry) {
|
||||
GfmlType[] actlTypeAry = typeMakr.Xto_bry();
|
||||
@@ -59,6 +60,6 @@ public class z400_GfmlTypeMakr_tst {
|
||||
for (int i = 0; i < actlAry.length; i++) {
|
||||
actlAry[i] = actlTypeAry[i].Key();
|
||||
}
|
||||
Tfds.Eq_ary(expdAry, actlAry);
|
||||
GfoTstr.EqLines(expdAry, actlAry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,19 +13,20 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z441_types_parse_basic_tst {
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Null() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "point:1;"
|
||||
)
|
||||
, fx.nde_().Hnd_("point").Typ_(GfmlType_.AnyKey).Atru_("1")
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, "point {"
|
||||
, "x;"
|
||||
@@ -37,7 +38,7 @@ public class z441_types_parse_basic_tst {
|
||||
);
|
||||
}
|
||||
@Test public void MultipleAtrs() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, "point {"
|
||||
, "x; y;"
|
||||
|
||||
@@ -13,11 +13,12 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z442_types_parse_default_tst {
|
||||
@Test public void Basic() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, "point {x;}"
|
||||
, "}"
|
||||
@@ -27,7 +28,7 @@ public class z442_types_parse_default_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Pinned() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, "point {x;}"
|
||||
, "}"
|
||||
@@ -39,7 +40,7 @@ public class z442_types_parse_default_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, "point {x;}" // point is always pinned
|
||||
, "size {w;}" // size is defined, but can only be invoked by hnd
|
||||
@@ -52,7 +53,7 @@ public class z442_types_parse_default_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Nested() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, "item {"
|
||||
, "point {x; y;}"
|
||||
@@ -66,7 +67,7 @@ public class z442_types_parse_default_tst {
|
||||
);
|
||||
}
|
||||
@Test public void NestedWithAtr() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, "item {"
|
||||
, "name;"
|
||||
@@ -83,7 +84,7 @@ public class z442_types_parse_default_tst {
|
||||
}
|
||||
//@Test
|
||||
public void WithDefault() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, "point {"
|
||||
, "x 1;"
|
||||
|
||||
@@ -13,11 +13,12 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z443_types_parse_keyd_tst {
|
||||
@Test public void Basic() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "[10 12];"
|
||||
)
|
||||
, fx.nde_().Subs_
|
||||
@@ -27,7 +28,7 @@ public class z443_types_parse_keyd_tst {
|
||||
}
|
||||
// @Test // FIX: IGNORE
|
||||
public void KeydDefault() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, " rect {"
|
||||
, " point [1 2];"
|
||||
|
||||
@@ -13,23 +13,25 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
class GfmlDefaultItem_fxt {
|
||||
@gplx.Internal protected GfmlDefaultItem make_(String typeKey, String key, GfmlTkn val) {return GfmlDefaultItem.new_(typeKey, key, val);}
|
||||
@gplx.Internal protected GfmlDefaultItem make_(String typeKey, String key, String val) {return GfmlDefaultItem.new_(typeKey, key, GfmlTkn_.raw_(val));}
|
||||
@gplx.Internal protected void tst_Item(GfmlDefaultItem actl, GfmlDefaultItem expd) {
|
||||
Tfds.Eq(expd.TypeKey(), actl.TypeKey());
|
||||
Tfds.Eq(expd.Key(), actl.Key());
|
||||
Tfds.Eq(GfmlFld_mok.XtoRaw(expd.Val()), GfmlFld_mok.XtoRaw(actl.Val()));
|
||||
Tfds.Eq(Val_to_str_or_null(expd.ValPrev()), Val_to_str_or_null(actl.ValPrev()));
|
||||
public GfmlDefaultItem make_(String typeKey, String key, GfmlTkn val) {return GfmlDefaultItem.new_(typeKey, key, val);}
|
||||
public GfmlDefaultItem make_(String typeKey, String key, String val) {return GfmlDefaultItem.new_(typeKey, key, GfmlTkn_.raw_(val));}
|
||||
public void tst_Item(GfmlDefaultItem actl, GfmlDefaultItem expd) {
|
||||
GfoTstr.EqObj(expd.TypeKey(), actl.TypeKey());
|
||||
GfoTstr.EqObj(expd.Key(), actl.Key());
|
||||
GfoTstr.EqObj(GfmlFld_mok.XtoRaw(expd.Val()), GfmlFld_mok.XtoRaw(actl.Val()));
|
||||
GfoTstr.EqObj(Val_to_str_or_null(expd.ValPrev()), Val_to_str_or_null(actl.ValPrev()));
|
||||
}
|
||||
@gplx.Internal protected void tst_List(List_adp list, GfmlDefaultItem... expdAry) {
|
||||
public void tst_List(List_adp list, GfmlDefaultItem... expdAry) {
|
||||
for (int i = 0; i < expdAry.length; i++) {
|
||||
GfmlDefaultItem actl = (GfmlDefaultItem)list.Get_at(i);
|
||||
GfmlDefaultItem actl = (GfmlDefaultItem)list.GetAt(i);
|
||||
GfmlDefaultItem expd = expdAry[i];
|
||||
tst_Item(actl, expd);
|
||||
}
|
||||
Tfds.Eq(expdAry.length, list.Len());
|
||||
GfoTstr.EqObj(expdAry.length, list.Len());
|
||||
}
|
||||
String Val_to_str_or_null(GfmlObj gobj) {
|
||||
GfmlTkn tkn = GfmlTkn_.as_(gobj);
|
||||
|
||||
@@ -13,7 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import org.junit.*;
|
||||
public class z451_dflts_compile_tst {
|
||||
@Before public void setup() {
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import org.junit.*;
|
||||
public class z452_dflts_exec_tst {
|
||||
@Before public void setup() {
|
||||
@@ -78,11 +79,11 @@ public class z452_dflts_exec_tst {
|
||||
GfmlFld subFld = type.SubFlds().Get_by(subFldKey);
|
||||
GfmlTkn defaultTkn = GfmlTkn_.as_(subFld.DefaultTkn());
|
||||
String actlDefaultVal = defaultTkn == null || defaultTkn == GfmlTkn_.Null ? null : defaultTkn.Val();
|
||||
Tfds.Eq(expdDefaultVal, actlDefaultVal);
|
||||
GfoTstr.EqObj(expdDefaultVal, actlDefaultVal);
|
||||
}
|
||||
void tst_SubFldExists(GfmlType type, String subFldKey, boolean expd) {
|
||||
GfmlFld subFld = type.SubFlds().Get_by(subFldKey);
|
||||
Tfds.Eq(expd, subFld != null);
|
||||
GfoTstr.EqObj(expd, subFld != null);
|
||||
}
|
||||
GfmlType make_(String key, String name, String... atrs) {
|
||||
GfmlTypeMakr typeMakr = GfmlTypeMakr.new_();
|
||||
|
||||
@@ -13,7 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import org.junit.*;
|
||||
public class z455_dflts_scope_tst {
|
||||
@Before public void setup() {
|
||||
@@ -37,11 +40,11 @@ public class z455_dflts_scope_tst {
|
||||
}
|
||||
GfmlType tst_FetchOrNullByPos(GfmlTypRegy regy, String key, GfmlDocPos docPos, String expdTypeKey, String... expdSubs) {
|
||||
GfmlType actl = regy.FetchOrNull(key, docPos);
|
||||
Tfds.Eq(expdTypeKey, actl.Key());
|
||||
GfoTstr.EqObj(expdTypeKey, actl.Key());
|
||||
String[] actlSubs = new String[actl.SubFlds().Count()];
|
||||
for (int i = 0; i < actlSubs.length; i++)
|
||||
actlSubs[i] = actl.SubFlds().Get_at(i).Name();
|
||||
Tfds.Eq_ary(expdSubs, actlSubs);
|
||||
GfoTstr.EqLines(expdSubs, actlSubs);
|
||||
return actl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,12 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z456_dflts_parse_tst {
|
||||
@Test public void Fix_DefaultChangesPinnedType() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_type:{"
|
||||
, "item {"
|
||||
, "name;"
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import org.junit.*;
|
||||
public class z481_vars_compile_tst {
|
||||
@Before public void setup() {
|
||||
@@ -26,8 +27,8 @@ public class z481_vars_compile_tst {
|
||||
, fx.nde_().Atru_("key_test").Atru_("val_test").Atru_("context_test"));
|
||||
|
||||
GfmlVarItm itm = pragma.CompileItmNde(gnde);
|
||||
Tfds.Eq_rev(itm.Key(), "key_test");
|
||||
Tfds.Eq_rev(itm.TknVal(), "val_test");
|
||||
Tfds.Eq_rev(itm.CtxKey(), "context_test");
|
||||
GfoTstr.EqObj("key_test", itm.Key());
|
||||
GfoTstr.EqObj("val_test", itm.TknVal());
|
||||
GfoTstr.EqObj("context_test", itm.CtxKey());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,13 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z482_vars_parse_tst {
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Basic() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_var:{"
|
||||
, " size '20,20';"
|
||||
, "}"
|
||||
@@ -28,7 +29,7 @@ public class z482_vars_parse_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_var:{"
|
||||
, " size '20,20';"
|
||||
, " pos '30,30';"
|
||||
@@ -39,7 +40,7 @@ public class z482_vars_parse_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Deferred() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_var:{"
|
||||
, " key0 '<~key1>';"
|
||||
, "}"
|
||||
@@ -52,7 +53,7 @@ public class z482_vars_parse_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Swap() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "{"
|
||||
, " _var:{"
|
||||
, " size '20,20';"
|
||||
@@ -71,7 +72,7 @@ public class z482_vars_parse_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Context() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_var:{"
|
||||
, " size '20,20' gui;"
|
||||
, "}"
|
||||
|
||||
@@ -13,12 +13,13 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import org.junit.*;
|
||||
public class z501_lxr_parse_tst {
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void SymCreate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_lxr_sym:key='gfml.elm_key_1' raw='<-' cmd='gfml.elm_key';"
|
||||
, "a<-1;"
|
||||
)
|
||||
@@ -26,7 +27,7 @@ public class z501_lxr_parse_tst {
|
||||
);
|
||||
}
|
||||
@Test public void SymUpdate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_lxr_sym:key='gfml.elm_key_0' raw='<-';"
|
||||
, "a<-1 b=1;"
|
||||
)
|
||||
@@ -34,7 +35,7 @@ public class z501_lxr_parse_tst {
|
||||
);
|
||||
}
|
||||
@Test public void SwapCreate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_lxr_sym:key='gfml.swap_0' raw='/?/?' val='/?';"
|
||||
, "/?/?;"
|
||||
)
|
||||
@@ -42,7 +43,7 @@ public class z501_lxr_parse_tst {
|
||||
);
|
||||
}
|
||||
@Test public void FrameCreate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_lxr_frame:key='gfml.comment_2' type='comment' bgn='/-' end='-/';"
|
||||
, "a=/-ignore-/b;"
|
||||
)
|
||||
@@ -50,7 +51,7 @@ public class z501_lxr_parse_tst {
|
||||
);
|
||||
}
|
||||
@Test public void FrameUpdate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_lxr_frame:key='gfml.comment_0' bgn='--' end='!';"
|
||||
, "a=--ignore!"
|
||||
, "b;"
|
||||
@@ -60,7 +61,7 @@ public class z501_lxr_parse_tst {
|
||||
}
|
||||
//@Test
|
||||
public void FrameCreateNest() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "_lxr_frame:key='gfml.comment_2' type='comment' bgn='/-' end='-/' {"
|
||||
, "sym:key='gfml.comment_2_escape_bgn' raw='/-/-' val='/-' cmd='gfml.elm_data';"
|
||||
, "sym:key='gfml.comment_2_escape_end' raw='-/-/' val='-/' cmd='gfml.elm_data';"
|
||||
|
||||
@@ -13,7 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import org.junit.*;
|
||||
public class z601_edit_atr_tst {
|
||||
GfmlUpdateFx fx = GfmlUpdateFx.new_();
|
||||
@@ -116,11 +119,11 @@ class GfmlUpdateFx {
|
||||
public GfmlUpdateFx tst_(String expd) {
|
||||
GfmlDoc actlDoc = GfmlDataNde.new_any_eol_(raw).Doc();
|
||||
for (int i = 0; i < cmds.Len(); i++) {
|
||||
GfmlUpdateCmd cmd = (GfmlUpdateCmd)cmds.Get_at(i);
|
||||
GfmlUpdateCmd cmd = (GfmlUpdateCmd)cmds.GetAt(i);
|
||||
cmd.Exec(actlDoc);
|
||||
}
|
||||
String actl = actlDoc.RootNde().To_str();
|
||||
Tfds.Eq(expd, actl);
|
||||
String actl = actlDoc.RootNde().ToStr();
|
||||
GfoTstr.EqObj(expd, actl);
|
||||
cmds.Clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.stores.*;
|
||||
package gplx.gfml;
|
||||
import gplx.core.stores.DataRdr;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import gplx.types.commons.KeyVal;
|
||||
import org.junit.Test;
|
||||
public class z801_useCase_DataRdr_tst {
|
||||
String raw;
|
||||
@Test public void Subs_byName() {
|
||||
raw = String_.Concat
|
||||
raw = StringUtl.Concat
|
||||
( "_type:{"
|
||||
, " item {"
|
||||
, " point {"
|
||||
@@ -39,7 +42,7 @@ public class z801_useCase_DataRdr_tst {
|
||||
}
|
||||
// @Test
|
||||
public void Subs_byName3() {
|
||||
raw = String_.Concat
|
||||
raw = StringUtl.Concat
|
||||
( "_type:{"
|
||||
, " item {"
|
||||
, " key"
|
||||
@@ -56,12 +59,12 @@ public class z801_useCase_DataRdr_tst {
|
||||
subRdr = rdr.Subs_byName_moveFirst("point");
|
||||
fx_rdr.tst_Atrs(subRdr, kv_("x", "1"), kv_("y", "2"));
|
||||
}
|
||||
Keyval kv_(String key, Object val) {return Keyval_.new_(key, val);}
|
||||
KeyVal kv_(String key, Object val) {return KeyVal.NewStr(key, val);}
|
||||
DataRdr_Fxt fx_rdr = DataRdr_Fxt.Instance;
|
||||
DataRdr rdr, subRdr;
|
||||
}
|
||||
class DataRdr_Fxt {
|
||||
@gplx.Internal protected DataRdr run_Subs_at(DataRdr rdr, int i) {
|
||||
public DataRdr run_Subs_at(DataRdr rdr, int i) {
|
||||
DataRdr rv = rdr.Subs();
|
||||
int count = -1;
|
||||
while (count++ < i) {
|
||||
@@ -69,11 +72,11 @@ class DataRdr_Fxt {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@gplx.Internal protected void tst_Atrs(DataRdr rdr, Keyval... expdAry) {
|
||||
Keyval[] actlAry = new Keyval[rdr.FieldCount()];
|
||||
public void tst_Atrs(DataRdr rdr, KeyVal... expdAry) {
|
||||
KeyVal[] actlAry = new KeyVal[rdr.FieldCount()];
|
||||
for (int i = 0; i < actlAry.length; i++)
|
||||
actlAry[i] = rdr.KeyValAt(i);
|
||||
Tfds.Eq_ary_str(expdAry, actlAry);
|
||||
GfoTstr.EqAryObjAry(expdAry, actlAry);
|
||||
}
|
||||
public static final DataRdr_Fxt Instance = new DataRdr_Fxt(); DataRdr_Fxt() {}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.libs.files.Io_mgr;
|
||||
import gplx.frameworks.tests.GfoIoTstr;
|
||||
import gplx.types.basics.utls.StringUtl;
|
||||
import gplx.libs.files.Io_url;
|
||||
import org.junit.*;
|
||||
public class z803_useCase_KbdKeyboard_tst {
|
||||
String raw; GfmlDoc gdoc;
|
||||
@Test public void Quote() { // smokeTest; make sure DefaultLxr supports both quoting mechanisms
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( "gfui-keyboard-ui:{"
|
||||
, " keyQuote {"
|
||||
, " \"'\" 'key.quote';"
|
||||
@@ -35,7 +39,7 @@ public class z803_useCase_KbdKeyboard_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Key_LtrA() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
fx.tst_Parse(StringUtl.Concat
|
||||
( TypeHeader
|
||||
, "keys:{"
|
||||
, " keyA {"
|
||||
@@ -53,12 +57,12 @@ public class z803_useCase_KbdKeyboard_tst {
|
||||
);
|
||||
}
|
||||
@Test public void Load_Smoke() {
|
||||
Io_url url = Tfds.RscDir.GenSubFil_nest("110_gfml", "cfgs_archive", "gfui-keyboard-ui.cfg.gfml");
|
||||
Io_url url = GfoIoTstr.RscDir.GenSubFil_nest("110_gfml", "cfgs_archive", "gfui-keyboard-ui.cfg.gfml");
|
||||
raw = Io_mgr.Instance.LoadFilStr(url);
|
||||
gdoc = GfmlDoc_.parse_any_eol_(raw);
|
||||
// Tfds.Write(gdoc.RootNde().To_str());
|
||||
}
|
||||
String TypeHeader = String_.Concat
|
||||
String TypeHeader = StringUtl.Concat
|
||||
( "_type:{"
|
||||
, " keys {"
|
||||
, " key {"
|
||||
|
||||
@@ -13,7 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
package gplx.gfml;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.lists.List_adp;
|
||||
import gplx.types.basics.lists.List_adp_;
|
||||
import org.junit.*;
|
||||
public class z811_useCase_GfmlIoSql_tst {
|
||||
@Test public void Basic() {
|
||||
@@ -34,7 +37,7 @@ public class z811_useCase_GfmlIoSql_tst {
|
||||
void tst_Doc(String raw, GfmlNdeWrapper expd) {
|
||||
GfmlDoc doc = SqlDoc.XtoDoc(raw);
|
||||
GfmlNde actl = (GfmlNde)doc.RootNde();
|
||||
Tfds.Eq_ary_str(To_str(expd.Nde()), To_str(actl));
|
||||
GfoTstr.EqLines(To_str(expd.Nde()), To_str(actl));
|
||||
}
|
||||
String[] To_str(GfmlNde nde) {
|
||||
List_adp list = List_adp_.New();
|
||||
|
||||
@@ -13,8 +13,15 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*; import gplx.core.strings.*; import gplx.core.envs.*;
|
||||
package gplx.gfml;
|
||||
import gplx.libs.files.Io_mgr;
|
||||
import gplx.frameworks.tests.GfoTstr;
|
||||
import gplx.types.basics.utls.LongUtl;
|
||||
import gplx.libs.files.Io_url_;
|
||||
import gplx.types.commons.String_bldr;
|
||||
import gplx.types.commons.String_bldr_;
|
||||
import org.junit.*;
|
||||
import gplx.core.envs.*;
|
||||
public class z901_perf_tst {
|
||||
TimerWatch tmr = TimerWatch.new_();
|
||||
@Test public void EmptyTestSoJunitWillNotFail() {}
|
||||
@@ -42,7 +49,7 @@ public class z901_perf_tst {
|
||||
// tmr.End_and_print("char"); // 1700
|
||||
|
||||
tmr.Bgn();
|
||||
GfmlDoc_.parse_any_eol_(sbGfml.To_str());
|
||||
GfmlDoc_.parse_any_eol_(sbGfml.ToStr());
|
||||
tmr.End_and_print("gfml"); // 1700
|
||||
}
|
||||
//@Test
|
||||
@@ -62,7 +69,7 @@ public class z901_perf_tst {
|
||||
for (int i = 0; i < max; i++)
|
||||
v = c.Val_proc();
|
||||
tmr.End_and_print("proc");
|
||||
Tfds.Write(v);
|
||||
GfoTstr.Write(v);
|
||||
}
|
||||
// @Test
|
||||
// public void ClassComp() {
|
||||
@@ -100,13 +107,13 @@ class PerfFieldVsProc {
|
||||
public int Val_proc() {return 1;}
|
||||
}
|
||||
class TimerWatch {
|
||||
public void Bgn() {bgnTime = System_.Ticks();} long bgnTime;
|
||||
public void End() {duration = System_.Ticks() - bgnTime;} long duration;
|
||||
public void Bgn() {bgnTime = SystemUtl.Ticks();} long bgnTime;
|
||||
public void End() {duration = SystemUtl.Ticks() - bgnTime;} long duration;
|
||||
public void End_and_print(String text) {
|
||||
this.End();
|
||||
Tfds.Write(XtoStr_ms() + " " + text);
|
||||
GfoTstr.Write(XtoStr_ms() + " " + text);
|
||||
}
|
||||
public String XtoStr_ms() {return Long_.To_str(duration);}
|
||||
public String XtoStr_ms() {return LongUtl.ToStr(duration);}
|
||||
public static TimerWatch new_() {
|
||||
TimerWatch rv = new TimerWatch();
|
||||
rv.Bgn();
|
||||
|
||||
Reference in New Issue
Block a user