if ((violations!=null) && (violations.getViolationCount()>0))
throw new IllegalArgumentException("Lexicon is not valid: "+violations.getViolation(0));
LexicalAutomaton automaton = new LexicalAutomaton(lexicon.getLexemeCount());
Lexeme lexeme;
PatternAutomaton definition = null;
for (int i = 0; i<lexicon.getLexemeCount(); i++)
{
lexeme = lexicon.getLexeme(i);
automaton.setLexemeSymbol(i, (lexeme.getSymbol()!=null) ? lexeme.getSymbol().getName() : null);
definition = (new PatternAutomatonBuilder(lexeme.getDefinition())).getPatternAutomaton();
if (definition!=null)
automaton.setLexemeDefinition(i, definition);
else
throw new IllegalArgumentException("Couldn't create PatternAutomaton for "+
lexeme.getSymbol()+" of \""+lexeme.getDefinition()+"\"");
}
this.automaton = automaton;
}