mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.3.1
This commit is contained in:
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.pfuncs.exprs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.core.btries.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
public class Pfunc_expr_shunter {
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.pfuncs.times; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.core.brys.*;
|
||||
class Pxd_eval_year {
|
||||
public static void Eval_at_pos_0(Pxd_parser tctx, Pxd_itm_int cur) {
|
||||
Pxd_itm[] data_ary = tctx.Data_ary();
|
||||
@@ -80,7 +81,7 @@ class Pxd_eval_seg {
|
||||
tctx.Seg_idxs_(itm, DateAdp_.SegIdx_year);
|
||||
return true;
|
||||
}
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_year, Bry_fmtr_arg_.int_(val));
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_year, Bfr_arg_.New_int(val));
|
||||
return false;
|
||||
}
|
||||
public static boolean Eval_as_m(Pxd_parser tctx, Pxd_itm_int itm) {
|
||||
@@ -94,7 +95,7 @@ class Pxd_eval_seg {
|
||||
}
|
||||
break;
|
||||
}
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_month, Bry_fmtr_arg_.int_(val));
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_month, Bfr_arg_.New_int(val));
|
||||
return false;
|
||||
}
|
||||
public static boolean Eval_as_d(Pxd_parser tctx, Pxd_itm_int itm) {
|
||||
@@ -108,7 +109,7 @@ class Pxd_eval_seg {
|
||||
}
|
||||
break;
|
||||
}
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_day, Bry_fmtr_arg_.int_(val));
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_day, Bfr_arg_.New_int(val));
|
||||
return false;
|
||||
}
|
||||
public static boolean Eval_as_h(Pxd_parser tctx, Pxd_itm_int itm) {
|
||||
@@ -122,7 +123,7 @@ class Pxd_eval_seg {
|
||||
}
|
||||
break;
|
||||
}
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_hour, Bry_fmtr_arg_.int_(val));
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_hour, Bfr_arg_.New_int(val));
|
||||
return false;
|
||||
}
|
||||
public static boolean Eval_as_n(Pxd_parser tctx, Pxd_itm_int itm) {
|
||||
@@ -136,7 +137,7 @@ class Pxd_eval_seg {
|
||||
}
|
||||
break;
|
||||
}
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_minute, Bry_fmtr_arg_.int_(val));
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_minute, Bfr_arg_.New_int(val));
|
||||
return false;
|
||||
}
|
||||
public static boolean Eval_as_s(Pxd_parser tctx, Pxd_itm_int itm) {
|
||||
@@ -150,7 +151,7 @@ class Pxd_eval_seg {
|
||||
}
|
||||
break;
|
||||
}
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_second, Bry_fmtr_arg_.int_(val));
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_second, Bfr_arg_.New_int(val));
|
||||
return false;
|
||||
}
|
||||
public static boolean Eval_as_tz_h(Pxd_parser tctx, Pxd_itm_int itm, boolean negative) {
|
||||
@@ -166,7 +167,7 @@ class Pxd_eval_seg {
|
||||
}
|
||||
break;
|
||||
}
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_hour, Bry_fmtr_arg_.int_(val));
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_hour, Bfr_arg_.New_int(val));
|
||||
return false;
|
||||
}
|
||||
public static boolean Eval_as_tz_m(Pxd_parser tctx, Pxd_itm_int itm, boolean negative) {
|
||||
@@ -182,7 +183,7 @@ class Pxd_eval_seg {
|
||||
}
|
||||
break;
|
||||
}
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_minute, Bry_fmtr_arg_.int_(val));
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_minute, Bfr_arg_.New_int(val));
|
||||
return false;
|
||||
}
|
||||
public static byte Eval_as_tz_sym(Pxd_parser tctx, Pxd_itm[] tkns, Pxd_itm_int hour_itm) {
|
||||
@@ -195,7 +196,7 @@ class Pxd_eval_seg {
|
||||
break;
|
||||
case Pxd_itm_.Tid_dash: return Bool_.N_byte;
|
||||
}
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_timezone, Bry_fmtr_arg_.bry_("null"));
|
||||
tctx.Err_set(Pft_func_time_log.Invalid_timezone, Bfr_arg_.New_bry("null"));
|
||||
return Bool_.__byte;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.pfuncs.times; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.core.brys.*;
|
||||
interface Pxd_itm_int_interface extends Pxd_itm {
|
||||
int Xto_int_or(int or);
|
||||
}
|
||||
@@ -220,7 +221,7 @@ class Pxd_itm_int extends Pxd_itm_base implements Pxd_itm_int_interface {
|
||||
}
|
||||
private void Eval_unknown_at_pos_0(Pxd_parser tctx) { // NOTE: assumes dmy format
|
||||
Pxd_itm[] data_ary = tctx.Data_ary();
|
||||
if (tctx.Data_ary_len() < 2) {tctx.Err_set(Pft_func_time_log.Invalid_year, Bry_fmtr_arg_.int_(val)); return;}
|
||||
if (tctx.Data_ary_len() < 2) {tctx.Err_set(Pft_func_time_log.Invalid_year, Bfr_arg_.New_int(val)); return;}
|
||||
Pxd_itm_int itm_1 = Pxd_itm_int_.CastOrNull(data_ary[1]);
|
||||
if (itm_1 != null) { // if 1st itm to right is number, parse it as month
|
||||
if (!Pxd_eval_seg.Eval_as_m(tctx, itm_1)) return;
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.pfuncs.times; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.core.brys.*;
|
||||
class Pxd_itm_colon extends Pxd_itm_base {
|
||||
@Override public byte Tkn_tid() {return Pxd_itm_.Tid_colon;}
|
||||
@Override public int Eval_idx() {return 20;}
|
||||
@@ -26,7 +27,7 @@ class Pxd_itm_colon extends Pxd_itm_base {
|
||||
switch (colon_count) {
|
||||
case 1: // hh:mm
|
||||
itm_int = Pxd_itm_int_.GetNearest(tkns, this.Ary_idx(), Bool_.N);
|
||||
if (itm_int == null) {state.Err_set(Pft_func_time_log.Invalid_hour, Bry_fmtr_arg_.bry_("null")); return;}
|
||||
if (itm_int == null) {state.Err_set(Pft_func_time_log.Invalid_hour, Bfr_arg_.New_bry("null")); return;}
|
||||
if (!Pxd_eval_seg.Eval_as_h(state, itm_int)) return;
|
||||
itm_int = Pxd_itm_int_.GetNearest(tkns, this.Ary_idx(), true);
|
||||
if (!Pxd_eval_seg.Eval_as_n(state, itm_int)) return;
|
||||
@@ -37,13 +38,13 @@ class Pxd_itm_colon extends Pxd_itm_base {
|
||||
break;
|
||||
case 3: // +hh:mm; DATE:2014-08-26
|
||||
itm_int = Pxd_itm_int_.GetNearest(tkns, this.Ary_idx(), Bool_.N);
|
||||
if (itm_int == null) {state.Err_set(Pft_func_time_log.Invalid_timezone, Bry_fmtr_arg_.bry_("null")); return;}
|
||||
if (itm_int == null) {state.Err_set(Pft_func_time_log.Invalid_timezone, Bfr_arg_.New_bry("null")); return;}
|
||||
byte tz_positive_val = Pxd_eval_seg.Eval_as_tz_sym(state, tkns, itm_int);
|
||||
if (tz_positive_val == Bool_.__byte) return;
|
||||
boolean tz_negative = tz_positive_val == Bool_.N_byte;
|
||||
if (!Pxd_eval_seg.Eval_as_tz_h(state, itm_int, tz_negative)) return;
|
||||
itm_int = Pxd_itm_int_.GetNearest(tkns, this.Ary_idx(), Bool_.Y);
|
||||
if (itm_int == null) {state.Err_set(Pft_func_time_log.Invalid_timezone, Bry_fmtr_arg_.bry_("null")); return;}
|
||||
if (itm_int == null) {state.Err_set(Pft_func_time_log.Invalid_timezone, Bfr_arg_.New_bry("null")); return;}
|
||||
if (tz_negative) itm_int.Val_(itm_int.Val() * -1);
|
||||
if (!Pxd_eval_seg.Eval_as_tz_m(state, itm_int, tz_negative)) return;
|
||||
break;
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.pfuncs.times; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.core.brys.*;
|
||||
class Pxd_itm_month_name extends Pxd_itm_base implements Pxd_itm_prototype {
|
||||
public Pxd_itm_month_name(int ary_idx, byte[] name, int seg_idx, int seg_val) {Ctor(ary_idx); this.name = name; Seg_idx_(seg_idx); this.seg_val = seg_val;} private byte[] name;
|
||||
@Override public byte Tkn_tid() {return Pxd_itm_.Tid_month_name;}
|
||||
@@ -231,10 +232,10 @@ class Pxd_itm_day_suffix extends Pxd_itm_base implements Pxd_itm_prototype {
|
||||
@Override public void Eval(Pxd_parser state) {
|
||||
Pxd_itm[] tkn_ary = state.Tkns();
|
||||
int tkn_idx = this.Ary_idx();
|
||||
if (tkn_idx == 0) state.Err_set(Pft_func_time_log.Invalid_day, Bry_fmtr_arg_.int_(Int_.Min_value));
|
||||
if (tkn_idx == 0) state.Err_set(Pft_func_time_log.Invalid_day, Bfr_arg_.New_int(Int_.Min_value));
|
||||
Pxd_itm day_itm = tkn_ary[tkn_idx - 1];
|
||||
if (day_itm.Seg_idx() != DateAdp_.SegIdx_day) {
|
||||
state.Err_set(Pft_func_time_log.Invalid_day, Bry_fmtr_arg_.int_(Int_.Min_value));
|
||||
state.Err_set(Pft_func_time_log.Invalid_day, Bfr_arg_.New_int(Int_.Min_value));
|
||||
}
|
||||
}
|
||||
public static final Pxd_itm_day_suffix Instance = new Pxd_itm_day_suffix(); Pxd_itm_day_suffix() {}
|
||||
@@ -290,7 +291,7 @@ class Pxd_itm_unit_relative extends Pxd_itm_base implements Pxd_itm_prototype {
|
||||
public Pxd_itm MakeNew(int ary_idx) {return new Pxd_itm_unit_relative(adj, ary_idx);}
|
||||
@Override public void Eval(Pxd_parser state) {
|
||||
Pxd_itm itm = Pxd_itm_.Find_fwd_by_tid(state.Tkns(), this.Ary_idx() + 1, Pxd_itm_.Tid_unit);
|
||||
if (itm == null) state.Err_set(Pft_func_time_log.Invalid_date, Bry_fmtr_arg_.int_(adj));
|
||||
if (itm == null) state.Err_set(Pft_func_time_log.Invalid_date, Bfr_arg_.New_int(adj));
|
||||
Pxd_itm_unit unit_tkn = (Pxd_itm_unit)itm;
|
||||
unit_tkn.Unit_seg_val_(adj);
|
||||
}
|
||||
@@ -350,7 +351,7 @@ class Pxd_itm_iso8601_t extends Pxd_itm_base implements Pxd_itm_prototype {
|
||||
@Override public void Eval(Pxd_parser state) {
|
||||
Pxd_itm hour = Next_non_ws_tkn(state.Tkns(), this.Ary_idx() + 1);
|
||||
if (hour != null && hour.Seg_idx() == DateAdp_.SegIdx_hour) return; // next item is hour
|
||||
state.Err_set(Pft_func_time_log.Invalid_hour, Bry_fmtr_arg_.bry_("T"));
|
||||
state.Err_set(Pft_func_time_log.Invalid_hour, Bfr_arg_.New_bry("T"));
|
||||
}
|
||||
@Override public void Time_ini(DateAdpBldr bldr) {}
|
||||
private static Pxd_itm Next_non_ws_tkn(Pxd_itm[] tkns, int bgn) {
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.pfuncs.times; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.core.btries.*; import gplx.core.log_msgs.*;
|
||||
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*; import gplx.core.btries.*; import gplx.core.log_msgs.*;
|
||||
class Pxd_parser {
|
||||
byte[] src; int cur_pos, tkn_bgn_pos, src_len, tkn_type;
|
||||
public Pxd_itm[] Tkns() {return tkns;} Pxd_itm[] tkns;
|
||||
@@ -37,7 +37,7 @@ class Pxd_parser {
|
||||
if (seg_idx >= 0) // ignore Seg_idx_null and Seg_idx_skip
|
||||
seg_idxs[seg_idx] = val;
|
||||
}
|
||||
public void Err_set(Gfo_msg_itm itm, Bry_fmtr_arg... args) {
|
||||
public void Err_set(Gfo_msg_itm itm, Bfr_arg... args) {
|
||||
if (itm == null) return;
|
||||
Bry_fmtr fmtr = itm.Fmtr();
|
||||
fmtr.Bld_bfr(error_bfr, args);
|
||||
@@ -128,7 +128,7 @@ class Pxd_parser {
|
||||
}
|
||||
DateAdp Evaluate(byte[] src, Bry_bfr error) {
|
||||
if (tkns_len == 0) {
|
||||
Err_set(Pft_func_time_log.Invalid_day, Bry_fmtr_arg_.bry_(src));
|
||||
Err_set(Pft_func_time_log.Invalid_day, Bfr_arg_.New_bry(src));
|
||||
return null;
|
||||
}
|
||||
Pxd_itm[] eval_ary = Pxd_itm_sorter.XtoAryAndSort(tkns, tkns_len);
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.pfuncs.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.core.btries.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.tmpls.*;
|
||||
public class Pfunc_anchorencode extends Pf_func_base { // EX: {{anchorencode:a b}} -> a+b
|
||||
@@ -25,8 +25,8 @@ public class Pfunc_anchorencode extends Pf_func_base { // EX: {{anchorencode:a b
|
||||
@Override public Pf_func New(int id, byte[] name) {return new Pfunc_anchorencode().Name_(name);}
|
||||
public static void Func_init(Xop_ctx ctx) {
|
||||
if (anchor_ctx != null) return;// NOTE: called by Scrib_uri
|
||||
encode_trie.Add(Byte_ascii.Colon, Bry_fmtr_arg_.byt_(Byte_ascii.Colon));
|
||||
encode_trie.Add(Byte_ascii.Space, Bry_fmtr_arg_.byt_(Byte_ascii.Underline));
|
||||
encode_trie.Add(Byte_ascii.Colon, Bfr_arg_.New_byte(Byte_ascii.Colon));
|
||||
encode_trie.Add(Byte_ascii.Space, Bfr_arg_.New_byte(Byte_ascii.Underline));
|
||||
anchor_ctx = Xop_ctx.new_sub_(ctx.Wiki());
|
||||
anchor_ctx.Para().Enabled_n_();
|
||||
anchor_tkn_mkr = anchor_ctx.Tkn_mkr();
|
||||
|
||||
Reference in New Issue
Block a user