def is_allowed(symbols, allowed_terminals):
  """Returns True if the token is a nonterminal or an allowed terminal."""
  for token in symbols:
    if token not in NT_SET and token not in allowed_terminals:
      return False
  return True
Returns True if the token is a nonterminal or an allowed terminal.
language/compgen/csl/qcfg/qcfg_rule.py