Xomw.Preprocessor: Integrate rest of Preprocessor_Hash tests [#508]

pull/620/head
gnosygnu 5 years ago
parent 0280254e8a
commit 0854cf9ba1

@ -21,7 +21,7 @@ public class String_ {
public static final Class<?> Cls_ref_type = String.class;
public static final String Cls_val_name = "str" + "ing";
public static final int Find_none = -1, Pos_neg1 = -1;
public static final String Empty = "", Null_mark = "<<NULL>>", Tab = "\t", Lf = "\n", CrLf = "\r\n";
public static final String Empty = "", Null_mark = "<<NULL>>", Tab = "\t", Lf = "\n", CrLf = "\r\n", Nl = "\n";
public static boolean Eq(String lhs, String rhs) {return lhs == null ? rhs == null : lhs.equals(rhs);}
public static int Len(String s) {return s.length();}

@ -140,4 +140,14 @@ public class XophpArrayUtl {
}
return rv;
}
// ( array $array , int $offset [, int $length = NULL [, boolean $preserve_keys = FALSE ]] ) :
public static XophpArray array_slice(XophpArray array, int offset) {return array_slice(array, offset, array.Len());}
public static XophpArray array_slice(XophpArray array, int offset, int length) {
XophpArray rv = new XophpArray();
int end = offset + length;
for (int i = offset; i< end; i++) {
rv.Add(array.Get_at(i));
}
return rv;
}
}

@ -160,12 +160,13 @@ public class XophpString {
public static int strlen(byte[] src) {return src.length;}
public static String str_repeat(String val, int count) {
int val_len = String_.Len(val);
char[] chry = new char[val_len];
int chry_len = val_len * count;
char[] chry = new char[chry_len];
for (int i = 0; i < count; i++) {
for (int j = 0; i < val_len; j++) {
for (int j = 0; j < val_len; j++) {
chry[(i * val_len) + j] = String_.CharAt(val, j);
}
}
return String_.new_charAry_(chry, 0, val_len);
return String_.new_charAry_(chry, 0, chry_len);
}
}

@ -49,6 +49,11 @@ public class XophpString_tst {
fxt.Test_strtr_by_trie("01_ab" , "89_ab"); // BOS
fxt.Test_strtr_by_trie("ab_01" , "ab_89"); // EOS
}
@Test public void Str_repeat() {
fxt.Test_str_repeat("abc", 3, "abcabcabc");
fxt.Test_str_repeat("", 3, "");
fxt.Test_str_repeat("abc", 0, "");
}
}
class XophpString_fxt {
public void Test_strspn_fwd__byte(String src_str, byte find, int bgn, int max, int expd) {
@ -82,4 +87,7 @@ class XophpString_fxt {
Btrie_rv trv = new Btrie_rv();
Gftest.Eq__str(expd, XophpString.strtr(Bry_.new_u8(src), strtr_trie, tmp, trv));
}
public void Test_str_repeat(String str, int count, String expd) {
Gftest.Eq__str(expd, XophpString.str_repeat(str, count));
}
}

@ -26,6 +26,6 @@ public class XophpType {
return type_id == Type_ids_.Id__array;
}
public static XophpType New(Object o) {
return new XophpType(Type_ids_.To_id_by_obj(o));
return new XophpType(XophpTypeUtl.To_type_id(o));
}
}

