All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sweble.wikitext.lazy.parser.TableRow.rats Maven / Gradle / Ivy

There is a newer version: 3.1.9
Show newest version
/**
 * Copyright 2011 The Open Source Research Group,
 *                University of Erlangen-Nürnberg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*!
 *
 * TableRow
 * --------
 *
 *   Grammar:
 *     - WS* '|-' TableAttribute* S*
 *
 *   AST node:
 *     Name        : TableRow
 *     Extends     : InnerNode.InnerNode2
 *     Constructor : "xmlAttributes, body"
 *     NodeType    : org.sweble.wikitext.lazy.AstNodeTypes.NT_TABLE_ROW
 *
 *     Children:
 *       xmlAttributes : NodeList
 *       body          : NodeList
 *
 */

module org.sweble.wikitext.lazy.parser.TableRow;

import org.sweble.wikitext.lazy.utils.Assert;

import org.sweble.wikitext.lazy.parser.Content;
import org.sweble.wikitext.lazy.parser.TableAttribute;
import org.sweble.wikitext.lazy.parser.TableCell;
import org.sweble.wikitext.lazy.parser.TableHeader;
import org.sweble.wikitext.lazy.parser.Whitespace;




// -- Table Row --[ State Aware Memoization ]-----------------------------------

noinline transient AstNode TableRow =
 ^{
    final StateAwareResult r = (StateAwareResult) pTableRowMemoized(yyBase);
    final LazyParserContext context = getContext();
    Result yyResult = r.getResult(context);
    if (yyResult == null)
      yyResult = r.setResult(context, pTableRowTransient(yyBase));
    if (returnTrue(r))
      return yyResult;
  }
;

noinline memoized AstNode TableRowMemoized =
 ^{
    final Result yyResult = new StateAwareResult("TableRow", getContext(), pTableRowTransient(yyBase));
    if (returnTrue(yyResult))
      return yyResult;
  }
;




// -- Table Row ----------------------------------------------------------------

noinline transient AstNode TableRowTransient =
  rt0:pExtSpaceStar "|-" attributes:TableAttributeStar body:TableRowBody
  {
    yyValue = new TableRow(attributes, body._3);

    if (isGatherRtData())
      addRtData(yyValue,
          joinRt(rt0, "|-"),
          joinRt(body._1, body._2),
          null);
  }
;

private inline Tuple3 TableRowBody =
    rt0:pExtSpaceStar rt1:pEol body:TableRowContentStar
    {
      yyValue = Tuple.from(rt0, rt1, body);
    }
  / rt0:pExtSpaceStar Eof
    {
      // Warning will be issued by the surrounding table.
      yyValue = Tuple.from(rt0, "", new NodeList());
    }
  / &ShouldNotBeHere SantiyCheckEnd
    {
      yyValue = null;
    }
;

private transient stateful NodeList TableRowContentStar =
  {
    enter(ParserScopes.TABLE_ELEMENTS);
  }
  garbage:BolBlockContent content:TableRowElement*
  {
    yyValue = new NodeList(garbage, new NodeList(content));
  }
;

private inline AstNode TableRowElement =
    &TableRowElementPrefix ( TableCell / TableHeader )
  / &( RowDoneSanityCheck / ShouldNotBeHere ) SantiyCheckEnd
;

private inline void TableRowElementPrefix =
    pExtSpaceStar "|" ![+}\-]
  / pExtSpaceStar "!"
;

private inline void RowDoneSanityCheck =
  pExtSpaceStar ( "|+" / "|-" / "|}" / Eof )
;




// -- End of file --------------------------------------------------------------




© 2015 - 2024 Weber Informatics LLC | Privacy Policy