def _EBQParser(clauses):

  def AddAll(tokens):
    temp_stack.append(''.join(tokens))

  def AddArgument(tokens):
    clauses[tokens[0]].extend(temp_stack)
    temp_stack[:] = []

  def AddSelectArgument():
    clauses['SELECT'].append(list(temp_stack))
    temp_stack[:] = []

  def AddLabel(tokens):
    temp_stack.append(tokens[0])

  def AddAlias(tokens):
    clauses['AS'][len(clauses['SELECT'])] = tokens[0]

  def AddInteger(tokens):
    temp_stack.append(int(tokens[0]))

  def AddLast(tokens):
    temp_stack[len(temp_stack) - 1] += ' ' + tokens[0]

  def AddWithin(tokens):
    clauses['WITHIN'][len(clauses['SELECT'])] = tokens[0]

  temp_stack = []

  as_kw = pp.CaselessKeyword('AS')
  select_kw = pp.CaselessKeyword('SELECT')
  within_kw = pp.CaselessKeyword('WITHIN')
  flatten_kw = pp.CaselessKeyword('FLATTEN')
  from_kw = pp.CaselessKeyword('FROM')
  where_kw = pp.CaselessKeyword('WHERE')
  having_kw = pp.CaselessKeyword('HAVING')
  order_kw = pp.CaselessKeyword('ORDER BY')
  asc_kw = pp.CaselessKeyword('ASC')
  desc_kw = pp.CaselessKeyword('DESC')
  group_kw = pp.CaselessKeyword('GROUP BY')
  limit_kw = pp.CaselessKeyword('LIMIT')

  push_label = pp.Word(
      pp.alphas, pp.alphas + pp.nums + '_' + '.').setParseAction(AddLabel)
  pos_int = pp.Word(pp.nums).setParseAction(AddInteger)
  order_label = (push_label +
                 pp.Optional((asc_kw | desc_kw).setParseAction(AddLast)))
  label = pp.Word(pp.alphas, pp.alphas + pp.nums + '_' + '.')
  alias_label = pp.Word(
      pp.alphas, pp.alphas + pp.nums + '_' + '.').setParseAction(AddAlias)
  within_label = pp.Word(
      pp.alphas, pp.alphas + pp.nums + '_' + '.').setParseAction(AddWithin)

  math_expr = _MathParser(temp_stack)
  within_expr = math_expr + pp.Optional(within_kw + within_label)
  alias_expr = within_expr + pp.Optional((
      (as_kw + alias_label) |
      (~from_kw + ~where_kw + ~having_kw + ~order_kw + ~group_kw + ~limit_kw +
       alias_label)))
  select_expr = (
      (select_kw + alias_expr).setParseAction(AddSelectArgument) +
      pp.ZeroOrMore((pp.Literal(',') + alias_expr).setParseAction(
          AddSelectArgument)))
  flatten_expr = (pp.OneOrMore(pp.Literal('(') + flatten_kw + pp.Literal('(') +
                               label + pp.Literal(',') + label +
                               pp.Literal(')') + pp.Literal(
                                   ')'))).setParseAction(AddAll)
  # TODO(user): Add join.
  from_expr = select_expr + pp.Optional((
      from_kw + (flatten_expr | push_label)).setParseAction(AddArgument))
  where_expr = from_expr + pp.Optional((
      where_kw + _MathParser(temp_stack)).setParseAction(AddArgument))
  having_expr = where_expr + pp.Optional((
      having_kw + _MathParser(temp_stack)).setParseAction(AddArgument))
  group_expr = having_expr + pp.Optional((
      group_kw + push_label + pp.ZeroOrMore(
          pp.Literal(',') + push_label)).setParseAction(AddArgument))
  order_expr = group_expr + pp.Optional((
      order_kw + order_label + pp.ZeroOrMore(
          pp.Literal(',') + order_label)).setParseAction(AddArgument))
  limit_expr = order_expr + pp.Optional((
      limit_kw + pos_int).setParseAction(AddArgument))
  entire_expr = limit_expr + pp.StringEnd()

  return entire_expr
Testing FileAttachmentReviewUI sandboxes get_js_view_data
dataset/ETHPy150Open google/encrypted-bigquery-client/src/query_parser.py/_EBQParser--crossover with--dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/reviews/ui/tests.py/SandboxTests.test_get_js_view_data