Skip to content
Snippets Groups Projects
Commit 8aa47d3a authored by Adam Wardynski's avatar Adam Wardynski
Browse files

Keep file name with Lexicon.

parent a5674e4b
No related merge requests found
...@@ -53,10 +53,10 @@ private: ...@@ -53,10 +53,10 @@ private:
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
parse_lexicon_file parse_lexicon_file
[const std::string& name] [const std::string& name, const std::string& file_name]
returns [boost::shared_ptr<Lexicon> lex] returns [boost::shared_ptr<Lexicon> lex]
{ {
lex.reset(new Lexicon(name)); lex.reset(new Lexicon(name, file_name));
} }
: (lexicon_entry [*lex])* : (lexicon_entry [*lex])*
EOF EOF
......
...@@ -14,8 +14,9 @@ class Lexicon : boost::noncopyable ...@@ -14,8 +14,9 @@ class Lexicon : boost::noncopyable
public: public:
typedef boost::unordered_map<UnicodeString, UnicodeString> map_t; typedef boost::unordered_map<UnicodeString, UnicodeString> map_t;
Lexicon(const std::string& name) Lexicon(const std::string& name, const std::string& file_name)
: name_(name) : name_(name),
file_name_(file_name_)
{ {
BOOST_ASSERT(!name_.empty()); BOOST_ASSERT(!name_.empty());
} }
...@@ -40,6 +41,10 @@ public: ...@@ -40,6 +41,10 @@ public:
return name_; return name_;
} }
std::string file_name() const {
return file_name_;
}
bool has_key(const UnicodeString& key) const { bool has_key(const UnicodeString& key) const {
return map_.find(key) != map_.end(); return map_.find(key) != map_.end();
} }
...@@ -55,6 +60,7 @@ public: ...@@ -55,6 +60,7 @@ public:
private: private:
map_t map_; map_t map_;
const std::string name_; const std::string name_;
const std::string file_name_;
}; };
} /* end ns Wccl */ } /* end ns Wccl */
......
...@@ -22,7 +22,7 @@ boost::shared_ptr<Lexicon> LexiconParser::parse_lexicon( ...@@ -22,7 +22,7 @@ boost::shared_ptr<Lexicon> LexiconParser::parse_lexicon(
ANTLRLexiconLexer lexer(is); ANTLRLexiconLexer lexer(is);
ANTLRLexiconParser parser(lexer); ANTLRLexiconParser parser(lexer);
return parser.parse_lexicon_file(lexicon_name); return parser.parse_lexicon_file(lexicon_name, filename);
} }
} /* end ns Wccl */ } /* end ns Wccl */
...@@ -26,6 +26,10 @@ public: ...@@ -26,6 +26,10 @@ public:
void insert(const boost::shared_ptr<Lexicon>& lexicon); void insert(const boost::shared_ptr<Lexicon>& lexicon);
const map_t& get_lexicons() const {
return lexicons_;
}
private: private:
map_t lexicons_; map_t lexicons_;
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment