Function opg::gen_firstvt[][src]

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

Generate FIRSTVT set for every non-terminals.

Input

productions the vector of struct Production

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

Return

firstvt the set of FIRSTVT for all terminals.

Example

 let firstvt:HashMap<String, HashSet<String>> = gen_firstvt(&productions, &nts);

Principles

Go through every production and search the following patterns:

  1. U => U_1y
  2. U => U_1Ty
  3. U => Ty

call dfs::compose_element() to get the final result.