Function opg::get_terminals[][src]

pub(crate) fn get_terminals(
    productions: &Vec<Production>,
    nts: &HashSet<String>
) -> HashSet<String>

Get terminals

Input

productions the vector of struct Production

nts the non-terminal set, which could be generated from the function get_non_terminals().

Output

The hashset contains terminals.

Example

let nts = get_non_terminals(&productions);
let ts = get_terminals(&productions, &nts);

Principles

To avoid repetative computing, receive the pre-computed non-terminal set and eliminate them among the candidates on the right side in each production.