mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Xomw.Preprocessor: Add XomwPPDStackElement [#508]
This commit is contained in:
parent
436f219477
commit
dea0556df5
@ -19,6 +19,7 @@ public class XophpArray implements Bry_bfr_able {
|
|||||||
private final Ordered_hash hash = Ordered_hash_.New();
|
private final Ordered_hash hash = Ordered_hash_.New();
|
||||||
private int nxt_idx;
|
private int nxt_idx;
|
||||||
public int Len() {return hash.Len();}
|
public int Len() {return hash.Len();}
|
||||||
|
public int Count() {return hash.Len();}
|
||||||
public void Clear() {
|
public void Clear() {
|
||||||
hash.Clear();
|
hash.Clear();
|
||||||
nxt_idx = 0;
|
nxt_idx = 0;
|
||||||
|
@ -17,6 +17,13 @@ package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
|
|||||||
public class XophpArrayUtl {
|
public class XophpArrayUtl {
|
||||||
public static boolean popBoolOrN(List_adp list) {return Bool_.Cast(List_adp_.Pop_or(list, false));}
|
public static boolean popBoolOrN(List_adp list) {return Bool_.Cast(List_adp_.Pop_or(list, false));}
|
||||||
public static byte[] popBryOrNull(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);}
|
public static byte[] popBryOrNull(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);}
|
||||||
|
public static Object pop_obj(XophpArray array) {
|
||||||
|
int array_count = array.Count();
|
||||||
|
if (array_count == 0) return null;
|
||||||
|
Object rv = array.Get_at(array_count - 1);
|
||||||
|
array.Del_at(array_count - 1);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
public static boolean isset(XophpArray ary, int idx) {
|
public static boolean isset(XophpArray ary, int idx) {
|
||||||
return ary.Get_at(idx) == null;
|
return ary.Get_at(idx) == null;
|
||||||
}
|
}
|
||||||
|
@ -158,4 +158,14 @@ public class XophpString {
|
|||||||
return pos == Bry_find_.Not_found ? null : Bry_.Mid(src, pos, src.length);
|
return pos == Bry_find_.Not_found ? null : Bry_.Mid(src, pos, src.length);
|
||||||
}
|
}
|
||||||
public static int strlen(byte[] src) {return src.length;}
|
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];
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
for (int j = 0; i < val_len; j++) {
|
||||||
|
chry[(i * val_len) + j] = String_.CharAt(val, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String_.new_charAry_(chry, 0, val_len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,4 +29,6 @@ public class XophpTypeUtl {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean is_string(Object obj) {return Type_.Eq_by_obj(obj, String.class);}
|
||||||
}
|
}
|
||||||
|
@ -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; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
|
|
||||||
public class XomwExceptionUtl {
|
|
||||||
public static Err New_by_method(Class<?> type, String method, String msg) {
|
|
||||||
return Err_.new_wo_type(Type_.Name(type) + "." + method + ":" + msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,4 +17,7 @@ package gplx.xowa.mediawiki.includes.exception; import gplx.*; import gplx.xowa.
|
|||||||
public class XomwMWException extends Err {
|
public class XomwMWException extends Err {
|
||||||
public XomwMWException(String msg) {super(true, "", "", msg);
|
public XomwMWException(String msg) {super(true, "", "", msg);
|
||||||
}
|
}
|
||||||
|
public static Err New_by_method(Class<?> type, String method, String msg) {
|
||||||
|
return Err_.new_wo_type(Type_.Name(type) + "." + method + ":" + msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 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 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 Hash_adp_bry no_more_closing_tag = Hash_adp_bry.cs();
|
||||||
private final XomwPPDStack stack;
|
private final XomwPPDStackOld stack;
|
||||||
private final Btrie_rv trv = new Btrie_rv();
|
private final Btrie_rv trv = new Btrie_rv();
|
||||||
private Xomw_prepro_accum accum = null;
|
private Xomw_prepro_accum accum = null;
|
||||||
|
|
||||||
@ -864,7 +864,7 @@ public abstract class XomwPreprocessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract XomwPPDPart Factory__part();
|
protected abstract XomwPPDPart Factory__part();
|
||||||
protected abstract XomwPPDStack Factory__stack();
|
protected abstract XomwPPDStackOld Factory__stack();
|
||||||
|
|
||||||
protected abstract Xomw_prepro_accum Accum__set(Xomw_prepro_accum accum);
|
protected abstract Xomw_prepro_accum Accum__set(Xomw_prepro_accum accum);
|
||||||
|
|
||||||
@ -883,7 +883,7 @@ public abstract class XomwPreprocessor {
|
|||||||
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_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_xml(Xomw_prepro_piece piece, byte[] name_bry, int max_count, int matching_count);
|
||||||
protected abstract void preprocessToObj_add_element(Xomw_prepro_accum element);
|
protected abstract void preprocessToObj_add_element(Xomw_prepro_accum element);
|
||||||
protected abstract void preprocessToObj_equals(XomwPPDStack stack);
|
protected abstract void preprocessToObj_equals(XomwPPDStackOld stack);
|
||||||
protected abstract Object preprocessToObj_term(XomwPPDStack stack);
|
protected abstract Object preprocessToObj_term(XomwPPDStackOld stack);
|
||||||
public abstract XomwPreprocessor Make_new(XomwParser parser);
|
public abstract XomwPreprocessor Make_new(XomwParser parser);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import gplx.xowa.mediawiki.includes.parsers.preprocessors.*;
|
|||||||
class XomwPreprocessor_DOM extends XomwPreprocessor { private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
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("");
|
private Xomw_prepro_accum__dom accum_dom = new Xomw_prepro_accum__dom("");
|
||||||
|
|
||||||
@Override protected XomwPPDStack Factory__stack() {return new XomwPPDStack(Xomw_prepro_accum__dom.Instance);}
|
@Override protected XomwPPDStackOld Factory__stack() {return new XomwPPDStackOld(Xomw_prepro_accum__dom.Instance);}
|
||||||
@Override protected XomwPPDPart Factory__part() {return new XomwPPDPart_DOM("");}
|
@Override protected XomwPPDPart Factory__part() {return new XomwPPDPart_DOM("");}
|
||||||
|
|
||||||
@Override public XomwPPFrame newFrame() {
|
@Override public XomwPPFrame newFrame() {
|
||||||
@ -138,11 +138,11 @@ class XomwPreprocessor_DOM extends XomwPreprocessor { private final Bry_bfr
|
|||||||
@Override protected void preprocessToObj_add_element(Xomw_prepro_accum element) {
|
@Override protected void preprocessToObj_add_element(Xomw_prepro_accum element) {
|
||||||
accum_dom.Add_bry(((Xomw_prepro_accum__dom)element).To_bry());
|
accum_dom.Add_bry(((Xomw_prepro_accum__dom)element).To_bry());
|
||||||
}
|
}
|
||||||
@Override protected void preprocessToObj_equals(XomwPPDStack stack) {
|
@Override protected void preprocessToObj_equals(XomwPPDStackOld stack) {
|
||||||
stack.Get_current_part().eqpos = accum_dom.Len();
|
stack.Get_current_part().eqpos = accum_dom.Len();
|
||||||
accum_dom.Add_bry(Byte_ascii.Eq_bry);
|
accum_dom.Add_bry(Byte_ascii.Eq_bry);
|
||||||
}
|
}
|
||||||
@Override protected Object preprocessToObj_term(XomwPPDStack stack) {
|
@Override protected Object preprocessToObj_term(XomwPPDStackOld stack) {
|
||||||
Bry_bfr root_accum = Bry_bfr_.New().Add_str_u8(((Xomw_prepro_accum__dom)stack.Get_root_accum()).To_str());
|
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();
|
int stack_len = stack.stack.Len();
|
||||||
for (int j = 0; j < stack_len; j++) {
|
for (int j = 0; j < stack_len; j++) {
|
||||||
|
@ -25,7 +25,7 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected XomwPPDStack Factory__stack() {return new XomwPPDStack_Hash(Xomw_prepro_accum__hash.Instance);}
|
@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 XomwPPDPart Factory__part() {return new XomwPPDPart_Hash("");}
|
||||||
@Override protected Xomw_prepro_accum Accum__set(Xomw_prepro_accum accum_obj) {
|
@Override protected Xomw_prepro_accum Accum__set(Xomw_prepro_accum accum_obj) {
|
||||||
this.accum = ((Xomw_prepro_accum__hash)accum_obj).Ary();
|
this.accum = ((Xomw_prepro_accum__hash)accum_obj).Ary();
|
||||||
@ -147,11 +147,11 @@ class XomwPreprocessor_Hash extends XomwPreprocessor { private XophpArray accum
|
|||||||
@Override protected void preprocessToObj_add_element(Xomw_prepro_accum element) {
|
@Override protected void preprocessToObj_add_element(Xomw_prepro_accum element) {
|
||||||
XophpArrayUtl.array_splice(accum, accum.Len(), 0, ((Xomw_prepro_accum__hash)element).Ary());
|
XophpArrayUtl.array_splice(accum, accum.Len(), 0, ((Xomw_prepro_accum__hash)element).Ary());
|
||||||
}
|
}
|
||||||
@Override protected void preprocessToObj_equals(XomwPPDStack stack) {
|
@Override protected void preprocessToObj_equals(XomwPPDStackOld stack) {
|
||||||
accum.Add(XophpArray.New("equals", XophpArray.New("=")));
|
accum.Add(XophpArray.New("equals", XophpArray.New("=")));
|
||||||
stack.Get_current_part().eqpos = accum.Len() - 1;
|
stack.Get_current_part().eqpos = accum.Len() - 1;
|
||||||
}
|
}
|
||||||
@Override protected Object preprocessToObj_term(XomwPPDStack stack) {
|
@Override protected Object preprocessToObj_term(XomwPPDStackOld stack) {
|
||||||
Xomw_prepro_accum__hash stack_accum = (Xomw_prepro_accum__hash)stack.Get_accum();
|
Xomw_prepro_accum__hash stack_accum = (Xomw_prepro_accum__hash)stack.Get_accum();
|
||||||
XophpArray stack_ary = stack_accum.Ary();
|
XophpArray stack_ary = stack_accum.Ary();
|
||||||
int len = stack_ary.Len();
|
int len = stack_ary.Len();
|
||||||
|
@ -19,7 +19,6 @@ public class XomwPreprocessor__tst {
|
|||||||
private final XomwPreprocessor__fxt fxt = new XomwPreprocessor__fxt();
|
private final XomwPreprocessor__fxt fxt = new XomwPreprocessor__fxt();
|
||||||
@Before public void init() {fxt.Clear();}
|
@Before public void init() {fxt.Clear();}
|
||||||
@Test public void Text() {
|
@Test public void Text() {
|
||||||
fxt.Init__hash_y();
|
|
||||||
fxt.Test__parse("abc", "<root>abc</root>");
|
fxt.Test__parse("abc", "<root>abc</root>");
|
||||||
}
|
}
|
||||||
@Test public void Brack() {
|
@Test public void Brack() {
|
||||||
|
@ -22,7 +22,7 @@ public abstract class XomwPPDPart {
|
|||||||
/**
|
/**
|
||||||
* @var String Output accumulator String
|
* @var String Output accumulator String
|
||||||
*/
|
*/
|
||||||
// private final byte[] output;
|
// public final byte[] output;
|
||||||
|
|
||||||
// Optional member variables:
|
// Optional member variables:
|
||||||
// eqpos Position of equals sign in output accumulator
|
// eqpos Position of equals sign in output accumulator
|
||||||
@ -36,13 +36,22 @@ public abstract class XomwPPDPart {
|
|||||||
// accum.Add_bry(Bry_.new_u8(output));
|
// accum.Add_bry(Bry_.new_u8(output));
|
||||||
// bfr = ((Xomw_prepro_accum__dom)accum).Bfr();
|
// bfr = ((Xomw_prepro_accum__dom)accum).Bfr();
|
||||||
}
|
}
|
||||||
// private final Xomw_prepro_accum__dom accum = new Xomw_prepro_accum__dom("");
|
|
||||||
// private final Bry_bfr bfr;
|
|
||||||
public abstract Xomw_prepro_accum Accum();
|
public abstract Xomw_prepro_accum Accum();
|
||||||
//
|
|
||||||
// public Bry_bfr Bfr() {return bfr;}
|
|
||||||
// public int Len() {return bfr.Len();}
|
|
||||||
// public byte[] To_bry() {return bfr.To_bry();}
|
|
||||||
|
|
||||||
public abstract XomwPPDPart Make_new(String val);
|
public abstract XomwPPDPart Make_new(String val);
|
||||||
}
|
}
|
||||||
|
// class XomwPPDPart {
|
||||||
|
// /**
|
||||||
|
// * @var String Output accumulator String
|
||||||
|
// */
|
||||||
|
// public String output;
|
||||||
|
//
|
||||||
|
// // Optional member variables:
|
||||||
|
// // eqpos Position of equals sign in output accumulator
|
||||||
|
// // commentEnd Past-the-end input pointer for the last comment encountered
|
||||||
|
// // visualEnd Past-the-end input pointer for the end of the accumulator minus comments
|
||||||
|
//
|
||||||
|
// public XomwPPDPart(String output) {
|
||||||
|
// this.output = output;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
@ -15,8 +15,7 @@ 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.*;
|
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:NONE
|
// MW.FILE:NONE
|
||||||
public class XomwPPDPart_DOM extends XomwPPDPart { // @codingStandardsIgnoreEnd
|
public class XomwPPDPart_DOM extends XomwPPDPart { private final Bry_bfr bfr;
|
||||||
private final Bry_bfr bfr;
|
|
||||||
private final Xomw_prepro_accum__dom accum = new Xomw_prepro_accum__dom("");
|
private final Xomw_prepro_accum__dom accum = new Xomw_prepro_accum__dom("");
|
||||||
public XomwPPDPart_DOM(String output) {super(output);
|
public XomwPPDPart_DOM(String output) {super(output);
|
||||||
bfr = accum.Bfr();
|
bfr = accum.Bfr();
|
||||||
@ -28,6 +27,7 @@ public class XomwPPDPart_DOM extends XomwPPDPart { // @codingStandardsIgnoreEnd
|
|||||||
public Bry_bfr Bfr() {return bfr;}
|
public Bry_bfr Bfr() {return bfr;}
|
||||||
public int Len() {return bfr.Len();}
|
public int Len() {return bfr.Len();}
|
||||||
public byte[] To_bry() {return bfr.To_bry();}
|
public byte[] To_bry() {return bfr.To_bry();}
|
||||||
|
public String To_str() {return bfr.To_str();}
|
||||||
|
|
||||||
@Override public XomwPPDPart Make_new(String val) {
|
@Override public XomwPPDPart Make_new(String val) {
|
||||||
return new XomwPPDPart_DOM(val);
|
return new XomwPPDPart_DOM(val);
|
||||||
|
@ -14,82 +14,91 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
|||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.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.*;
|
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
|
import gplx.xowa.mediawiki.includes.exception.*;
|
||||||
|
// MW.FILE:Preprocessor
|
||||||
/**
|
/**
|
||||||
* Stack class to help Preprocessor::preprocessToObj()
|
* Stack clazz to help Preprocessor::preprocessToObj()
|
||||||
* @ingroup Parser
|
* @ingroup Parser
|
||||||
*/
|
*/
|
||||||
public class XomwPPDStack {
|
public class XomwPPDStack {
|
||||||
public final List_adp stack = List_adp_.New();
|
public XophpArray stack;
|
||||||
public Xomw_prepro_piece top;
|
public Xomw_prepro_accum rootAccum;
|
||||||
private final Xomw_prepro_flags flags = new Xomw_prepro_flags();
|
|
||||||
protected Xomw_prepro_accum root_accum;
|
|
||||||
protected Xomw_prepro_accum accum;
|
protected Xomw_prepro_accum accum;
|
||||||
|
|
||||||
public XomwPPDStack(Xomw_prepro_accum prototype) {
|
/**
|
||||||
root_accum = prototype.Make_new();
|
* @var PPDStack
|
||||||
accum = root_accum;
|
*/
|
||||||
}
|
public XomwPPDStackElement top;
|
||||||
public void Clear() {
|
// public $out;
|
||||||
stack.Clear();
|
// public $elementClass = 'PPDStackElement';
|
||||||
accum.Clear();
|
|
||||||
top = null;
|
|
||||||
}
|
|
||||||
public int Count() {return stack.Len();}
|
|
||||||
|
|
||||||
public Xomw_prepro_accum Get_accum() {return accum;}
|
public XomwPPDStack (Xomw_prepro_accum prototype) {
|
||||||
public Xomw_prepro_accum Get_root_accum() {return root_accum;}
|
this.stack = XophpArray.New();
|
||||||
|
this.top = null;
|
||||||
|
this.rootAccum = prototype.Make_new();
|
||||||
|
this.accum = rootAccum;
|
||||||
|
}
|
||||||
|
|
||||||
public XomwPPDPart Get_current_part() {
|
/**
|
||||||
if (top == null) {
|
* @return int
|
||||||
|
*/
|
||||||
|
public int count() {
|
||||||
|
return this.stack.Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Xomw_prepro_accum getAccum() {
|
||||||
|
return this.accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public XomwPPDPart getCurrentPart() {
|
||||||
|
if (this.top == null) {
|
||||||
return null;
|
return null;
|
||||||
|
} else {
|
||||||
|
return this.top.getCurrentPart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void push(XomwPPDStackElement data) {
|
||||||
|
if (Type_.Eq_by_obj(data, XomwPPDStackElement.class)) {
|
||||||
|
this.stack.Add(data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return top.Get_current_part();
|
// $class = this.elementClass;
|
||||||
|
// this.stack[] = new $class($data);
|
||||||
}
|
}
|
||||||
|
this.top = (XomwPPDStackElement)this.stack.Get_at(this.stack.Count() - 1);
|
||||||
|
this.accum = this.top.getAccum();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Push(Xomw_prepro_piece item) {
|
public XomwPPDStackElement pop() {
|
||||||
stack.Add(item);
|
if (this.stack.Count() == 0) {
|
||||||
this.top = (Xomw_prepro_piece)stack.Get_at(stack.Len() - 1);
|
throw XomwMWException.New_by_method(XomwPPDStack.class, "pop", "no elements remaining");
|
||||||
accum = top.Get_accum();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Xomw_prepro_piece Pop() {
|
|
||||||
int len = stack.Count();
|
|
||||||
if (len == 0) {
|
|
||||||
throw Err_.new_wo_type("XomwPPDStack: no elements remaining");
|
|
||||||
}
|
}
|
||||||
|
XomwPPDStackElement temp = (XomwPPDStackElement)XophpArrayUtl.pop_obj(this.stack);
|
||||||
Xomw_prepro_piece rv = (Xomw_prepro_piece)stack.Get_at(len - 1);
|
if (this.stack.Count()> 0) {
|
||||||
stack.Del_at(len - 1);
|
this.top = (XomwPPDStackElement)this.stack.Get_at(this.stack.Count() - 1);
|
||||||
len--;
|
this.accum = this.top.getAccum();
|
||||||
|
|
||||||
if (len > 0) {
|
|
||||||
this.top = (Xomw_prepro_piece)stack.Get_at(stack.Len() - 1);
|
|
||||||
this.accum = top.Get_accum();
|
|
||||||
} else {
|
} else {
|
||||||
this.top = null;
|
this.top = null;
|
||||||
this.accum = root_accum;
|
this.accum = this.rootAccum;
|
||||||
}
|
}
|
||||||
return rv;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add_part(byte[] bry) {
|
public void addPart(String s) {
|
||||||
top.Add_part(bry);
|
this.top.addPart(s);
|
||||||
accum = top.Get_accum();
|
this.accum = this.top.getAccum();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xomw_prepro_flags Get_flags() {
|
/**
|
||||||
if (stack.Count() == 0) {
|
* @return array
|
||||||
flags.findEquals = false;
|
*/
|
||||||
flags.findPipe = false;
|
public XomwPPDStackElementFlags getFlags() {
|
||||||
flags.inHeading = false;
|
if (this.stack.Count() == 0) {
|
||||||
return flags;
|
return XomwPPDStackElementFlags.Empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
top.Set_flags(flags);
|
return this.top.getFlags();
|
||||||
return flags;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
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 XomwPPDStackElementFlags {
|
||||||
|
public XomwPPDStackElementFlags(boolean findPipe, boolean findEquals, boolean inHeading) {
|
||||||
|
this.findPipe = findPipe;
|
||||||
|
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 static final XomwPPDStackElementFlags Empty = new XomwPPDStackElementFlags(false, false, false);
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
|||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.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.*;
|
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 XomwPPDStack_Hash extends XomwPPDStack { public XomwPPDStack_Hash(Xomw_prepro_accum prototype) {super(prototype);
|
public class XomwPPDStackOld_Hash extends XomwPPDStackOld { public XomwPPDStackOld_Hash(Xomw_prepro_accum prototype) {super(prototype);
|
||||||
this.root_accum = prototype.Make_new();
|
this.root_accum = prototype.Make_new();
|
||||||
this.accum = root_accum;
|
this.accum = root_accum;
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; impor
|
|||||||
/**
|
/**
|
||||||
* @ingroup Parser
|
* @ingroup Parser
|
||||||
*/
|
*/
|
||||||
|
import gplx.xowa.mediawiki.includes.exception.*;
|
||||||
public class XomwPPNode_Hash_Text extends XomwPPNode { public String value;
|
public class XomwPPNode_Hash_Text extends XomwPPNode { public String value;
|
||||||
private final XophpArray store;
|
private final XophpArray store;
|
||||||
private final int index;
|
private final int index;
|
||||||
@ -32,7 +33,7 @@ public class XomwPPNode_Hash_Text extends XomwPPNode { public String value;
|
|||||||
public XomwPPNode_Hash_Text(XophpArray store, int index) {
|
public XomwPPNode_Hash_Text(XophpArray store, int index) {
|
||||||
Object value_obj = store.Get_at(index);
|
Object value_obj = store.Get_at(index);
|
||||||
if (!XophpTypeUtl.is_scalar(value_obj)) {
|
if (!XophpTypeUtl.is_scalar(value_obj)) {
|
||||||
throw XomwExceptionUtl.New_by_method(XomwPPNode_Hash_Text.class, "CTOR", "given Object instead of String");
|
throw XomwMWException.New_by_method(XomwPPNode_Hash_Text.class, "CTOR", "given Object instead of String");
|
||||||
}
|
}
|
||||||
this.value = Object_.Xto_str_strict_or_null(value_obj);
|
this.value = Object_.Xto_str_strict_or_null(value_obj);
|
||||||
this.store = store;
|
this.store = store;
|
||||||
|
@ -18,6 +18,7 @@ package gplx.xowa.mediawiki.includes.parsers.preprocessors; import gplx.*; impor
|
|||||||
/**
|
/**
|
||||||
* @ingroup Parser
|
* @ingroup Parser
|
||||||
*/
|
*/
|
||||||
|
import gplx.xowa.mediawiki.includes.exception.*;
|
||||||
public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String name;
|
public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String name;
|
||||||
/**
|
/**
|
||||||
* The store array for children of this node. It is "raw" in the sense that
|
* The store array for children of this node. It is "raw" in the sense that
|
||||||
@ -93,7 +94,7 @@ public class XomwPPNode_Hash_Tree extends XomwPPNode { public final String na
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw XomwExceptionUtl.New_by_method(XomwPPNode_Hash_Tree.class, "factory", "invalid node descriptor");
|
throw XomwMWException.New_by_method(XomwPPNode_Hash_Tree.class, "factory", "invalid node descriptor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user