def _build_rule_table(bnf_grammar_ast, terminals, skip):
    """
    Args:
      bnf_grammar_ast: grammar on bnf ast form produced by _ebnf_grammar_to_bnf
      terminals (list): list of terminals of the language

    Returns:
      A dict that maps every non-terminal to a list of 
      right hand sides of production rules from that non-terminal.
    """
    rule_table = {}    
    for rule in bnf_grammar_ast:
        lhs = rule[0]
        rhs = rule[1]
        if lhs in terminals or lhs in skip:
            continue        
        if lhs not in rule_table:
            rule_table[lhs] = []
        rule_table[lhs] += [rhs]        
    return rule_table