--- a
+++ b/trunk/Soul/Soul.Parsing/Keyword.hpp
@@ -0,0 +1,102 @@
+/*========================================================================
+    Copyright (c) 2011 Seppo Laakko
+    http://sourceforge.net/projects/soulparsing/
+ 
+    Distributed under the GNU General Public License, version 3 (GPLv3).
+    (See accompanying LICENSE.txt or http://www.gnu.org/licenses/gpl.html)
+
+========================================================================*/
+
+#ifndef SOUL_PARSING_KEYWORD_INCLUDED
+#define SOUL_PARSING_KEYWORD_INCLUDED
+#include <Soul.Parsing/Rule.hpp>
+#include <boost/unordered_set.hpp>
+
+namespace Soul { namespace Parsing {
+
+class IdentifierCharsRule : public RuleParser
+{
+public:
+    static RuleParserPtr Instance();
+};
+
+class KeywordParser : public Parser
+{
+public:
+    KeywordParser(const String& keyword_);
+    KeywordParser(const String& keyword_, const String& continuationRuleName_);
+    const String& Keyword() const { return keyword; }
+    const String& ContinuationRuleName() const { return continuationRuleName; }
+    void SetContinuationRule(const RuleParserPtr& continuationRule_);
+    virtual Match Parse(Scanner& scanner, ObjectStack& stack);
+    virtual void Accept(Visitor& visitor);
+private:
+    String keyword;
+    String continuationRuleName;
+    RuleParserPtr continuationRule;
+    ParserPtr keywordStringParser;
+    RuleParserPtr keywordRule;
+    void CreateKeywordRule();
+};
+
+class KeywordListParser : public Parser
+{
+public:
+    typedef boost::unordered_set<String> KeywordSet;
+    typedef KeywordSet::const_iterator KeywordSetIt;
+    KeywordListParser(const String& selectorRuleName_, const std::vector<String>& keywords_);
+    const String& SelectorRuleName() const { return selectorRuleName; }
+    const String& KeywordVecName() const { return keywordVecName; }
+    String& KeywordVecName() { return keywordVecName; }
+    const KeywordSet& Keywords() const { return keywords; }
+    void SetSelectorRule(const RuleParserPtr& selectorRule_) { selectorRule = selectorRule_; }
+    virtual Match Parse(Scanner& scanner, ObjectStack& stack);
+    virtual void Accept(Visitor& visitor);
+private:
+    String selectorRuleName;
+    String keywordVecName;
+    KeywordSet keywords;
+    RuleParserPtr selectorRule;
+};
+
+class KeywordRule
+{
+public:
+    KeywordRule(): keyword(), ruleName(), rule() {}
+    KeywordRule(const String& keyword_, const String& ruleName_): keyword(keyword_), ruleName(ruleName_) {}
+    const String& Keyword() const { return keyword; }
+    const String& RuleName() const { return ruleName; }
+    const RuleParserPtr& Rule() const { return rule; }
+    RuleParserPtr& Rule() { return rule; }
+private:
+    String keyword;
+    String ruleName;
+    RuleParserPtr rule;
+};
+
+class KeywordRuleListParser : public Parser
+{
+public:
+    typedef std::vector<KeywordRule> KeywordRuleVector;
+    KeywordRuleListParser(const String& selectorRuleName_, const KeywordRuleVector& keywordRules_);
+    const String& SelectorRuleName() const { return selectorRuleName; }
+    const String& KeywordRuleVecName() const { return keywordRuleVecName; }
+    String& KeywordRuleVecName() { return keywordRuleVecName; }
+    const KeywordRuleVector& KeywordRules() const { return keywordRules; }
+    void SetSelectorRule(const RuleParserPtr& selectorRule_) { selectorRule = selectorRule_; }
+    void SetKeywordRule(const String& keyword, const RuleParserPtr& rule);
+    virtual Match Parse(Scanner& scanner, ObjectStack& stack);
+    virtual void Accept(Visitor& visitor);
+private:
+    String selectorRuleName;
+    String keywordRuleVecName;
+    KeywordRuleVector keywordRules;
+    RuleParserPtr selectorRule;
+    typedef boost::unordered_map<String, KeywordRule> KeywordRuleMap;
+    typedef KeywordRuleMap::iterator KeywordRuleMapIt;
+    KeywordRuleMap keywordRuleMap;
+};
+
+} } // namespace Soul.Parsing
+
+#endif // SOUL_PARSING_KEYWORD_INCLUDED