Ejemplo n.º 1
0
def code():
    return pg.AllOf(
        pg.Ignore("`"),
        pg.Join(
            pg.Many(
                pg.Not("`"))),
        pg.Ignore("`"))
Ejemplo n.º 2
0
def test_match_join():
    three_times_a = pg.Join(pg.CountOf(3, "a"))

    data = "aaa"
    expected = ['three_times_a', "aaa"]
    match, rest = pg.match_join(data, three_times_a, 'three_times_a')
    assert match == expected
    assert rest == ""

    not_d = pg.Join(pg.Many(pg.Not("d")))

    data = "abcd"
    expected = ['not_d', "abc"]
    match, rest = pg.match_join(data, not_d, 'not_d')
    assert match == expected
    assert rest == "d"
Ejemplo n.º 3
0
def link_text():
    return pg.AllOf(
        pg.Ignore("["),
        pg.Join(
            pg.Many(
                pg.Not("]"))),
        pg.Ignore("]"))
Ejemplo n.º 4
0
def link_url():
    return pg.AllOf(
        pg.Ignore("("),
        pg.Join(
            pg.Many(
                pg.Not(")"))),
        pg.Ignore(")"))
Ejemplo n.º 5
0
def text():
    return pg.AllOf(pg.Ignore("| "), pg.Join(pg.Many(pg.Not(newline_or_eof))),
                    pg.Ignore(newline_or_eof))
Ejemplo n.º 6
0
def code_line():
    return pg.Escaped(
        pg.Join(
            pg.Many(
                pg.Not("\n"))))
Ejemplo n.º 7
0
def code_block():
    return pg.AllOf(pg.Ignore("!="), pg.Join(pg.Many(pg.Not(newline_or_eof))),
                    pg.Ignore(newline_or_eof))
Ejemplo n.º 8
0
def comment():
    return pg.AllOf(pg.Optional(pg.Ignore(pg.Many(" "))), pg.Ignore("// "),
                    pg.Join(pg.Many(pg.Not(newline_or_eof))),
                    pg.Ignore(newline_or_eof))
Ejemplo n.º 9
0
def content():
    return pg.AllOf(pg.Ignore(pg.OneOf(" | ", " ")),
                    pg.Join(pg.Many(pg.Not(newline_or_eof))))
Ejemplo n.º 10
0
def attribute_value_code():
    return pg.OneOf(
        pg.AllOf(pg.Ignore("{{"), pg.Join(pg.Many(pg.Not("}}"))),
                 pg.Ignore("}}")), identifier_parts)
Ejemplo n.º 11
0
def quoted_string():
    return pg.OneOf(
        pg.AllOf(pg.Ignore("'"), pg.Optional(pg.Join(pg.Many(pg.Not("'")))),
                 pg.Ignore("'")),
        pg.AllOf(pg.Ignore('"'), pg.Optional(pg.Join(pg.Many(pg.Not('"')))),
                 pg.Ignore('"')))