Function parol::analysis::k_decision::decidable

source ยท
pub fn decidable(
    grammar_config: &GrammarConfig,
    non_terminal: &str,
    max_k: usize,
    first_cache: &FirstCache,
    follow_cache: &FollowCache,
) -> Result<usize>
Expand description

Calculates if for a certain non-terminal of grammar cfg the production to use can be determined deterministically with at maximum max_k lookahead. To accomplish this, for all productions of the given non-terminal k-tuples of at most length k are generated, starting with k=1. If all k-tuples are distinct between all productions the number k is returned. Otherwise the value of k is incremented by 1 and the process is retried. If k_max is exceeded the function returns an error.