diff --git a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/XomwPreprocessor_DOM.java b/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/XomwPreprocessor_DOM.java index c83d8701f..dcdf84299 100644 --- a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/XomwPreprocessor_DOM.java +++ b/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/XomwPreprocessor_DOM.java @@ -144,8 +144,9 @@ class XomwPreprocessor_DOM extends XomwPreprocessor { private final Bry_bfr 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++) { - Xomw_prepro_piece piece = (Xomw_prepro_piece)stack.stack.Get_at(j); - root_accum.Add(piece.Break_syntax(tmp_bfr, -1)); + // XomwPPDStackElement_Hash piece = (XomwPPDStackElement_Hash)stack.stack.Get_at(j); + // root_accum.Add((XophpArray)piece.breakSyntax(tmp_bfr)); + // root_accum.Add((XophpArray)piece.breakSyntax(tmp_bfr, -1)); } root_accum.Add_str_a7(""); return root_accum.To_bry_and_clear(); diff --git a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_frame_itm.java b/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_frame_itm.java deleted file mode 100644 index 11958d910..000000000 --- a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_frame_itm.java +++ /dev/null @@ -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 Xomw_frame_itm { - public byte[] Expand(byte[] ttl) { - return null; - } -} diff --git a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_frame_wkr.java b/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_frame_wkr.java deleted file mode 100644 index 907c52f00..000000000 --- a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_frame_wkr.java +++ /dev/null @@ -1,562 +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 Xomw_frame_wkr { // THREAD.UNSAFE: caching for repeated calls -// private final Xomw_parser parser; -// public Xomw_frame_wkr(Xomw_parser parser) { -// this.parser = parser; -// } -// \\ Replace magic variables, templates, and template arguments -// \\ with the appropriate text. Templates are substituted recursively, -// \\ taking care to avoid infinite loops. -// \\ -// \\ Note that the substitution depends on value of $mOutputType: -// \\ self::OT_WIKI: only {{subst:}} templates -// \\ self::OT_PREPROCESS: templates but not extension tags -// \\ self::OT_HTML: all templates and extension tags -// \\ -// \\ @param String $text The text to transform -// \\ @param boolean|PPFrame $frame Object describing the arguments passed to the -// \\ template. Arguments may also be provided as an associative array, as -// \\ was the usual case before MW1.12. Providing arguments this way may be -// \\ useful for extensions wishing to perform variable replacement -// \\ explicitly. -// \\ @param boolean $argsOnly Only do argument (triple-brace) expansion, not -// \\ double-brace expansion. -// \\ @return String -// public function replaceVariables($text, $frame = false, $argsOnly = false) { -// // Is there any text? Also, Prevent too big inclusions! -// $textSize = strlen($text); -// if ($textSize < 1 || $textSize > $this->mOptions->getMaxIncludeSize()) { -// return $text; -// } -// -// if ($frame == false) { -// $frame = $this->getPreprocessor()->newFrame(); -// } elseif (!($frame instanceof PPFrame)) { -// wfDebug(__METHOD__ . " called using plain parameters instead of " -// . "a PPFrame instance. Creating custom frame.\n"); -// $frame = $this->getPreprocessor()->newCustomFrame($frame); -// } -// -// $dom = $this->preprocessToDom($text); -// $flags = $argsOnly ? PPFrame::NO_TEMPLATES : 0; -// $text = $frame->expand($dom, $flags); -// -// return $text; -// } -// -// \\ Clean up argument array - refactored in 1.9 so parserfunctions can use it, too. -// public static function createAssocArgs($args) { -// $assocArgs = []; -// $index = 1; -// foreach ($args as $arg) { -// $eqpos = strpos($arg, '='); -// if ($eqpos == false) { -// $assocArgs[$index++] = $arg; -// } else { -// $name = trim(substr($arg, 0, $eqpos)); -// $value = trim(substr($arg, $eqpos + 1)); -// if ($value == false) { -// $value = ''; -// } -// if ($name != false) { -// $assocArgs[$name] = $value; -// } -// } -// } -// -// return $assocArgs; -// } - -// \\ Return the text of a template, after recursively -// \\ replacing any variables or templates within the template. -// \\ -// \\ @param array $piece The parts of the template -// \\ $piece['title']: the title, i.e. the part before the | -// \\ $piece['parts']: the parameter array -// \\ $piece['lineStart']: whether the brace was at the start of a line -// \\ @param PPFrame $frame The current frame, contains template arguments -// \\ @throws Exception -// \\ @return String The text of the template -// public void Brace_substitution(Xomw_prepro_node__template piece, Xomw_frame_itm frame) { -// // Flags -// -// // $text has been filled -// boolean found = false; -// // wiki markup in $text should be escaped -// boolean nowiki = false; -// // $text is HTML, armour it against wikitext transformation -// boolean is_html = false; -// // Force interwiki transclusion to be done in raw mode not rendered -// boolean force_raw_interwiki = false; -// // $text is a DOM node needing expansion in a child frame -// boolean is_child_obj = false; -// // $text is a DOM node needing expansion in the current frame -// boolean is_local_obj = false; -// -// // Title Object, where $text came from -// byte[] title = null; -// -// // $part1 is the bit before the first |, and must contain only title characters. -// // Various prefixes will be stripped from it later. -// byte[] title_with_spaces = frame.Expand(piece.Title()); -// byte[] part1 = Bry_.Trim(title_with_spaces); -// byte[] title_text = null; -// -// // Original title text preserved for various purposes -// byte[] originalTitle = part1; -// -// // $args is a list of argument nodes, starting from index 0, not including $part1 -// // @todo FIXME: If piece['parts'] is null then the call to getLength() -// // below won't work b/c this $args isn't an Object -// Xomw_prepro_node__part[] args = (null == piece.Parts()) ? null : piece.Parts(); -// -// byte[] profile_section = null; // profile templates -// -// Tfds.Write(nowiki, is_html, force_raw_interwiki, is_child_obj, is_local_obj, title, title_text, profile_section); -// // SUBST -// if (!found) { -// String subst_match = null; // $this->mSubstWords->matchStartAndRemove($part1); -// boolean literal = false; -// -// // Possibilities for substMatch: "subst", "safesubst" or FALSE -// // Decide whether to expand template or keep wikitext as-is. -// if (parser.Output_type__wiki()) { -// if (subst_match == null) { -// literal = true; // literal when in PST with no prefix -// } -// else { -// literal = false; // expand when in PST with subst: or safesubst: -// } -// } -// else { -// if (subst_match == "subst") { -// literal = true; // literal when not in PST with plain subst: -// } -// else { -// literal = false; // expand when not in PST with safesubst: or no prefix -// } -// } -// if (literal) { -//// $text = $frame->virtualBracketedImplode('{{', '|', '}}', title_with_spaces, $args); -// is_local_obj = true; -// found = true; -// } -// } -// -// // Variables -// if (!found && args.length == 0) { -//// $id = $this->mVariables->matchStartToEnd($part1); -//// if ($id != false) { -//// $text = $this->getVariableValue($id, $frame); -//// if (MagicWord::getCacheTTL($id) > -1) { -//// $this->mOutput->updateCacheExpiry(MagicWord::getCacheTTL($id)); -//// } -// found = true; -//// } -// } -// -// // MSG, MSGNW and RAW -// if (!found) { -// // Check for MSGNW: -//// $mwMsgnw = MagicWord::get('msgnw'); -//// if ($mwMsgnw->matchStartAndRemove($part1)) { -// nowiki = true; -//// } -//// else { -// // Remove obsolete MSG: -//// $mwMsg = MagicWord::get('msg'); -//// $mwMsg->matchStartAndRemove($part1); -//// } -// -// // Check for RAW: -//// $mwRaw = MagicWord::get('raw'); -//// if ($mwRaw->matchStartAndRemove($part1)) { -//// force_raw_interwiki = true; -//// } -// } - - // Parser functions -// if (!found) { -// $colonPos = strpos($part1, ':'); -// if ($colonPos != false) { -// $func = substr($part1, 0, $colonPos); -// $funcArgs = [ trim(substr($part1, $colonPos + 1)) ]; -// $argsLength = $args->getLength(); -// for ($i = 0; $i < $argsLength; $i++) { -// $funcArgs[] = $args->item($i); -// } -// try { -// $result = $this->callParserFunction($frame, $func, $funcArgs); -// } catch (Exception $ex) { -// throw $ex; -// } - - // The interface for parser functions allows for extracting - // flags into the local scope. Extract any forwarded flags - // here. -// extract($result); -// } -// } - - // Finish mangling title and then check for loops. - // Set title to a Title Object and $title_text to the PDBK -// if (!found) { -// $ns = NS_TEMPLATE; - // Split the title into page and subpage -// $subpage = ''; -// $relative = $this->maybeDoSubpageLink($part1, $subpage); -// if ($part1 != $relative) { -// $part1 = $relative; -// $ns = $this->mTitle->getNamespace(); -// } -// title = Title::newFromText($part1, $ns); -// if (title) { -// $title_text = title->getPrefixedText(); -// // Check for language variants if the template is not found -// if ($this->getConverterLanguage()->hasVariants() && title->getArticleID() == 0) { -// $this->getConverterLanguage()->findVariantLink($part1, title, true); -// } -// // Do recursion depth check -// $limit = $this->mOptions->getMaxTemplateDepth(); -// if ($frame->depth >= $limit) { -// found = true; -// $text = '' -// . wfMessage('parser-template-recursion-depth-warning') -// ->numParams($limit)->inContentLanguage()->text() -// . ''; -// } -// } -// } - - // Load from database -// if (!found && title) { -// $profile_section = $this->mProfiler->scopedProfileIn(title->getPrefixedDBkey()); -// if (!title->isExternal()) { -// if (title->isSpecialPage() -// && $this->mOptions->getAllowSpecialInclusion() -// && $this->ot['html'] -// ) { -// $specialPage = SpecialPageFactory::getPage(title->getDBkey()); -// // Pass the template arguments as URL parameters. -// // "uselang" will have no effect since the Language Object -// // is forced to the one defined in ParserOptions. -// $pageArgs = []; -// $argsLength = $args->getLength(); -// for ($i = 0; $i < $argsLength; $i++) { -// $bits = $args->item($i)->splitArg(); -// if (strval($bits['index']) == '') { -// $name = trim($frame->expand($bits['name'], PPFrame::STRIP_COMMENTS)); -// $value = trim($frame->expand($bits['value'])); -// $pageArgs[$name] = $value; -// } -// } -// -// // Create a new context to execute the special page -// $context = new RequestContext; -// $context->setTitle(title); -// $context->setRequest(new FauxRequest($pageArgs)); -// if ($specialPage && $specialPage->maxIncludeCacheTime() == 0) { -// $context->setUser($this->getUser()); -// } else { -// // If this page is cached, then we better not be per user. -// $context->setUser(User::newFromName('127.0.0.1', false)); -// } -// $context->setLanguage($this->mOptions->getUserLangObj()); -// $ret = SpecialPageFactory::capturePath( -// title, $context, $this->getLinkRenderer()); -// if ($ret) { -// $text = $context->getOutput()->getHTML(); -// $this->mOutput->addOutputPageMetadata($context->getOutput()); -// found = true; -// is_html = true; -// if ($specialPage && $specialPage->maxIncludeCacheTime() != false) { -// $this->mOutput->updateRuntimeAdaptiveExpiry( -// $specialPage->maxIncludeCacheTime() -// ); -// } -// } -// } elseif (XomwNamespace::isNonincludable(title->getNamespace())) { -// found = false; // access denied -// wfDebug(__METHOD__ . ": template inclusion denied for " . -// title->getPrefixedDBkey() . "\n"); -// } else { -// list($text, title) = $this->getTemplateDom(title); -// if ($text != false) { -// found = true; -// is_child_obj = true; -// } -// } -// -// // If the title is valid but undisplayable, make a link to it -// if (!found && ($this->ot['html'] || $this->ot['pre'])) { -// $text = "[[:$title_text]]"; -// found = true; -// } -// } elseif (title->isTrans()) { -// // Interwiki transclusion -// if ($this->ot['html'] && !force_raw_interwiki) { -// $text = $this->interwikiTransclude(title, 'render'); -// is_html = true; -// } else { -// $text = $this->interwikiTransclude(title, 'raw'); -// // Preprocess it like a template -// $text = $this->preprocessToDom($text, self::PTD_FOR_INCLUSION); -// is_child_obj = true; -// } -// found = true; -// } -// -// // Do infinite loop check -// // This has to be done after redirect resolution to avoid infinite loops via redirects -// if (!$frame->loopCheck(title)) { -// found = true; -// $text = '' -// . wfMessage('parser-template-loop-warning', $title_text)->inContentLanguage()->text() -// . ''; -// wfDebug(__METHOD__ . ": template loop broken at '$title_text'\n"); -// } -// } - - // If we haven't found text to substitute by now, we're done - // Recover the source wikitext and return it -// if (!found) { -// $text = $frame->virtualBracketedImplode('{{', '|', '}}', title_with_spaces, $args); -// if ($profile_section) { -// $this->mProfiler->scopedProfileOut($profile_section); -// } -// return [ 'Object' => $text ]; -// } - - // Expand DOM-style return values in a child frame -// if (is_child_obj) { -// // Clean up argument array -// $newFrame = $frame->newChild($args, title); -// -// if (nowiki) { -// $text = $newFrame->expand($text, PPFrame::RECOVER_ORIG); -// } elseif ($title_text != false && $newFrame->isEmpty()) { -// // Expansion is eligible for the empty-frame cache -// $text = $newFrame->cachedExpand($title_text, $text); -// } else { -// // Uncached expansion -// $text = $newFrame->expand($text); -// } -// } -// if (is_local_obj && nowiki) { -// $text = $frame->expand($text, PPFrame::RECOVER_ORIG); -// is_local_obj = false; -// } - -// if ($profile_section) { -// $this->mProfiler->scopedProfileOut($profile_section); -// } - - // Replace raw HTML by a placeholder -// if (is_html) { -// $text = $this->insertStripItem($text); -// } elseif (nowiki && ($this->ot['html'] || $this->ot['pre'])) { -// // Escape nowiki-style return values -// $text = wfEscapeWikiText($text); -// } elseif (is_string($text) -// && !$piece['lineStart'] -// && preg_match('/^(?:{\\||:|;|#|\*)/', $text) -// ) { -// // T2529: if the template begins with a table or block-level -// // element, it should be treated as beginning a new line. -// // This behavior is somewhat controversial. -// $text = "\n" . $text; -// } - -// if (is_string($text) && !$this->incrementIncludeSize('post-expand', strlen($text))) { -// // Error, oversize inclusion -// if ($title_text != false) { -// // Make a working, properly escaped link if possible (T25588) -// $text = "[[:$title_text]]"; -// } else { -// // This will probably not be a working link, but at least it may -// // provide some hint of where the problem is -// preg_replace('/^:/', '', $originalTitle); -// $text = "[[:$originalTitle]]"; -// } -// $text .= $this->insertStripItem(''); -// $this->limitationWarn('post-expand-template-inclusion'); -// } -// -// if (is_local_obj) { -// $ret = [ 'Object' => $text ]; -// } else { -// $ret = [ 'text' => $text ]; -// } - -// return $ret; -// } - -// \\ Triple brace replacement -- used for template arguments -// public function argSubstitution($piece, $frame) { -// -// $error = false; -// $parts = $piece['parts']; -// $nameWithSpaces = $frame->expand($piece['title']); -// $argName = trim($nameWithSpaces); -// $Object = false; -// $text = $frame->getArgument($argName); -// if ($text == false && $parts->getLength() > 0 -// && ($this->ot['html'] -// || $this->ot['pre'] -// || ($this->ot['wiki'] && $frame->isTemplate()) -// ) -// ) { -// // No match in frame, use the supplied default -// $Object = $parts->item(0)->getChildren(); -// } -// if (!$this->incrementIncludeSize('arg', strlen($text))) { -// $error = ''; -// $this->limitationWarn('post-expand-template-argument'); -// } -// -// if ($text == false && $Object == false) { -// // No match anywhere -// $Object = $frame->virtualBracketedImplode('{{{', '|', '}}}', $nameWithSpaces, $parts); -// } -// if ($error != false) { -// $text .= $error; -// } -// if ($Object != false) { -// $ret = [ 'Object' => $Object ]; -// } else { -// $ret = [ 'text' => $text ]; -// } -// -// return $ret; -// } -// -// /** -// \\ Return the text to be used for a given extension tag. -// \\ This is the ghost of strip(). -// \\ -// \\ @param array $params Associative array of parameters: -// \\ name PPNode for the tag name -// \\ attr PPNode for unparsed text where tag attributes are thought to be -// \\ attributes Optional associative array of parsed attributes -// \\ inner Contents of extension element -// \\ noClose Original text did not have a close tag -// \\ @param PPFrame $frame -// \\ -// \\ @throws MWException -// \\ @return String -// \\/ -// public function extensionSubstitution($params, $frame) { -// static $errorStr = ''; -// static $errorLen = 20; -// -// $name = $frame->expand($params['name']); -// if (substr($name, 0, $errorLen) == $errorStr) { -// // Probably expansion depth or node count exceeded. Just punt the -// // error up. -// return $name; -// } -// -// $attrText = !isset($params['attr']) ? null : $frame->expand($params['attr']); -// if (substr($attrText, 0, $errorLen) == $errorStr) { -// // See above -// return $attrText; -// } -// -// // We can't safely check if the expansion for $content resulted in an -// // error, because the content could happen to be the error String -// // (T149622). -// $content = !isset($params['inner']) ? null : $frame->expand($params['inner']); -// -// $marker = self::MARKER_PREFIX . "-$name-" -// . sprintf('%08X', $this->mMarkerIndex++) . self::MARKER_SUFFIX; -// -// $isFunctionTag = isset($this->mFunctionTagHooks[strtolower($name)]) && -// ($this->ot['html'] || $this->ot['pre']); -// if ($isFunctionTag) { -// $markerType = 'none'; -// } else { -// $markerType = 'general'; -// } -// if ($this->ot['html'] || $isFunctionTag) { -// $name = strtolower($name); -// $attributes = Sanitizer::decodeTagAttributes($attrText); -// if (isset($params['attributes'])) { -// $attributes = $attributes + $params['attributes']; -// } -// -// if (isset($this->mTagHooks[$name])) { -// // Workaround for PHP bug 35229 and similar -// if (!is_callable($this->mTagHooks[$name])) { -// throw new MWException("Tag hook for $name is not callable\n"); -// } -// $output = call_user_func_array($this->mTagHooks[$name], -// [ $content, $attributes, $this, $frame ]); -// } elseif (isset($this->mFunctionTagHooks[$name])) { -// list($callback,) = $this->mFunctionTagHooks[$name]; -// if (!is_callable($callback)) { -// throw new MWException("Tag hook for $name is not callable\n"); -// } -// -// $output = call_user_func_array($callback, [ &$this, $frame, $content, $attributes ]); -// } else { -// $output = 'Invalid tag extension name: ' . -// htmlspecialchars($name) . ''; -// } -// -// if (is_array($output)) { -// // Extract flags to local scope (to override $markerType) -// $flags = $output; -// $output = $flags[0]; -// unset($flags[0]); -// extract($flags); -// } -// } else { -// if (is_null($attrText)) { -// $attrText = ''; -// } -// if (isset($params['attributes'])) { -// foreach ($params['attributes'] as $attrName => $attrValue) { -// $attrText .= ' ' . htmlspecialchars($attrName) . '="' . -// htmlspecialchars($attrValue) . '"'; -// } -// } -// if ($content == null) { -// $output = "<$name$attrText/>"; -// } else { -// $close = is_null($params['close']) ? '' : $frame->expand($params['close']); -// if (substr($close, 0, $errorLen) == $errorStr) { -// // See above -// return $close; -// } -// $output = "<$name$attrText>$content$close"; -// } -// } -// -// if ($markerType == 'none') { -// return $output; -// } elseif ($markerType == 'nowiki') { -// $this->mStripState->addNoWiki($marker, $output); -// } elseif ($markerType == 'general') { -// $this->mStripState->addGeneral($marker, $output); -// } else { -// throw new MWException(__METHOD__ . ': invalid marker type'); -// } -// return $marker; -// } -// } diff --git a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node.java b/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node.java deleted file mode 100644 index 5c5e12316..000000000 --- a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node.java +++ /dev/null @@ -1,96 +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 interface Xomw_prepro_node { - int Subs__len(); - Xomw_prepro_node Subs__get_at(int i); - void Subs__add(Xomw_prepro_node sub); - void To_xml(Bry_bfr bfr); -} -class Xomw_prepro_node__text extends Xomw_prepro_node__base { - public Xomw_prepro_node__text(byte[] bry) { - this.bry = bry; - } - public byte[] Bry() {return bry;} protected final byte[] bry; - @Override public void To_xml(Bry_bfr bfr) { - bfr.Add(bry); - } -} -class Xomw_prepro_node__comment extends Xomw_prepro_node__base { - public Xomw_prepro_node__comment(byte[] bry) { - this.bry = bry; - } - public byte[] Bry() {return bry;} protected final byte[] bry; - @Override public void To_xml(Bry_bfr bfr) { - bfr.Add_str_a7(""); - bfr.Add(bry); - bfr.Add_str_a7(""); - } -} -class Xomw_prepro_node__ext extends Xomw_prepro_node__base { - public Xomw_prepro_node__ext(byte[] name, byte[] attr, byte[] inner, byte[] close) { - this.name = name; - this.attr = attr; - this.inner = inner; - this.close = close; - } - public byte[] Name() {return name;} private final byte[] name; - public byte[] Attr() {return attr;} private final byte[] attr; - public byte[] Inner() {return inner;} private final byte[] inner; - public byte[] Close() {return close;} private final byte[] close; - @Override public void To_xml(Bry_bfr bfr) { - bfr.Add_str_a7(""); - bfr.Add_str_a7("").Add(name).Add_str_a7(""); - bfr.Add_str_a7("").Add(attr).Add_str_a7(""); - bfr.Add_str_a7("").Add(inner).Add_str_a7(""); - bfr.Add_str_a7("").Add(close).Add_str_a7(""); - bfr.Add_str_a7(""); - } -} -class Xomw_prepro_node__heading extends Xomw_prepro_node__base { - public Xomw_prepro_node__heading(int heading_index, int title_index, byte[] text) { - this.heading_index = heading_index; - this.title_index = title_index; - this.text = text; - } - public int Heading_index() {return heading_index;} private final int heading_index; - public int Title_index() {return title_index;} private final int title_index; - public byte[] Text() {return text;} private final byte[] text; - @Override public void To_xml(Bry_bfr bfr) { - bfr.Add_str_a7(""); - bfr.Add(text); - bfr.Add_str_a7(""); - } -} -class Xomw_prepro_node__tplarg extends Xomw_prepro_node__base { - public Xomw_prepro_node__tplarg(byte[] title, Xomw_prepro_node__part[] parts) { - this.title = title; this.parts = parts; - } - public byte[] Title() {return title;} private final byte[] title; - public Xomw_prepro_node__part[] Parts() {return parts;} private final Xomw_prepro_node__part[] parts; - @Override public void To_xml(Bry_bfr bfr) { - bfr.Add_str_a7(""); - bfr.Add_str_a7("").Add(title); - bfr.Add_str_a7(""); - for (Xomw_prepro_node__part part : parts) - part.To_xml(bfr); - - bfr.Add_str_a7(""); - } -} diff --git a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node__base.java b/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node__base.java deleted file mode 100644 index 4d5c5876c..000000000 --- a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node__base.java +++ /dev/null @@ -1,26 +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 abstract class Xomw_prepro_node__base implements Xomw_prepro_node { - private List_adp subs; - public int Subs__len() {return subs == null ? 0 : subs.Len();} - public Xomw_prepro_node Subs__get_at(int i) {return subs == null ? null : (Xomw_prepro_node)subs.Get_at(i);} - public void Subs__add(Xomw_prepro_node sub) { - if (subs == null) subs = List_adp_.New(); - subs.Add(sub); - } - public abstract void To_xml(Bry_bfr bfr); -} diff --git a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node__part.java b/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node__part.java deleted file mode 100644 index 89c89d115..000000000 --- a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node__part.java +++ /dev/null @@ -1,43 +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 Xomw_prepro_node__part extends Xomw_prepro_node__base { - public Xomw_prepro_node__part(int idx, byte[] key, byte[] val) { - this.idx = idx; - this.key = key; - this.val = val; - } - public int Idx() {return idx;} private final int idx; - public byte[] Key() {return key;} private final byte[] key; - public byte[] Val() {return val;} private final byte[] val; - @Override public void To_xml(Bry_bfr bfr) { - bfr.Add_str_a7(""); - bfr.Add_str_a7(" 0) { - bfr.Add_str_a7(" index=\"").Add_int_variable(idx).Add_str_a7("\" />"); - } - else { - bfr.Add_str_a7(">"); - bfr.Add(key); - bfr.Add_str_a7(""); - bfr.Add_str_a7("="); - } - bfr.Add_str_a7(""); - bfr.Add(val); - bfr.Add_str_a7(""); - bfr.Add_str_a7(""); - } -} diff --git a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node__template.java b/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node__template.java deleted file mode 100644 index 5ab323fcd..000000000 --- a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_node__template.java +++ /dev/null @@ -1,34 +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 Xomw_prepro_node__template extends Xomw_prepro_node__base { - public Xomw_prepro_node__template(byte[] title, Xomw_prepro_node__part[] parts, int line_start) { - this.title = title; this.parts = parts; this.line_start = line_start; - } - public byte[] Title() {return title;} private final byte[] title; - public Xomw_prepro_node__part[] Parts() {return parts;} private final Xomw_prepro_node__part[] parts; - public int Line_start() {return line_start;} private final int line_start; - @Override public void To_xml(Bry_bfr bfr) { - bfr.Add_str_a7(" 0) bfr.Add_str_a7(" lineStart=\"").Add_int_variable(line_start).Add_byte_quote(); - bfr.Add_byte(Byte_ascii.Angle_end); - bfr.Add_str_a7("").Add(title); - bfr.Add_str_a7(""); - for (Xomw_prepro_node__part part : parts) - part.To_xml(bfr); - bfr.Add_str_a7(""); - } -} diff --git a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_piece.java b/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_piece.java deleted file mode 100644 index 1a290d98c..000000000 --- a/400_xowa/src/gplx/xowa/mediawiki/includes/parsers/preprocessors/Xomw_prepro_piece.java +++ /dev/null @@ -1,85 +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 Xomw_prepro_piece { - public final byte[] open; // Opening character (\n for heading) - public final byte[] close; // Matching closing char; - public int count; // Number of opening characters found (number of "=" for heading) - public final boolean line_start; // True if the open char appeared at the start of the input line; Not set for headings. - public final int start_pos; - public List_adp parts = List_adp_.New(); - private final XomwPPDPart part_factory; - public Xomw_prepro_piece(XomwPPDPart part_factory, byte[] open, byte[] close, int count, int start_pos, boolean line_start) { - this.part_factory = part_factory; - this.open = open; - this.close = close; - this.count = count; - this.start_pos = start_pos; - this.line_start = line_start; - parts.Add(part_factory.Make_new("")); - } - public void Parts__renew() { - parts.Clear(); - this.Add_part(Bry_.Empty); - } - public XomwPPDPart Get_current_part() { - return (XomwPPDPart)parts.Get_at(parts.Len() - 1); - } - public Xomw_prepro_accum Get_accum() { - return Get_current_part().Accum(); - } - public void Add_part(byte[] bry) { - parts.Add(part_factory.Make_new(String_.new_u8(bry))); - } - public static final byte[] Brack_bgn_bry = Bry_.new_a7("["); - public void Set_flags(Xomw_prepro_flags flags) { - int parts_len = parts.Len(); - boolean open_is_nl = Bry_.Eq(open, Byte_ascii.Nl_bry); - boolean findPipe = !open_is_nl && !Bry_.Eq(open, Brack_bgn_bry); - flags.findPipe = findPipe; - flags.findEquals = findPipe && parts_len > 1 && ((XomwPPDPart)parts.Get_at(parts_len - 1)).eqpos != -1; - flags.inHeading = open_is_nl; - } - // Get the output String that would result if the close is not found. - public byte[] Break_syntax(Bry_bfr tmp_bfr, int opening_count) { - byte[] rv = Bry_.Empty; - if (Bry_.Eq(open, Byte_ascii.Nl_bry)) { - rv = ((XomwPPDPart_DOM)parts.Get_at(0)).To_bry(); - } - else { - if (opening_count == -1) { - opening_count = count; - } - tmp_bfr.Add(Bry_.Repeat_bry(open, opening_count)); - - // concat parts with "|" - boolean first = true; - int len = parts.Len(); - for (int i = 0; i < len; i++) { - XomwPPDPart part = (XomwPPDPart)parts.Get_at(i); - if (first) { - first = false; - } - else { - tmp_bfr.Add_byte_pipe(); - } - tmp_bfr.Add(((XomwPPDPart_DOM)part).To_bry()); - } - rv = tmp_bfr.To_bry_and_clear(); - } - return rv; - } -}