コード例 #1
0
ファイル: adnauseam.py プロジェクト: srobertson/adnauseam
def tokenize(template):
  t = Tokens(template)
  while not t.at_end():
    if t.current_char == '{':
      path = t.read_until('}') + t.read_char()
      yield Key(path[1:-1].strip())
    else:
      yield t.read_until('{')
コード例 #2
0
def parse(statement, root_exp=None):
    if root_exp is None:
        root_exp = and_exp

    tokens = list(Tokens(statement))
    exp = root_exp(tokens)
    if tokens:
        raise SyntaxError('Incomplete statement {}'.format(tokens))
    return exp
コード例 #3
0
ファイル: adnauseam.py プロジェクト: srobertson/adnauseam
def tokenize(template):
    t = Tokens(template)
    while not t.at_end():
        if t.current_char == '{':
            path = t.read_until('}') + t.read_char()
            yield Key(path[1:-1].strip())
        else:
            yield t.read_until('{')
コード例 #4
0
ファイル: path.py プロジェクト: graingert/splicer
def tokenize_pattern(pattern):
  t = Tokens(pattern)
  while not t.at_end():
    if t.current_char == '/':
      yield t.read_char()
    elif t.current_char == '{':
      yield t.read_until('}') + t.read_char()
    else:
      yield t.read_until('/{')
コード例 #5
0
ファイル: query_parser.py プロジェクト: gstarnberger/splicer
def parse(statement, root_exp=None):
    term = set(terminators)

    if root_exp is None:
        root_exp = and_exp

    tokens = [
        token.lower() if token.lower() in term else token
        for token in Tokens(statement)
    ]

    exp = root_exp(tokens)
    if tokens:
        raise SyntaxError('Incomplete statement {}'.format(tokens))
    return exp