Examples of StringVar


Examples of org.parboiled.support.StringVar

    return FirstOf( Quoted(), Escaped(), NamedParameter(), Other() );
  }

  @SuppressSubnodes
  public Rule NamedParameter() {
    StringVar name = new StringVar( "" );

    return Sequence(
      ParameterBeginDelimiter(),
      ZeroOrMore( WhiteSpace() ),
      OneOrMore( Alphanumeric() ),
      name.set( match() ),
      ZeroOrMore( WhiteSpace() ),
      ParameterEndDelimiter(),
      adapter.addNamedParameter( name.get(), currentIndex() )
    );
  }
View Full Code Here

Examples of org.parboiled.support.StringVar

    Rule HtmlBlockClose(StringVar tagName) {
        return Sequence('<', Spn1(), '/', OneOrMore(Alphanumeric()), match().equals(tagName.get()), Spn1(), '>');
    }

    Rule DefinedHtmlTagName() {
        StringVar name = new StringVar();
        return Sequence(
                OneOrMore(Alphanumeric()),
                name.set(match().toLowerCase()) && // compare ignoring case
                        Arrays.binarySearch(HTML_TAGS, name.get()) >= 0 && // make sure its a defined tag
                        push(new Node(name.get()))
        );
    }
View Full Code Here

Examples of org.parboiled.support.StringVar

        );
    }

    @Cached
    Rule Source(Var<ExpLinkNode> node) {
        StringVar url = new StringVar("");
        return FirstOf(
                Sequence('(', Source(node), ')'),
                Sequence('<', Source(node), '>'),
                Sequence(
                        OneOrMore(
                                FirstOf(
                                        Sequence('\\', AnyOf("()"), url.append(matchedChar())),
                                        Sequence(TestNot(AnyOf("()>")), Nonspacechar(), url.append(matchedChar()))
                                )
                        ),
                        node.get().setUrl(url.get())
                ),
                EMPTY
        );
    }
View Full Code Here

Examples of org.parboiled.support.StringVar

    Rule OptionallyIndentedLine() {
        return Sequence(Optional(Indent()), Line());
    }

    Rule Line() {
        StringVar line = new StringVar();
        return Sequence(
                ZeroOrMore(TestNot('\r'), TestNot('\n'), ANY), line.set(match() + '\n'),
                Newline(),
                push(new Node(line.get()))
        );
    }
View Full Code Here

Examples of org.parboiled.support.StringVar

                NonindentSpace(), Inlines(), push(new ParaNode(pop())), OneOrMore(BlankLine())
        );
    }

    Rule BlockQuote() {
        StringVar innerSource = new StringVar("");
        return Sequence(
                OneOrMore(
                        '>', Optional(' '), Line(), innerSource.append(pop().getText()),
                        ZeroOrMore(
                                TestNot('>'),
                                TestNot(BlankLine()),
                                Line(), innerSource.append(pop().getText())
                        ),
                        ZeroOrMore(BlankLine(), innerSource.append("\n"))
                ),
                // trigger a recursive parsing run on the innerSource we just built
                // and attach the root of the inner parses AST
                push(new BlockQuoteNode(parseRawBlock(innerSource.get()).resultValue))
        );
    }
View Full Code Here

Examples of org.parboiled.support.StringVar

                push(new BlockQuoteNode(parseRawBlock(innerSource.get()).resultValue))
        );
    }

    Rule Verbatim() {
        StringVar text = new StringVar("");
        StringVar temp = new StringVar("");
        return Sequence(
                OneOrMore(
                        ZeroOrMore(BlankLine(), temp.append("\n")),
                        NonblankIndentedLine(), text.append(temp.getAndSet(""), pop().getText())
                ),
                push(new VerbatimNode(text.get()))
        );
    }
View Full Code Here

Examples of org.parboiled.support.StringVar

    Rule ListItem(boolean tight) {
        // for a simpler parser design we use a recursive parsing strategy for list items:
        // we collect the markdown source for an item, run a complete parsing cycle on this inner source and attach
        // the root of the inner parsing results AST to the outer AST tree

        StringVar innerSource = new StringVar();
        StringVar blanks = new StringVar("");
        StringVar extraNLs = new StringVar("");

        return Sequence(
                FirstOf(Bullet(), Enumerator()),

                ListBlock(),
                innerSource.set(pop().getText()) &&
                        (tight || extraNLs.set("\n\n")), // append extra \n\n to loose list items

                ZeroOrMore(
                        FirstOf(
                                // if we have blank lines append them to the inner source
                                OneOrMore(BlankLine(), blanks.append("\n")),

                                // if we do not have a blank line we append a boundary marker
                                blanks.set(tight ? "\u0001" : "\n\n\u0001")
                        ),
                        OneOrMore(
                                Indent(), ListBlock(),

                                // append potentially captured blanks and the block text
                                innerSource.append(blanks.getAndSet(""), pop().getText())
                        ),
                        extraNLs.set("\n\n") // if we have several lines always add two extra newlines
                ),

                // finally, after having built the complete source we run an inner parse and attach its AST root
                setListItemNode(tight, innerSource.get() + extraNLs.get())
        );
    }
View Full Code Here

Examples of org.parboiled.support.StringVar

            start = end + 1;
        }
    }

    Rule ListBlock() {
        StringVar source = new StringVar();
        return Sequence(
                Line(),
                source.set(pop().getText()),
                ZeroOrMore(ListBlockLine(), source.append(pop().getText())),
                push(new Node(source.get()))
        );
    }
View Full Code Here

Examples of org.parboiled.support.StringVar

                OneOrMore(BlankLine())
        );
    }

    Rule HtmlBlockInTags() {
        StringVar tagName = new StringVar();
        return Sequence(
                HtmlBlockOpen(), tagName.set(pop().getText()),
                ZeroOrMore(FirstOf(HtmlBlockInTags(), Sequence(TestNot(HtmlBlockClose(tagName)), ANY))),
                HtmlBlockClose(tagName)
        );
    }
View Full Code Here

Examples of org.parboiled.support.StringVar

                NonindentSpace(), Inlines(), push(new ParaNode(pop())), OneOrMore(BlankLine())
        );
    }

    Rule BlockQuote() {
        StringVar innerSource = new StringVar("");
        return Sequence(
                OneOrMore(
                        '>', Optional(' '), Line(), innerSource.append(pop().getText()),
                        ZeroOrMore(
                                TestNot('>'),
                                TestNot(BlankLine()),
                                Line(), innerSource.append(pop().getText())
                        ),
                        ZeroOrMore(BlankLine(), innerSource.append("\n"))
                ),
                // trigger a recursive parsing run on the innerSource we just built
                // and attach the root of the inner parses AST
                push(new BlockQuoteNode(parseRawBlock(innerSource.get()).resultValue))
        );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.