Function opg::gen_lastvt[][src]

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

Generate LASTVT 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

lastvt the set of LASTVT for all terminals.

Example

 let lastvt:HashMap<String, HashSet<String>> = gen_lastvt(&productions, &nts);

Principles

Go through every production and search the following patterns:

  1. U => xU_1
  2. U => xTU_1
  3. U => xT

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