* @return the first and last GrammarNodes of the network
*/
private GrammarGraph processRuleSequence(JSGFRuleSequence ruleSequence)
throws JSGFGrammarException {
GrammarNode startNode = null;
GrammarNode endNode = null;
logger.fine("parseRuleSequence: " + ruleSequence);
List<JSGFRule> rules = ruleSequence.getRules();
GrammarNode lastGrammarNode = null;
// expand and connect each rule in the sequence serially
for (int i = 0; i < rules.size(); i++) {
JSGFRule rule = rules.get(i);
GrammarGraph newNodes = processRule(rule);
// first node
if (i == 0) {
startNode = newNodes.getStartNode();
}
// last node
if (i == (rules.size() - 1)) {
endNode = newNodes.getEndNode();
}
if (i > 0) {
lastGrammarNode.add(newNodes.getStartNode(), 0.0f);
}
lastGrammarNode = newNodes.getEndNode();
}
return new GrammarGraph(startNode, endNode);