public Rule TableColumn(Var<TableNode> tableNode, Var<Boolean> pipeSeen) { Var<TableColumnNode> node = new Var<TableColumnNode>(new TableColumnNode()); return Sequence( NodeSequence( push(node.get()), Sp(), Optional(':', node.get().markLeftAligned()), Sp(), OneOrMore('-'), Sp(), Optional(':', node.get().markRightAligned()), Sp(), Optional('|', pipeSeen.set(Boolean.TRUE)) ), tableNode.get().addColumn((TableColumnNode) pop()) ); }
public Rule RefSrcContent(Var<ReferenceNode> ref) { return Sequence(OneOrMore(TestNot('>'), Nonspacechar()), ref.get().setUrl(match())); }
public Rule Abbreviation() { Var<AbbreviationNode> node = new Var<AbbreviationNode>(); return NodeSequence( NonindentSpace(), '*', Label(), push(node.setAndGet(new AbbreviationNode(popAsNode()))), Sp(), ':', Sp(), AbbreviationText(node), abbreviations.add(node.get()) ); }
public Rule RefTitle(char open, char close, Var<ReferenceNode> ref) { return Sequence( open, ZeroOrMore(TestNot(close, Sp(), Newline()), NotNewline(), ANY), ref.get().setTitle(match()), close ); }
public Rule AbbreviationText(Var<AbbreviationNode> node) { return Sequence( NodeSequence( push(new SuperNode()), ZeroOrMore(NotNewline(), Inline(), addAsChild()) ), node.get().setExpansion(popAsNode()) ); }
public Rule ReferenceNoEOL() { Var<ReferenceNode> ref = new Var<ReferenceNode>(); return NodeSequence( NonindentSpace(), Label(), push(ref.setAndGet(new ReferenceNode(popAsNode()))), ':', Spn1(), RefSrc(ref), Sp(), Optional(RefTitle(ref)), Sp(), // make range not include the EOL Test(Newline()), references.add(ref.get()) ); }
public Rule TableRow() { Var<Boolean> leadingPipe = new Var<Boolean>(Boolean.FALSE); return NodeSequence( push(new TableRowNode()), Optional('|', leadingPipe.set(Boolean.TRUE)), OneOrMore(TableCell(), addAsChild()), leadingPipe.get() || ((Node) peek()).getChildren().size() > 1 || getContext().getInputBuffer().charAt(matchEnd() - 1) == '|', Sp(), Newline() ); }
@Cached public Rule CodeFence(Var<Integer> markerLength) { return Sequence( FirstOf(NOrMore('~', 3), NOrMore('`', 3)), (markerLength.isSet() && matchLength() == markerLength.get()) || (markerLength.isNotSet() && markerLength.set(matchLength())), Sp(), ZeroOrMore(TestNot(Newline()), ANY), // GFM code type identifier push(match()), Newline() ); }
), tight.get() ? push(tightFirstItem.setAndGet(itemNodeCreator.create(parseListBlock(block), taskType.get(), taskListMarker.getString()))) && taskListMarker.clearContents() : fixFirstItem((SuperNode) peek(1)) && push(itemNodeCreator.create(parseListBlock(block.appended('\n')), taskType.get(), taskListMarker.getString())) && taskListMarker.clearContents(), ZeroOrMore( (tight.get() ? push(parseListBlock(block)) : ((!ext(FORCELISTITEMPARA)) || tightFirstItem.isNotSet() || wrapFirstItemInPara(tightFirstItem.get())) && push(wrapFirstSubItemInPara((SuperNode) parseListBlock(block.appended('\n')))) ) && addAsChild()
public Rule Table() { Var<TableNode> node = new Var<TableNode>(); return NodeSequence( push(node.setAndGet(new TableNode())), Optional( NodeSequence( TableRow(), push(1, new TableHeaderNode()) && addAsChild(), ZeroOrMore(TableRow(), addAsChild()) ), addAsChild() // add the TableHeaderNode to the TableNode ), TableDivider(node), Optional( NodeSequence( TableRow(), push(1, new TableBodyNode()) && addAsChild(), ZeroOrMore(TableRow(), addAsChild()) ), addAsChild() // add the TableHeaderNode to the TableNode ), // only accept as table if we have at least one header or at least one body Optional(TableCaption(), addAsChild()), !node.get().getChildren().isEmpty() ); }
), tight.get() ? push(tightFirstItem.setAndGet(itemNodeCreator.create(parseListBlock(block)))) : fixFirstItem((SuperNode) peek(1)) && push(itemNodeCreator.create(parseListBlock(block.appended('\n')))), (tight.get() ? push(parseListBlock(block)) : ((!ext(FORCELISTITEMPARA)) || tightFirstItem.isNotSet() || wrapFirstItemInPara(tightFirstItem.get())) && push(wrapFirstSubItemInPara((SuperNode) parseListBlock(block.appended('\n')))) ) && addAsChild()
@Override public boolean run(final Context<BaseTemplate> context) { String endName = context.getMatch(); boolean match = name.get().text.equals(endName); if (!match) { noffset = endName.length(); throw new ActionException(String.format( "found: '%s', expected: '%s'", endName, name.get().text)); } return match; } },
Rule containsAll() { Var<List<ConditionValue>> elems = new Var<List<ConditionValue>>(new LinkedList<ConditionValue>()); return Sequence(field(), push(match()), space(), EQUALS, space(), SQUARE_BRACKET_OPEN, space(), value(), elems.get().add((ConditionValue)pop()), space(), ZeroOrMore(COMMA, space(), value(), elems.get().add((ConditionValue)pop()), space()), SQUARE_BRACKET_CLOSE, push(new ContainsAll(toElement(pop().toString()), elems.get()))); } Rule containsOne() {
Rule stringFunction() { Var<String> alias = new Var<String>(); return Sequence(valueText(), Optional(alias(alias)), push(new FunctionValue(alias.get(), ((ConditionValueString)pop()).getValue() ))); }
Rule function() { Var<String> alias = new Var<String>(); return Sequence(OneOrMore(FirstOf(field(), AnyOf("#"))), push(match()), BRACKET_OPEN, push(new LinkedList()), Optional(functionOrFieldOrString(), ZeroOrMore(COMMA, functionOrFieldOrString())), BRACKET_CLOSE, Optional(alias(alias)), push(WikittyQueryFunction.create(pop(1).toString(), alias.get(), (List)pop()))); }
/** * Term definition. * * @return Term definition rule. */ public Rule term() { Var<Character> op = new Var<>(); return Sequence(factor(), ZeroOrMore(ZeroOrMore(whitespace()), FirstOf("*", "/"), op.set(matchedChar()), ZeroOrMore(whitespace()), factor(), push(createMultiplicationOrDivisionRateGenerator(op.get())))); }