@ -15,10 +15,23 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
public class XophpTypeUtl {
// REF.PHP: https://www.php.net/manual/en/function.is-scalar.php
public static boolean is_scalar(Object obj) {
if (obj == null) return false;
int type_id = Type_ids_.To_id_by_type(obj.getClass());
public static int To_type_id(Object o) {
int type_id = Type_ids_.To_id_by_obj(o);
switch (type_id) {
case Type_ids_.Id__bry:
type_id = Type_ids_.Id__str;
break;
case Type_ids_.Id__obj:
if (Type_.Eq_by_obj(o, XophpArray.class)) {
type_id = Type_ids_.Id__array;
}
break;
}
return type_id;
}
public static boolean is_scalar(Object o) { // REF.PHP: https://www.php.net/manual/en/function.is-scalar.php
if (o == null) return false;
int type_id = To_type_id(o);
switch (type_id) {
case Type_ids_.Id__int:
case Type_ids_.Id__float:
@ -29,6 +42,7 @@ public class XophpTypeUtl {
return false;
}
}
public static boolean is_string(Object obj) {return Type_.Eq_by_obj(obj, String.class);}
public static boolean is_string(Object o) {
return To_type_id(o) == Type_ids_.Id__str;
}
}

@ -155,7 +155,7 @@ public abstract class XomwPreprocessor {
private final Btrie_slim_mgr elements_trie__y = Btrie_slim_mgr.ci_a7(), elements_trie__n = Btrie_slim_mgr.ci_a7();
private final Hash_adp_bry xmlish_allow_missing_end_tag = Hash_adp_bry.cs().Add_many_str("includeonly", "noinclude", "onlyinclude");
private final Hash_adp_bry no_more_closing_tag = Hash_adp_bry.cs();
private final XomwPPDStackOld stack;
private final XomwPPDStack stack;
private final Btrie_rv trv = new Btrie_rv();
private Xomw_prepro_accum accum = null;
@ -188,7 +188,7 @@ public abstract class XomwPreprocessor {
trie.Add_obj(hook, new Xomw_prepro_elem(type_is_comment ? Xomw_prepro_elem.Type__comment : Xomw_prepro_elem.Type__other, Bry_.new_a7(name)));
}
public abstract byte[] preprocessToDbg(byte[] src, boolean for_inclusion);
public abstract String preprocessToDbg(byte[] src, boolean for_inclusion);
/**
* @param String $text
* @param int $flags
@ -241,7 +241,7 @@ public abstract class XomwPreprocessor {
int i = 0;
// Current accumulator
accum = this.Accum__set(stack.Get_accum());
accum = this.Accum__set(stack.getAccum());
this.preprocessToObj_root();
// True to find equals signs in arguments
@ -270,7 +270,7 @@ public abstract class XomwPreprocessor {
int src_len = src.length;
int found = -1;
byte[] cur_char = Bry_.Empty;
byte[] cur_closing = Bry_.Empty;
String cur_closing = "";
byte[] inner = null;
Xomw_prepro_rule rule = null;
@ -297,7 +297,7 @@ public abstract class XomwPreprocessor {
// Find next opening brace, closing brace or pipe
// RELIC.REGEX: $search = $searchBase;
if (stack.top == null) {
cur_closing = Bry_.Empty;
cur_closing = "";
}
else {
cur_closing = stack.top.close;
@ -332,10 +332,10 @@ public abstract class XomwPreprocessor {
if (findEquals) loop_stop = true;
break;
default: // handle "cur_closing"; specified by piece.close and rule.close, so "\n", "}", "]" and "}-"
if (cur_closing != Bry_.Empty) {
byte cur_closing_0 = cur_closing[0];
if (String_.EqNot(cur_closing, "")) {
byte cur_closing_0 = (byte)String_.CharAt(cur_closing, 0);
if (b == cur_closing_0) {
if (cur_closing.length == 1) { // handle "\n", "}", "]"
if (String_.Len(cur_closing) == 1) { // handle "\n", "}", "]"
loop_stop = true;
}
else {// handle "}-"
@ -357,7 +357,7 @@ public abstract class XomwPreprocessor {
i += literal_len;
}
if (i >= src_len) {
if (Bry_.Eq(cur_closing, Byte_ascii.Nl_bry)) {
if (String_.Eq(cur_closing, String_.Nl)) {
// Do a past-the-end run to finish off the heading
cur_char = Bry_.Empty;
found = Found__line_end;
@ -487,7 +487,7 @@ public abstract class XomwPreprocessor {
}
if (stack.top != null) {
XomwPPDPart part = stack.top.Get_current_part();
XomwPPDPart part = stack.top.getCurrentPart();
if (!(part.commentEnd != -1 && part.commentEnd == ws_bgn - 1)) {
part.visualEnd = ws_bgn;
}
@ -617,11 +617,11 @@ public abstract class XomwPreprocessor {
// complex.
}
else if (count > 0) {
Xomw_prepro_piece piece = new Xomw_prepro_piece(Factory__part(), Byte_ascii.Nl_bry, Byte_ascii.Nl_bry, count, i, false);
piece.Add_part(Bry_.Repeat(Byte_ascii.Eq, count));
stack.Push(piece);
accum = this.Accum__set(stack.Get_accum());
Xomw_prepro_flags flags = stack.Get_flags();
XomwPPDStackElement piece = Factory__stack_element(Factory__part(), String_.Nl, String_.Nl, count, i, false);
piece.addPart(XophpString.str_repeat("=", count));
stack.push(piece);
accum = this.Accum__set(stack.getAccum());
XomwPPDStackElementFlags flags = stack.getFlags();
findPipe = flags.findPipe;
findEquals = flags.findEquals;
inHeading = flags.inHeading;
@ -629,10 +629,10 @@ public abstract class XomwPreprocessor {
}
}
else if (found == Found__line_end) {
Xomw_prepro_piece piece = stack.top;
XomwPPDStackElement piece = stack.top;
// A heading must be open, otherwise \n wouldn't have been in the search list
if (!Bry_.Eq(piece.open, Byte_ascii.Nl_bry)) throw Err_.new_wo_type("assertion:piece must start with \\n");
XomwPPDPart part = piece.Get_current_part();
if (!String_.Eq(piece.open, String_.Nl)) throw Err_.new_wo_type("assertion:piece must start with \\n");
XomwPPDPart part = piece.getCurrentPart();
// Search back through the input to see if it has a proper close.
// Do this using the reversed String since the other solutions
@ -683,10 +683,10 @@ public abstract class XomwPreprocessor {
}
// Unwind the stack
stack.Pop();
this.accum = this.Accum__set(stack.Get_accum());
stack.pop();
this.accum = this.Accum__set(stack.getAccum());
Xomw_prepro_flags flags = stack.Get_flags();
XomwPPDStackElementFlags flags = stack.getFlags();
findPipe = flags.findPipe;
findEquals = flags.findEquals;
inHeading = flags.inHeading;
@ -706,11 +706,10 @@ public abstract class XomwPreprocessor {
// we need to add to stack only if opening brace count is enough for one of the rules
if (count >= rule.min) {
// Add it to the stack
Xomw_prepro_piece piece = new Xomw_prepro_piece(Factory__part(), cur_char, rule.end, count, -1, i > 0 && src[i - 1] == Byte_ascii.Nl);
stack.Push(piece);
this.accum = this.Accum__set(stack.Get_accum());
Xomw_prepro_flags flags = stack.Get_flags();
XomwPPDStackElement piece = Factory__stack_element(Factory__part(), String_.new_u8(cur_char), String_.new_u8(rule.end), count, -1, i > 0 && src[i - 1] == Byte_ascii.Nl);
stack.push(piece);
this.accum = this.Accum__set(stack.getAccum());
XomwPPDStackElementFlags flags = stack.getFlags();
findPipe = flags.findPipe;
findEquals = flags.findEquals;
inHeading = flags.inHeading;
@ -723,7 +722,7 @@ public abstract class XomwPreprocessor {
i += count;
}
else if (found == Found__close) {
Xomw_prepro_piece piece = stack.top;
XomwPPDStackElement piece = stack.top;
// lets check if there are enough characters for closing brace
int max_count = piece.count;
int count = XophpString.strspn_fwd__byte(src, cur_char[0], i, max_count, src_len);
@ -759,7 +758,7 @@ public abstract class XomwPreprocessor {
Xomw_prepro_accum element = null;
if (name_type == Xomw_prepro_rule.Name__null) {
// No element, just literal text
element = this.preprocessToObj_text(element, piece, rule.end, matching_count);
element = this.preprocessToObj_text(piece, rule.end, matching_count);
}
else {
// Create XML element
@ -770,8 +769,8 @@ public abstract class XomwPreprocessor {
i += matching_count;
// Unwind the stack
stack.Pop();
this.accum = this.Accum__set(stack.Get_accum());
stack.pop();
this.accum = this.Accum__set(stack.getAccum());
// Re-add the old stack element if it still has unmatched opening characters remaining
if (matching_count < piece.count) {
@ -781,15 +780,15 @@ public abstract class XomwPreprocessor {
// do we still qualify for any callback with remaining count?
int min = Get_rule(piece.open).min;
if (piece.count >= min) {
stack.Push(piece);
this.accum = this.Accum__set(stack.Get_accum());
stack.push(piece);
this.accum = this.Accum__set(stack.getAccum());
}
else {
this.preprocessToObj_literal(Bry_.Repeat_bry(piece.open, piece.count));
this.preprocessToObj_literal(Bry_.new_u8(XophpString.str_repeat(piece.open, piece.count)));
}
}
Xomw_prepro_flags flags = stack.Get_flags();
XomwPPDStackElementFlags flags = stack.getFlags();
findPipe = flags.findPipe;
findEquals = flags.findEquals;
inHeading = flags.inHeading;
@ -799,8 +798,8 @@ public abstract class XomwPreprocessor {
}
else if (found == Found__pipe) {
findEquals = true; // shortcut for getFlags()
stack.Add_part(Bry_.Empty);
this.accum = this.Accum__set(stack.Get_accum());
stack.addPart("");
this.accum = this.Accum__set(stack.getAccum());
i++;
}
else if (found == Found__equals) {
@ -814,6 +813,7 @@ public abstract class XomwPreprocessor {
return this.preprocessToObj_term(stack);
}
private Xomw_prepro_rule Get_rule(String str) {return Get_rule(Bry_.new_u8(str));}
private Xomw_prepro_rule Get_rule(byte[] bry) {
if (Bry_.Eq(bry, rule_curly.bgn)) return rule_curly;
else if (Bry_.Eq(bry, rule_brack.bgn)) return rule_brack;
@ -864,7 +864,8 @@ public abstract class XomwPreprocessor {
}
protected abstract XomwPPDPart Factory__part();
protected abstract XomwPPDStackOld Factory__stack();
protected abstract XomwPPDStack Factory__stack();
protected abstract XomwPPDStackElement Factory__stack_element(XomwPPDPart part_factory, String open, String close, int count, int start_pos, boolean lineStart);
protected abstract Xomw_prepro_accum Accum__set(Xomw_prepro_accum accum);
@ -880,10 +881,10 @@ public abstract class XomwPreprocessor {
protected abstract Xomw_prepro_accum preprocessToObj_heading_init(int count, int heading_index);
protected abstract void preprocessToObj_heading_end(Xomw_prepro_accum element);
protected abstract void preprocessToObj_removeLeadingWhitespaceFromEnd(int ws_len);
protected abstract Xomw_prepro_accum preprocessToObj_text(Xomw_prepro_accum element, Xomw_prepro_piece piece, byte[] rule_end, int matching_count);
protected abstract Xomw_prepro_accum preprocessToObj_xml(Xomw_prepro_piece piece, byte[] name_bry, int max_count, int matching_count);
protected abstract Xomw_prepro_accum preprocessToObj_text(XomwPPDStackElement piece, byte[] rule_end, int matching_count);
protected abstract Xomw_prepro_accum preprocessToObj_xml(XomwPPDStackElement piece, byte[] name_bry, int max_count, int matching_count);
protected abstract void preprocessToObj_add_element(Xomw_prepro_accum element);
protected abstract void preprocessToObj_equals(XomwPPDStackOld stack);
protected abstract Object preprocessToObj_term(XomwPPDStackOld stack);
protected abstract void preprocessToObj_equals(XomwPPDStack stack);
protected abstract Object preprocessToObj_term(XomwPPDStack stack);
public abstract XomwPreprocessor Make_new(XomwParser parser);
}

@ -20,8 +20,9 @@ import gplx.xowa.mediawiki.includes.parsers.preprocessors.*;
class XomwPreprocessor_DOM extends XomwPreprocessor { private final Bry_bfr tmp_bfr = Bry_bfr_.New();
private Xomw_prepro_accum__dom accum_dom = new Xomw_prepro_accum__dom("");
@Override protected XomwPPDStackOld Factory__stack() {return new XomwPPDStackOld(Xomw_prepro_accum__dom.Instance);}
@Override protected XomwPPDPart Factory__part() {return new XomwPPDPart_DOM("");}
@Override protected XomwPPDStack Factory__stack() {return new XomwPPDStack(Xomw_prepro_accum__dom.Instance);}
@Override protected XomwPPDStackElement Factory__stack_element(XomwPPDPart part_factory, String open, String close, int count, int start_pos, boolean lineStart) {return new XomwPPDStackElement(part_factory, open, close, count, start_pos, lineStart);}
@Override public XomwPPFrame newFrame() {
return null;
@ -34,7 +35,7 @@ class XomwPreprocessor_DOM extends XomwPreprocessor { private final Bry_bfr
return accum;
}
@Override public byte[] preprocessToDbg(byte[] src, boolean for_inclusion) {return (byte[])this.preprocessToObj_base(src, for_inclusion);}
@Override public String preprocessToDbg(byte[] src, boolean for_inclusion) {return String_.new_u8((byte[])this.preprocessToObj_base(src, for_inclusion));}
@Override public XomwPPNode preprocessToObj(String text, int flags) {
return (XomwPPNode)preprocessToObj_base(Bry_.new_u8(text), gplx.core.bits.Bitmask_.Has_int(flags, XomwParser.PTD_FOR_INCLUSION));
}
@ -89,25 +90,22 @@ class XomwPreprocessor_DOM extends XomwPreprocessor { private final Bry_bfr
@Override protected void preprocessToObj_heading_end(Xomw_prepro_accum element) {
accum_dom.Add_bry(((Xomw_prepro_accum__dom)element).To_bry());
}
@Override protected Xomw_prepro_accum preprocessToObj_text(Xomw_prepro_accum element_obj, Xomw_prepro_piece piece, byte[] rule_end, int matching_count) {
Xomw_prepro_accum__dom element = (Xomw_prepro_accum__dom)element_obj;
tmp_bfr.Add(piece.Break_syntax(tmp_bfr, matching_count));
if (element != null)
tmp_bfr.Add(element.To_bry());
@Override protected Xomw_prepro_accum preprocessToObj_text(XomwPPDStackElement piece, byte[] rule_end, int matching_count) {
tmp_bfr.Add_str_u8((String)piece.breakSyntax(matching_count));
tmp_bfr.Add(Bry_.Repeat_bry(rule_end, matching_count));
byte[] rv = tmp_bfr.To_bry_and_clear();
return new Xomw_prepro_accum__dom(String_.new_u8(rv));
}
@Override protected Xomw_prepro_accum preprocessToObj_xml(Xomw_prepro_piece piece, byte[] name_bry, int max_count, int matching_count) {
@Override protected Xomw_prepro_accum preprocessToObj_xml(XomwPPDStackElement piece, byte[] name_bry, int max_count, int matching_count) {
// Note: $parts is already XML, does not need to be encoded further
List_adp parts = piece.parts;
XophpArray parts = piece.parts;
byte[] title = ((XomwPPDPart_DOM)parts.Get_at(0)).To_bry();
parts.Del_at(0);
// The invocation is at the start of the line if lineStart is set in
// the stack, and all opening brackets are used up.
byte[] attr = null;
if (max_count == matching_count && piece.line_start) { // RELIC:!empty( $piece->lineStart )
if (max_count == matching_count && piece.lineStart) { // RELIC:!empty( $piece->lineStart )
attr = Bry_.new_a7(" lineStart=\"1\"");
}
else {
@ -138,11 +136,11 @@ class XomwPreprocessor_DOM extends XomwPreprocessor { private final Bry_bfr
@Override protected void preprocessToObj_add_element(Xomw_prepro_accum element) {
accum_dom.Add_bry(((Xomw_prepro_accum__dom)element).To_bry());
}
@Override protected void preprocessToObj_equals(XomwPPDStackOld stack) {
stack.Get_current_part().eqpos = accum_dom.Len();
@Override protected void preprocessToObj_equals(XomwPPDStack stack) {
stack.getCurrentPart().eqpos = accum_dom.Len();
accum_dom.Add_bry(Byte_ascii.Eq_bry);
}
@Override protected Object preprocessToObj_term(XomwPPDStackOld stack) {
@Override protected Object preprocessToObj_term(XomwPPDStack stack) {
Bry_bfr root_accum = Bry_bfr_.New().Add_str_u8(((Xomw_prepro_accum__dom)stack.Get_root_accum()).To_str());
int stack_len = stack.stack.Len();
for (int j = 0; j < stack_len; j++) {

@ -25,16 +25,18 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
return null;
}
@Override protected XomwPPDStackOld Factory__stack() {return new XomwPPDStackOld_Hash(Xomw_prepro_accum__hash.Instance);}
@Override protected XomwPPDPart Factory__part() {return new XomwPPDPart_Hash("");}
@Override protected XomwPPDStack Factory__stack() {return new XomwPPDStack(Xomw_prepro_accum__hash.Instance);}
@Override protected XomwPPDStackElement Factory__stack_element(XomwPPDPart part_factory, String open, String close, int count, int start_pos, boolean lineStart) {return new XomwPPDStackElement_Hash(part_factory, open, close, count, start_pos, lineStart);}
@Override protected Xomw_prepro_accum Accum__set(Xomw_prepro_accum accum_obj) {
this.accum = ((Xomw_prepro_accum__hash)accum_obj).Ary();
return accum_obj;
}
@Override public byte[] preprocessToDbg(byte[] src, boolean for_inclusion) {
@Override public String preprocessToDbg(byte[] src, boolean for_inclusion) {
XomwPPNode_Hash_Tree node = (XomwPPNode_Hash_Tree)this.preprocessToObj_base(src, for_inclusion);
return Bry_.new_u8(node.toString());
return node.toString();
}
@Override public XomwPPNode preprocessToObj(String text, int flags) {
return (XomwPPNode)preprocessToObj_base(Bry_.new_u8(text), gplx.core.bits.Bitmask_.Has_int(flags, XomwParser.PTD_FOR_INCLUSION));
@ -42,22 +44,22 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
@Override protected void preprocessToObj_root() {} // NOTE: deliberately empty;
@Override protected void preprocessToObj_ignore(byte[] src, int bgn, int end) {
accum.Add(XophpArray.New("ignore", XophpString.substr(src, bgn, end)));
accum.Add(XophpArray.New("ignore", XophpArray.New(XophpString.substr(src, bgn, end - bgn))));
}
@Override protected void preprocessToObj_literal(byte[] src, int bgn, int end) {
addLiteral(accum, XophpString.substr(src, bgn, end));
addLiteral(accum, XophpString.substr(src, bgn, end - bgn));
}
@Override protected void preprocessToObj_comment(byte[] src, int bgn, int end) {
accum.Add(XophpArray.New("comment", XophpString.substr(src, bgn, end)));
accum.Add(XophpArray.New("comment", XophpArray.New(XophpString.substr(src, bgn, end - bgn))));
}
@Override protected void preprocessToObj_removeLeadingWhitespaceFromEnd(int ws_len) {
int endIndex = accum.Len() - 1;
if ( ws_len > 0
&& endIndex >= 0) {
Object itm_obj = accum.Get_at(endIndex);
if (Type_.Eq_by_obj(itm_obj, Bry_.Cls_ref_type)) {
byte[] itm = (byte[])itm_obj;
if (XophpString.strspn_fwd__space_or_tab(itm, 0, itm.length, itm.length) == ws_len) {
if (XophpTypeUtl.is_string(itm_obj)) {
byte[] itm = Bry_.new_u8((String)itm_obj);
if (XophpString.strspn_fwd__space_or_tab(itm, itm.length - ws_len, -1, itm.length) == ws_len) {
accum.Set(endIndex, XophpString.substr(itm, 0, -ws_len));
}
}
@ -69,19 +71,19 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
}
@Override protected void preprocessToObj_ext(byte[] src, byte[] name, int atr_bgn, int atr_end, byte[] inner, byte[] close) {
XophpArray children = XophpArray.New();
children.Add(XophpArray.New("name", name));
children.Add(XophpArray.New("attr", Bry_.Mid(src, atr_bgn, atr_end)));
children.Add(XophpArray.New("name", XophpArray.New(name)));
children.Add(XophpArray.New("attr", XophpArray.New(String_.new_u8(Bry_.Mid(src, atr_bgn, atr_end)))));
if (inner != null)
children.Add(XophpArray.New("inner", inner));
children.Add(XophpArray.New("inner", XophpArray.New(inner)));
if (close != null)
children.Add(XophpArray.New("close", close));
children.Add(XophpArray.New("close", XophpArray.New(close)));
accum.Add(XophpArray.New("ext", children));
}
@Override protected Xomw_prepro_accum preprocessToObj_heading_init(int count, int heading_index) {
Xomw_prepro_accum__hash rv = new Xomw_prepro_accum__hash();
Xomw_prepro_accum__hash rv = new Xomw_prepro_accum__hash(XophpArray.New());
rv.Ary().Add
( XophpArray.New
( "possible-h",
( "h",
XophpArrayUtl.array_merge
( XophpArray.New
( XophpArray.New("@level", XophpArray.New(count))
@ -97,62 +99,57 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
XophpArrayUtl.array_splice(accum, accum.Len(), 0, ((Xomw_prepro_accum__hash)element).Ary());
}
@Override protected Xomw_prepro_accum preprocessToObj_text(Xomw_prepro_accum element_obj, Xomw_prepro_piece piece, byte[] rule_end, int matching_count) {
Xomw_prepro_accum__hash element = (Xomw_prepro_accum__hash)element_obj;
// element = piece.breakSyntax(matchingCount);
addLiteral(element.Ary(), String_.new_u8(Bry_.Repeat_bry(rule_end, matching_count)));
return element;
}
@Override protected Xomw_prepro_accum preprocessToObj_xml(Xomw_prepro_piece piece, byte[] name_bry, int max_count, int matching_count) {
List_adp parts = piece.parts;
byte[] title = ((XomwPPDPart_DOM)parts.Get_at(0)).To_bry();
@Override protected Xomw_prepro_accum preprocessToObj_text(XomwPPDStackElement piece, byte[] rule_end, int matching_count) {
XophpArray array = (XophpArray)((XomwPPDStackElement)piece).breakSyntax(matching_count);
addLiteral(array, XophpString.str_repeat(String_.new_u8(rule_end), matching_count));
return new Xomw_prepro_accum__hash(array);
}
@Override protected Xomw_prepro_accum preprocessToObj_xml(XomwPPDStackElement piece, byte[] name_bry, int max_count, int matching_count) {
XophpArray parts = piece.parts;
Xomw_prepro_accum title = ((XomwPPDPart_Hash)parts.Get_at(0)).Accum();
parts.Del_at(0);
XophpArray children = XophpArray.New();
// The invocation is at the start of the line if lineStart is set in
// the stack, and all opening brackets are used up.
if (max_count == matching_count && piece.line_start) { // RELIC:!empty( $piece->lineStart )
if (max_count == matching_count && piece.lineStart) { // RELIC:!empty( $piece->lineStart )
children.Add(XophpArray.New("@lineStart", XophpArray.New(1)));
}
XophpArray titleNode = XophpArray.New("title", title);
children.Add(titleNode);
// int argIndex = 1;
int argIndex = 1;
int parts_len = parts.Len();
for (int j = 0; j < parts_len; j++) {
XomwPPDPart part = (XomwPPDPart)parts.Get_at(j);
XomwPPDPart_Hash part = (XomwPPDPart_Hash)parts.Get_at(j);
XophpArray part_out = (XophpArray)part.Accum_hash().Ary();
if (part.eqpos != -1) {
/*
Object equalsNode = part.Out()[part.eqpos];
XophpArray nameNode = XophpArray.New("name" , XophpArrayUtl.array_splice(part.Out(), 0, part.eqpos));
XophpArray valueNode = XophpArray.New("value", XophpArrayUtl.array_splice(part.Out(), part.eqpos + 1));
XophpArray partNode = XophpArray.New("part", XophpArray.New(nameNode, equalsNode, valueNode));
Object equalsNode = part_out.Get_at(part.eqpos);
XophpArray nameNode = XophpArray.New("name" , XophpArrayUtl.array_slice(part_out, 0, part.eqpos));
XophpArray valueNode = XophpArray.New("value", XophpArrayUtl.array_slice(part_out, part.eqpos + 1));
XophpArray partNode = XophpArray.New("part" , XophpArray.New(nameNode, equalsNode, valueNode));
children.Add(partNode);
*/
}
else {
/*
XophpArray nameNode = XophpArray.New("name" , XophpArray.New(XophpArray.New("@index", XophpArray.New(argIndex++))));
XophpArray valueNode = XophpArray.New("value", part.Out());
XophpArray partNode = XophpArray.New("part", XophpArray.New(nameNode, valueNode));
XophpArray valueNode = XophpArray.New("value", part_out);
XophpArray partNode = XophpArray.New("part" , XophpArray.New(nameNode, valueNode));
children.Add(partNode);
*/
}
}
// XophpArray element = XophpArray.New(XophpArray.New(name, children));
// return new Xomw_prepro_piece__hash(element);
return null;
XophpArray element = XophpArray.New(XophpArray.New(String_.new_u8(name_bry), children));
return new Xomw_prepro_accum__hash(element);
}
@Override protected void preprocessToObj_add_element(Xomw_prepro_accum element) {
XophpArrayUtl.array_splice(accum, accum.Len(), 0, ((Xomw_prepro_accum__hash)element).Ary());
}
@Override protected void preprocessToObj_equals(XomwPPDStackOld stack) {
@Override protected void preprocessToObj_equals(XomwPPDStack stack) {
accum.Add(XophpArray.New("equals", XophpArray.New("=")));
stack.Get_current_part().eqpos = accum.Len() - 1;
stack.getCurrentPart().eqpos = accum.Len() - 1;
}
@Override protected Object preprocessToObj_term(XomwPPDStackOld stack) {
Xomw_prepro_accum__hash stack_accum = (Xomw_prepro_accum__hash)stack.Get_accum();
@Override protected Object preprocessToObj_term(XomwPPDStack stack) {
Xomw_prepro_accum__hash stack_accum = (Xomw_prepro_accum__hash)stack.getAccum();
XophpArray stack_ary = stack_accum.Ary();
int len = stack_ary.Len();
for (int i = 0; i < len; i++) {
@ -186,14 +183,13 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
private static void addLiteral(XophpArray accum, byte[] text) {addLiteral(accum, String_.new_u8(text));}
private static void addLiteral(XophpArray accum, String text) {
int n = accum.Len();
if (n > 0) {
Object itm = accum.Get_at(n - 1);
if (itm != null) {
accum.Set(n - 1, ((String)itm) + text);
return;
}
Object itm = accum.Get_at(n - 1);
if (n > 0 && XophpTypeUtl.is_string(itm)) {
accum.Set(n - 1, ((String)itm) + text);
}
else {
accum.Add(text);
}
accum.Add(text);
}
@Override public XomwPreprocessor Make_new(XomwParser parser) {return new XomwPreprocessor_Hash();}

@ -220,7 +220,7 @@ public class XomwPreprocessor__tst {
}
}
class XomwPreprocessor__fxt {
private boolean dom_enabled = Bool_.Y, hash_enabled = Bool_.N;
private boolean dom_enabled = Bool_.Y, hash_enabled = Bool_.Y;
private boolean for_inclusion = false;
public XomwPreprocessor__fxt() {
}
@ -248,8 +248,8 @@ class XomwPreprocessor__fxt {
for (int i = 0; i < list.Len(); i++) {
XomwPreprocessor wkr = (XomwPreprocessor)list.Get_at(i);
byte[] src_bry = Bry_.new_u8(src_str);
byte[] actl = wkr.preprocessToDbg(src_bry, for_inclusion);
Tfds.Eq_str_lines(expd, String_.new_u8(actl), src_str);
String actl = wkr.preprocessToDbg(src_bry, for_inclusion);
Tfds.Eq_str_lines(expd, actl, src_str);
}
}
}

@ -18,15 +18,14 @@ package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; impor
/**
* @ingroup Parser
*/
// @codingStandardsIgnoreStart Squiz.Classes.ValidClassName.NotCamelCaps
public class XomwPPDPart_Hash extends XomwPPDPart { // @codingStandardsIgnoreEnd
private final Xomw_prepro_accum__hash accum = new Xomw_prepro_accum__hash();
public class XomwPPDPart_Hash extends XomwPPDPart { private final Xomw_prepro_accum__hash accum = new Xomw_prepro_accum__hash(XophpArray.New());
public XomwPPDPart_Hash(String output) {super(output);
if (output != String_.Empty) {
accum.Ary().Add(output);
}
}
@Override public Xomw_prepro_accum Accum() {return accum;}
public Xomw_prepro_accum__hash Accum_hash() {return (Xomw_prepro_accum__hash)accum;}
@Override public XomwPPDPart Make_new(String val) {
return new XomwPPDPart_Hash(val);
}

@ -59,13 +59,12 @@ public class XomwPPDStack {
}
public void push(XomwPPDStackElement data) {
if (Type_.Eq_by_obj(data, XomwPPDStackElement.class)) {
this.stack.Add(data);
}
else {
this.stack.Add(data);
// PHP.IGNORE:strong-typing
// else {
// $class = this.elementClass;
// this.stack[] = new $class($data);
}
// }
this.top = (XomwPPDStackElement)this.stack.Get_at(this.stack.Count() - 1);
this.accum = this.top.getAccum();
}
@ -101,4 +100,11 @@ public class XomwPPDStack {
return this.top.getFlags();
}
}
public void Clear() {
stack.Clear();
accum.Clear();
top = null;
}
public Xomw_prepro_accum Get_root_accum() {return this.rootAccum;}
}

@ -43,31 +43,38 @@ public class XomwPPDStackElement {
* @var boolean True if the open char appeared at the start of the input line.
* Not set for headings.
*/
// public boolean lineStart;
public boolean lineStart;
public String partClass = "PPDPart";
public XomwPPDStackElement(String open, String close, int count) {
public int start_pos;
private final XomwPPDPart part_factory;
public XomwPPDStackElement(XomwPPDPart part_factory, String open, String close, int count, int start_pos, boolean lineStart) {
this.parts = new XophpArray();
this.open = open;
this.close = close;
this.count = count;
this.part_factory = part_factory;
this.start_pos = start_pos;
this.lineStart = lineStart;
parts.Add(part_factory.Make_new(""));
}
public Xomw_prepro_accum getAccum() {
return (Xomw_prepro_accum)Get_at(this.parts.Count() - 1);
return (Xomw_prepro_accum)Get_at(this.parts.Count() - 1).Accum();
}
public void addPart(String s) {
this.parts.Add(Make_part(s));
}
@gplx.Virtual protected XomwPPDPart Make_part(String s) {
return new XomwPPDPart_DOM(s);
return part_factory.Make_new(s);
}
public XomwPPDPart getCurrentPart() {
return (XomwPPDPart)this.parts.Get_at(this.parts.Count() - 1);
return (XomwPPDPart)Get_at(this.parts.Count() - 1);
}
/**
@ -89,10 +96,11 @@ public class XomwPPDStackElement {
* @param boolean|int $openingCount
* @return String
*/
@gplx.Virtual public String breakSyntax(int openingCount) {
@gplx.Virtual public Object breakSyntax(int openingCount) {
Char_bfr bfr = new Char_bfr(16);
if (String_.Eq(this.open, "\n")) {
bfr.Add_bry(Get_at(0).To_bry());
XomwPPDPart_DOM part_0 = (XomwPPDPart_DOM)Get_at(0);
bfr.Add_bry(part_0.To_bry());
}
else {
if (openingCount == -1) {
@ -102,7 +110,7 @@ public class XomwPPDStackElement {
boolean first = true;
int parts_len = parts.Len();
for (int i = 0; i < parts_len; i++) {
XomwPPDPart_DOM part = Get_at(i);
XomwPPDPart_DOM part = (XomwPPDPart_DOM)Get_at(i);
if (first) {
first = false;
} else {
@ -113,63 +121,12 @@ public class XomwPPDStackElement {
}
return bfr.To_str_and_clear();
}
private XomwPPDPart_DOM Get_at(int i) {
return (XomwPPDPart_DOM)this.parts.Get_at(i);
}
}
// MW.FILE:Preprocessor_Hash
/**
* @ingroup Parser
*/
class XomwPPDStackElement_Hash extends XomwPPDStackElement { public XomwPPDStackElement_Hash(String open, String close, int count) {super(open, close, count);
}
private XomwPPDPart_Hash Get_at_hash(int i) {
return (XomwPPDPart_Hash)this.parts.Get_at(i);
public void Parts__renew() {
parts.Clear();
this.addPart("");
}
/**
* Get the accumulator that would result if the close is not found.
*
* @param int|boolean $openingCount
* @return array
*/
public XophpArray breakSyntax_Hash(int openingCount) {
XophpArray accum = null;
if (String_.Eq(this.open, "\n")) {
accum = (XophpArray)Get_at_hash(0).Accum();
}
else {
if (openingCount == -1) {
openingCount = this.count;
}
accum = XophpArray.New(XophpString.str_repeat(this.open, openingCount));
int lastIndex = 0;
boolean first = true;
int parts_len = parts.Len();
for (int i = 0; i < parts_len; i++) {
XomwPPDPart_Hash part = Get_at_hash(i);
if (first) {
first = false;
}
else if (XophpTypeUtl.is_string(accum.Get_at_str(lastIndex))) {
accum.Set(lastIndex, accum.Get_at_str(lastIndex) + "|");
} else {
accum.Set(++lastIndex, "|");
}
XophpArray part_out = ((Xomw_prepro_accum__hash)part.Accum()).Ary();
int part_out_len = part_out.Len();
for (int j = 0; j < part_out_len; j++) {
Object node = part_out.Get_at(j);
if (XophpTypeUtl.is_string(node) && XophpTypeUtl.is_string(accum.Get_at(lastIndex))) {
accum.Set(lastIndex, accum.Get_at_str(lastIndex) + (String)node);
} else {
accum.Set(++lastIndex, node);
}
}
}
}
return accum;
private XomwPPDPart Get_at(int i) {
return (XomwPPDPart)this.parts.Get_at(i);
}
}
///**

@ -20,9 +20,9 @@ public class XomwPPDStackElementFlags {
this.findEquals = findEquals;
this.inHeading = inHeading;
}
public boolean FindPipe() {return findPipe;} private final boolean findPipe;
public boolean FindEquals() {return findEquals;} private final boolean findEquals;
public boolean InHeading() {return inHeading;} private final boolean inHeading;
public final boolean findPipe;
public final boolean findEquals;
public final boolean inHeading;
public static final XomwPPDStackElementFlags Empty = new XomwPPDStackElementFlags(false, false, false);
}

@ -0,0 +1,71 @@
/*
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.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
// MW.FILE:Preprocessor_Hash
/**
* @ingroup Parser
*/
public class XomwPPDStackElement_Hash extends XomwPPDStackElement { public XomwPPDStackElement_Hash(XomwPPDPart part_factory, String open, String close, int count, int start_pos, boolean lineStart) {super(part_factory, open, close, count, start_pos, lineStart);
}
private XomwPPDPart_Hash Get_at_hash(int i) {
return (XomwPPDPart_Hash)this.parts.Get_at(i);
}
/**
* Get the accumulator that would result if the close is not found.
*
* @param int|boolean $openingCount
* @return array
*/
@Override public Object breakSyntax(int openingCount) {
XophpArray accum = null;
if (String_.Eq(this.open, "\n")) {
accum = (XophpArray)Get_at_hash(0).Accum();
}
else {
if (openingCount == -1) {
openingCount = this.count;
}
accum = XophpArray.New(XophpString.str_repeat(this.open, openingCount));
int lastIndex = 0;
boolean first = true;
int parts_len = parts.Len();
for (int i = 0; i < parts_len; i++) {
XomwPPDPart_Hash part = Get_at_hash(i);
if (first) {
first = false;
}
else if (XophpTypeUtl.is_string(accum.Get_at_str(lastIndex))) {
accum.Set(lastIndex, accum.Get_at_str(lastIndex) + "|");
} else {
accum.Set(++lastIndex, "|");
}
XophpArray part_out = ((Xomw_prepro_accum__hash)part.Accum()).Ary();
int part_out_len = part_out.Len();
for (int j = 0; j < part_out_len; j++) {
Object node = part_out.Get_at(j);
if (XophpTypeUtl.is_string(node) && XophpTypeUtl.is_string(accum.Get_at(lastIndex))) {
accum.Set(lastIndex, accum.Get_at_str(lastIndex) + (String)node);
} else {
accum.Set(++lastIndex, node);
}
}
}
}
return accum;
}
}

@ -1,95 +0,0 @@
/*
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.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
// MW.FILE:Preprocessor_DOM
/**
* Stack class to help Preprocessor::preprocessToObj()
* @ingroup Parser
*/
public class XomwPPDStackOld {
public final List_adp stack = List_adp_.New();
public Xomw_prepro_piece top;
private final Xomw_prepro_flags flags = new Xomw_prepro_flags();
protected Xomw_prepro_accum root_accum;
protected Xomw_prepro_accum accum;
public XomwPPDStackOld(Xomw_prepro_accum prototype) {
root_accum = prototype.Make_new();
accum = root_accum;
}
public void Clear() {
stack.Clear();
accum.Clear();
top = null;
}
public int Count() {return stack.Len();}
public Xomw_prepro_accum Get_accum() {return accum;}
public Xomw_prepro_accum Get_root_accum() {return root_accum;}
public XomwPPDPart Get_current_part() {
if (top == null) {
return null;
}
else {
return top.Get_current_part();
}
}
public void Push(Xomw_prepro_piece item) {
stack.Add(item);
this.top = (Xomw_prepro_piece)stack.Get_at(stack.Len() - 1);
accum = top.Get_accum();
}
public Xomw_prepro_piece Pop() {
int len = stack.Count();
if (len == 0) {
throw Err_.new_wo_type("XomwPPDStackOld: no elements remaining");
}
Xomw_prepro_piece rv = (Xomw_prepro_piece)stack.Get_at(len - 1);
stack.Del_at(len - 1);
len--;
if (len > 0) {
this.top = (Xomw_prepro_piece)stack.Get_at(stack.Len() - 1);
this.accum = top.Get_accum();
} else {
this.top = null;
this.accum = root_accum;
}
return rv;
}
public void Add_part(byte[] bry) {
top.Add_part(bry);
accum = top.Get_accum();
}
public Xomw_prepro_flags Get_flags() {
if (stack.Count() == 0) {
flags.findEquals = false;
flags.findPipe = false;
flags.inHeading = false;
return flags;
}
else {
top.Set_flags(flags);
return flags;
}
}
}

@ -1,21 +0,0 @@
/*
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.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
public class XomwPPDStackOld_Hash extends XomwPPDStackOld { public XomwPPDStackOld_Hash(Xomw_prepro_accum prototype) {super(prototype);
this.root_accum = prototype.Make_new();
this.accum = root_accum;
}
}

@ -30,12 +30,15 @@ public class XomwPPNode_Hash_Attr extends XomwPPNode { public String name, valu
* @param integer $index
*/
public XomwPPNode_Hash_Attr(XophpArray store, int index) {
// XophpArray descriptor = (XophpArray)store.Get_at_val(index);
// if (!String_.Eq(XophpArrayUtl.Get_nest_val(XomwPPNode_Hash_Tree.NAME, 0), '@')) {
// throw Err_.new_wo_type("XomwPPNode_Hash_Attr.CTOR: invalid name in attribute descriptor");
// }
// this.name = substr($descriptor[PPNode_Hash_Tree::NAME], 1);
// this.value = $descriptor[PPNode_Hash_Tree::CHILDREN][0];
XophpArray descriptor = (XophpArray)store.Get_at(index);
String descriptor_name = descriptor.Get_at_str(XomwPPNode_Hash_Tree.NAME);
if (!(String_.CharAt(descriptor_name, 0) == '@')) {
throw Err_.new_wo_type("XomwPPNode_Hash_Attr.CTOR: invalid name in attribute descriptor");
}
this.name = String_.new_u8(XophpString.substr(Bry_.new_u8(descriptor_name), 1));
XophpArray descriptor_children = (XophpArray)descriptor.Get_at(XomwPPNode_Hash_Tree.CHILDREN);
Object value_obj = descriptor_children.Get_at(0);
this.value = Type_.Eq_by_obj(value_obj, byte[].class) ? String_.new_u8((byte[])value_obj): value_obj.toString();
this.store = store;
this.index = index;
}

@ -41,13 +41,13 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
* The offset of the name within descriptors, used in some places for
* readability.
*/
private static final int NAME = 0;
public static final int NAME = 0;
/**
* The offset of the child list within descriptors, used in some places for
* readability.
*/
// private static final int CHILDREN = 1;
public static final int CHILDREN = 1;
/**
* Construct an Object using the data from $store[$index]. The rest of the
@ -62,7 +62,13 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
XophpArray list = this.store.Get_at_ary(index);
this.name = list.Get_at_str(0);
this.rawChildren = ((Xomw_prepro_accum__hash)(list.Get_at(1))).Ary();
Object rawChildrenObj = list.Get_at(1);
if (XophpTypeUtl.To_type_id(rawChildrenObj) == Type_ids_.Id__array) {
this.rawChildren = (XophpArray)rawChildrenObj;
}
else {
this.rawChildren = ((Xomw_prepro_accum__hash)rawChildrenObj).Ary();
}
}
/**
@ -85,12 +91,12 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
}
else if (type.is_array()) {
XophpArray descriptor_array = (XophpArray)descriptor;
XophpArray name_array = (XophpArray)(descriptor_array.Get_by(NAME));
if (String_.Has_at_bgn(name_array.Get_at_str(0), "@")) {
String name = (String)(descriptor_array.Get_by(NAME));
if (String_.CharAt(name, 0) == '@') {
return new XomwPPNode_Hash_Attr(store, index);
}
else {
return new XomwPPNode_Hash_Text(store, index);
return new XomwPPNode_Hash_Tree(store, index);
}
}
else {
@ -107,15 +113,20 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
for (XomwPPNode node = this.getFirstChild(); node != null; node = node.getNextSibling()) {
if (Type_.Eq_by_obj(node, XomwPPNode_Hash_Attr.class)) {
XomwPPNode_Hash_Attr node_attr = (XomwPPNode_Hash_Attr)node;
attribs += " " + node_attr.name + "=\"" + Bry_.Escape_html(Bry_.new_u8(node_attr.value)) + "\"";
attribs += " " + node_attr.name + "=\"" + String_.new_u8(Bry_.Escape_html(Bry_.new_u8(node_attr.value))) + "\"";
} else {
inner += node.toString();
}
}
if (String_.Eq(inner, "")) {
return "<" + this.name + attribs + "/>";
if (String_.Eq(inner, "") && String_.Eq(name, "name")) {
return "<" + this.name + attribs + " />";
} else {
return "<" + this.name + attribs + ">" + inner + "</" + this.name + ">";
if (String_.Eq(name, "equals")) {
return inner;
}
else {
return "<" + this.name + attribs + ">" + inner + "</" + this.name + ">";
}
}
}

@ -14,12 +14,14 @@ 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.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; import gplx.xowa.mediawiki.includes.parsers.*;
public class Xomw_prepro_accum__hash implements Xomw_prepro_accum {
public Xomw_prepro_accum__hash() {
public class Xomw_prepro_accum__hash implements Xomw_prepro_accum {
private final XophpArray ary;
public Xomw_prepro_accum__hash(XophpArray ary) {
this.ary = ary;
}
public XophpArray Ary() {return ary;} private final XophpArray ary = new XophpArray();
public XophpArray Ary() {return ary;}
public void Clear() {ary.Clear();}
public static final Xomw_prepro_accum__hash Instance = new Xomw_prepro_accum__hash();
public Xomw_prepro_accum Make_new() {return new Xomw_prepro_accum__hash();}
public static final Xomw_prepro_accum__hash Instance = new Xomw_prepro_accum__hash(null);
public Xomw_prepro_accum Make_new() {return new Xomw_prepro_accum__hash(XophpArray.New());}
}

Loading…
Cancel
Save