00001 #ifndef _LABELSYNTAXCHECKER_H_23546777390_ 00002 #define _LABELSYNTAXCHECKER_H_23546777390_ 00003 00004 #include "stringProcessor.h" 00005 #include "itransition.h" 00006 00007 /*! 00008 * Syntax checker implemented by recursive descending method. 00009 * Computes characters and gives pattern used in label text. 00010 * If fails, report is available. 00011 * \param characterList (created by StringProcessor) 00012 * \sa StringProcessor 00013 */ 00014 class LabelSyntaxChecker 00015 { 00016 public: 00017 enum ELabelTextPattern { eEmptyPattern = 0, 00018 eNormalPattern, 00019 eAlphabetMinusPattern, 00020 eBarPattern, 00021 eAlphabetPattern, 00022 eEpsilonSymbPattern }; 00023 00024 LabelSyntaxChecker(const ITransition::TCharSet &alphabet, 00025 const QString &alphabetSymb, 00026 const QString &epsilonSymb); 00027 00028 ~LabelSyntaxChecker() {} 00029 00030 QString getReport(); 00031 ITransition::TCharSet getCharacters(); 00032 ELabelTextPattern getPattern(); 00033 00034 //! starts recursive descent 00035 bool checkSyntax(const StringProcessor::TCharacterList &characterList); 00036 00037 protected: 00038 //! return next CharacterInfo from input list and 00039 StringProcessor::CharacterInfo nextToken(); 00040 bool hasNextToken(); 00041 00042 const ITransition::TCharSet m_alphabet; 00043 const QString m_alphabetSymb; 00044 const QString m_epsilonSymb; 00045 StringProcessor::TCharacterList m_characterList; 00046 int m_idx; 00047 00048 ITransition::TCharSet characters; 00049 ELabelTextPattern pattern; 00050 QStringList report; 00051 00052 //! adds character to charSet and check if it's in alphabet 00053 bool processCharacter(ITransition::TCharSet &charSet, 00054 const StringProcessor::CharacterInfo &charInfo); 00055 //! adds barred character to charSet and check if it's in alphabet 00056 bool processBarredCharacter(ITransition::TCharSet &charSet, 00057 const StringProcessor::CharacterInfo &charInfo); 00058 00059 //! recursive descent methods 00060 bool NormalPattern(ITransition::TCharSet &charSet); 00061 bool NormalPatternNext(ITransition::TCharSet &charSet); 00062 bool BarPattern(); 00063 bool BarPatternNext(); 00064 bool AlphabetOrAlphabetMinusPattern(); 00065 bool End(); 00066 }; 00067 00068 #endif //_LABELSYNTAXCHECKER_H_23546777390_