예제 #1
0
파일: tools.py 프로젝트: kstep/greencss
def quoted(char=anychar, quot=charclass('\'"'), esc=lit('\\')):
    charseq = seq(but(state.check), char)
    if esc:
        escseq = seq(skip(esc), alter(quot, esc))
        charseq = alter(escseq, charseq)
    return wrap_parser('quoted')(
                surround(pipe(star(charseq), join), state.push(quot), state.pop)
                )
예제 #2
0
파일: tools.py 프로젝트: kstep/greencss
def braced(char=anychar, left=lit('('), right=lit(')'), esc=lit('\\')):
    charseq = seq(but(right), char)
    if esc:
        escseq = seq(skip(esc), alter(right, esc))
        charseq = alter(escseq, charseq)
    return wrap_parser('braced')(
                surround(pipe(star(charseq), join), left, right)
                )
예제 #3
0
파일: literals.py 프로젝트: kstep/greencss
def word(w, border='\t '):
    from greencss.lexer.parsers.compound import seq, star
    border = star(charclass(border))
    return wrap_parser('word', w)(
            seq(border, lit(w), border)
            )
예제 #4
0
파일: tools.py 프로젝트: kstep/greencss
def surround(parser, left=lit('('), right=lit(')')):
    return wrap_parser('surround')(
            seq(skip(left), parser, skip(right)))
예제 #5
0
파일: tools.py 프로젝트: kstep/greencss
def commalist(parser, comma=lit(','), wsp=charclass('\t ')):
    delim = seq(star(wsp), comma, star(wsp))
    return wrap_parser('commalist')(
            seq(parser, star(seq(skip(delim), parser))))
예제 #6
0
파일: compound.py 프로젝트: kstep/greencss
def plus(parser):
    '''
    One or more parser
    '''
    return wrap_parser('plus', parser)(seq(parser, star(parser)))
예제 #7
0
파일: compound.py 프로젝트: kstep/greencss
def plus(parser):
    """
    One or more parser
    """
    return wrap_parser("plus", parser)(seq(parser, star(parser)))