diff options
-rw-r--r-- | generator/generator.cpp | 3 | ||||
-rw-r--r-- | generator/group.cpp | 4 | ||||
-rw-r--r-- | generator/group.h | 1 | ||||
-rw-r--r-- | generator/lemma.cpp | 8 | ||||
-rw-r--r-- | generator/pronunciation.h | 14 | ||||
-rw-r--r-- | generator/word.h | 14 |
6 files changed, 26 insertions, 18 deletions
diff --git a/generator/generator.cpp b/generator/generator.cpp index 785ec87..e52aa90 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp | |||
@@ -242,8 +242,7 @@ namespace verbly { | |||
242 | { | 242 | { |
243 | adj.setAdjectivePosition(positioning::postnominal); | 243 | adj.setAdjectivePosition(positioning::postnominal); |
244 | } else { | 244 | } else { |
245 | // Can't happen because of how we specified the regex. | 245 | throw std::logic_error("adjpos_str invalid"); |
246 | assert(false); | ||
247 | } | 246 | } |
248 | } | 247 | } |
249 | } | 248 | } |
diff --git a/generator/group.cpp b/generator/group.cpp index 1ffb9d9..0e609e9 100644 --- a/generator/group.cpp +++ b/generator/group.cpp | |||
@@ -144,8 +144,8 @@ namespace verbly { | |||
144 | 144 | ||
145 | case part::type::invalid: | 145 | case part::type::invalid: |
146 | { | 146 | { |
147 | // Invalid parts should not be serialized. | 147 | throw std::invalid_argument( |
148 | assert(false); | 148 | "Invalid parts should not be serialized"); |
149 | 149 | ||
150 | break; | 150 | break; |
151 | } | 151 | } |
diff --git a/generator/group.h b/generator/group.h index f912920..c8e30e4 100644 --- a/generator/group.h +++ b/generator/group.h | |||
@@ -4,7 +4,6 @@ | |||
4 | #include <map> | 4 | #include <map> |
5 | #include <set> | 5 | #include <set> |
6 | #include <string> | 6 | #include <string> |
7 | #include <cassert> | ||
8 | #include <list> | 7 | #include <list> |
9 | #include <hkutil/database.h> | 8 | #include <hkutil/database.h> |
10 | #include "role.h" | 9 | #include "role.h" |
diff --git a/generator/lemma.cpp b/generator/lemma.cpp index 33ab037..a64e43b 100644 --- a/generator/lemma.cpp +++ b/generator/lemma.cpp | |||
@@ -1,6 +1,6 @@ | |||
1 | #include "lemma.h" | 1 | #include "lemma.h" |
2 | #include <list> | 2 | #include <list> |
3 | #include <cassert> | 3 | #include <stdexcept> |
4 | #include "form.h" | 4 | #include "form.h" |
5 | 5 | ||
6 | namespace verbly { | 6 | namespace verbly { |
@@ -17,8 +17,10 @@ namespace verbly { | |||
17 | 17 | ||
18 | void lemma::addInflection(inflection type, const form& f) | 18 | void lemma::addInflection(inflection type, const form& f) |
19 | { | 19 | { |
20 | // There can only be one base form. | 20 | if (type == inflection::base) |
21 | assert(type != inflection::base); | 21 | { |
22 | throw std::invalid_argument("There can only be one base form"); | ||
23 | } | ||
22 | 24 | ||
23 | inflections_[type].insert(&f); | 25 | inflections_[type].insert(&f); |
24 | } | 26 | } |
diff --git a/generator/pronunciation.h b/generator/pronunciation.h index 163e55e..3190e6d 100644 --- a/generator/pronunciation.h +++ b/generator/pronunciation.h | |||
@@ -2,8 +2,8 @@ | |||
2 | #define PRONUNCIATION_H_584A08DD | 2 | #define PRONUNCIATION_H_584A08DD |
3 | 3 | ||
4 | #include <string> | 4 | #include <string> |
5 | #include <cassert> | ||
6 | #include <hkutil/database.h> | 5 | #include <hkutil/database.h> |
6 | #include <stdexcept> | ||
7 | 7 | ||
8 | namespace verbly { | 8 | namespace verbly { |
9 | namespace generator { | 9 | namespace generator { |
@@ -34,16 +34,20 @@ namespace verbly { | |||
34 | 34 | ||
35 | std::string getRhymePhonemes() const | 35 | std::string getRhymePhonemes() const |
36 | { | 36 | { |
37 | // Calling code should always call hasRhyme first. | 37 | if (rhyme_.empty()) |
38 | assert(!rhyme_.empty()); | 38 | { |
39 | throw std::domain_error("Pronunciation does not have a rhyme"); | ||
40 | } | ||
39 | 41 | ||
40 | return rhyme_; | 42 | return rhyme_; |
41 | } | 43 | } |
42 | 44 | ||
43 | std::string getPrerhyme() const | 45 | std::string getPrerhyme() const |
44 | { | 46 | { |
45 | // Calling code should always call hasRhyme first. | 47 | if (rhyme_.empty()) |
46 | assert(!rhyme_.empty()); | 48 | { |
49 | throw std::domain_error("Pronunciation does not have a rhyme"); | ||
50 | } | ||
47 | 51 | ||
48 | return prerhyme_; | 52 | return prerhyme_; |
49 | } | 53 | } |
diff --git a/generator/word.h b/generator/word.h index 2e469d4..2818202 100644 --- a/generator/word.h +++ b/generator/word.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef WORD_H_91F99D46 | 1 | #ifndef WORD_H_91F99D46 |
2 | #define WORD_H_91F99D46 | 2 | #define WORD_H_91F99D46 |
3 | 3 | ||
4 | #include <cassert> | 4 | #include <stdexcept> |
5 | #include <hkutil/database.h> | 5 | #include <hkutil/database.h> |
6 | #include "../lib/enums.h" | 6 | #include "../lib/enums.h" |
7 | 7 | ||
@@ -61,8 +61,10 @@ namespace verbly { | |||
61 | 61 | ||
62 | int getTagCount() const | 62 | int getTagCount() const |
63 | { | 63 | { |
64 | // Calling code should always call hasTagCount first. | 64 | if (!hasTagCount_) |
65 | assert(hasTagCount_); | 65 | { |
66 | throw std::domain_error("Word does not have a tag count"); | ||
67 | } | ||
66 | 68 | ||
67 | return tagCount_; | 69 | return tagCount_; |
68 | } | 70 | } |
@@ -79,8 +81,10 @@ namespace verbly { | |||
79 | 81 | ||
80 | const group& getVerbGroup() const | 82 | const group& getVerbGroup() const |
81 | { | 83 | { |
82 | // Calling code should always call hasVerbGroup first. | 84 | if (!hasVerbGroup()) |
83 | assert(verbGroup_ != nullptr); | 85 | { |
86 | throw std::domain_error("Word does not have a verb group"); | ||
87 | } | ||
84 | 88 | ||
85 | return *verbGroup_; | 89 | return *verbGroup_; |
86 | } | 90 | } |