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.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);
|
||||
|
||||
Reference in New Issue
Block a user