示例#1
0
def code():
    return pg.AllOf(
        pg.Ignore("`"),
        pg.Join(
            pg.Many(
                pg.Not("`"))),
        pg.Ignore("`"))
示例#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"
示例#3
0
def link_text():
    return pg.AllOf(
        pg.Ignore("["),
        pg.Join(
            pg.Many(
                pg.Not("]"))),
        pg.Ignore("]"))
示例#4
0
def link_url():
    return pg.AllOf(
        pg.Ignore("("),
        pg.Join(
            pg.Many(
                pg.Not(")"))),
        pg.Ignore(")"))
示例#5
0
文件: jade.py 项目: Singletoned/jade
def text():
    return pg.AllOf(pg.Ignore("| "), pg.Join(pg.Many(pg.Not(newline_or_eof))),
                    pg.Ignore(newline_or_eof))
示例#6
0
def code_line():
    return pg.Escaped(
        pg.Join(
            pg.Many(
                pg.Not("\n"))))
示例#7
0
文件: jade.py 项目: Singletoned/jade
def code_block():
    return pg.AllOf(pg.Ignore("!="), pg.Join(pg.Many(pg.Not(newline_or_eof))),
                    pg.Ignore(newline_or_eof))
示例#8
0
文件: jade.py 项目: Singletoned/jade
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))
示例#9
0
文件: jade.py 项目: Singletoned/jade
def content():
    return pg.AllOf(pg.Ignore(pg.OneOf(" | ", " ")),
                    pg.Join(pg.Many(pg.Not(newline_or_eof))))
示例#10
0
文件: jade.py 项目: Singletoned/jade
def attribute_value_code():
    return pg.OneOf(
        pg.AllOf(pg.Ignore("{{"), pg.Join(pg.Many(pg.Not("}}"))),
                 pg.Ignore("}}")), identifier_parts)
示例#11
0
文件: jade.py 项目: Singletoned/jade
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('"')))