Module GenerationEngine.productionCoverage
Production coverage implementation.
The module implements the production coverage criterion. The main idea to the algorithm is create a set of test requiremets, the goalSymbols, and for each requirement that will be satisfied by the process it is removed from the intial set. At the end of the process we check the number of inital requirements over the final ones and calculate the coverage rate.
The main process has the following steps:
- The basic structures are computed on the event initGen. These structures are: productions and PRules. Currently, the goalSymbols is defined with all production rules, but it is also possible to define another intial set.
- The events checkNonTerminal and checkAlt are used to control the penSymbols set. These are also responsible to the optimization over the nonterminal and prodution rules expansion to restrict the execution of the algorithm over search spaces that don't contribute to the coverage criterion coverage.
- At the end of sentence generation, the checkSentence event is used to a final check over the sentence to see if it will be used or discarted.
- At the end of the process, the event finalizeGen is used to calculate the information about the achievement of the coverage criterion.
Dependencies: Util, TimeMachine, BenchTimer, Set, Relation, MetaInfo
Info:
- Author: Cleverton Hentz
Events
| finalizeGrammar | It happens after the reading of original grammar. |
| initGen | It happens before the generation process. |
| finalizeGen | Collect the information about the results |
| checkNonTerminal | Verify if the nonterminal contribute with a requirement. |
| checkSentence | Verify if the sentence contribute with a requirement. |
| checkAlt | Verify if the alternative contribute with a requirement. |
| checkOneOrMoreSep | Verify if the operator oneOrMoreSep contribute with a requirement. |
Fields
| productions | The table with all productions rules from the input grammar. |
| PRules | Table with the productions closure used by the algorithm. |
| mGrammar | A simplification of the input grammar used to calculate other structures. |
| goalSymbols | The set thats represents the test requirement set. |
| penSymbols | The set of production rules used by the derivation processe for the current sentence. |
| prodConfig | The configuration of the production coverage criterion |
| reachablePRCount | Number of reachable production rules from the start symbol. |
Local Functions
| constructAllProductions | Deprecated, Construct the production information to the algorithm. |
| calcPRules | Deprecated, Construct the transitive and reflexive closure from production rules. |
| checkNeedContinue | Check if the algorithm should continue. |
| checkGrammar | Check if there are some grammar inconsistency |
| convertProdSet | Convert internal representation of production from Array to Set. |
| calcReachablePR | calculate the reachable production rules from the start symbol |
| genMetaGrammar | Generate information from the actual grammar to the algorithm. |
Events
- finalizeGrammar
-
It happens after the reading of original grammar.
- MG A meta-grammar
See also:
- initGen
-
It happens before the generation process. On this function are created the basic structures to the algorithm:
- productions table is used to store the productions rules for the grammar;
- PRules table is used to store the production closure;
- goalSymbols set is used to define the productions' set used as goal to the algorithm.
See also:
- finalizeGen
-
Collect the information about the results
See also:
- checkNonTerminal
-
Verify if the nonterminal contribute with a requirement.
See also:
- checkSentence
-
Verify if the sentence contribute with a requirement.
If the sentence has new requirements, its is added
to the result set and his requiriments are removed from
the goalSymbols set.
See also:
- checkAlt
-
Verify if the alternative contribute with a requirement.
If an alternative or production rule doesn't contribute to the
coverage satisfaction, it is not executed.
See also:
- checkOneOrMoreSep
-
Verify if the operator oneOrMoreSep contribute with a requirement.
See also:
Fields
- productions
- The table with all productions rules from the input grammar.
- PRules
- Table with the productions closure used by the algorithm.
- mGrammar
- A simplification of the input grammar used to calculate other structures.
- goalSymbols
- The set thats represents the test requirement set.
- penSymbols
- The set of production rules used by the derivation processe for the current sentence.
- prodConfig
- The configuration of the production coverage criterion
- reachablePRCount
- Number of reachable production rules from the start symbol.
Local Functions
- constructAllProductions
-
Deprecated, Construct the production information to the algorithm.
Parameters:
- prods table Table of productions.
Returns:
-
table
Return a table with
<NonTerminal>#<Index>syntax. - calcPRules
-
Deprecated, Construct the transitive and reflexive closure from production rules.
Parameters:
- prods table Table of productions.
Returns:
-
table
Return a table with
[<NonTerminal>] = {<NonTerminal>#<Index>}syntax.See also:
- checkNeedContinue
-
Check if the algorithm should continue.
Check is based on the PRules table and goalSymbols set.
Parameters:
- nonTerminal string NT to verify.
- index number Production index to verify
Returns:
-
{nil,number,bool}
It is OK or not ot go.
- checkGrammar
-
Check if there are some grammar inconsistency
Parameters:
- metaGrammar The meta-grammar
Returns:
- Is the grammar OK?
- If non OK, present a error message
- convertProdSet
-
Convert internal representation of production from Array to Set.
Parameters:
- prod
- calcReachablePR
-
calculate the reachable production rules from the start symbol
Parameters:
- start
- prodClosure
- genMetaGrammar
-
Generate information from the actual grammar to the algorithm.
Parameters:
- G table The grammar received after the transformation process.
- maxTreeHeight number The maximum derivation tree height from runtime configuration.
Returns:
-
table
Return a table with the fields:
Terminals: (Set)NTerminals: (Set)startSymbol: (String)Productions: (table)ClosureProductions: (table)