From 0fae6fed47ec6565441ec5daab09081e20e00334 Mon Sep 17 00:00:00 2001 From: Ahmed Siam Date: Sat, 21 Oct 2023 10:22:02 +0300 Subject: [PATCH] renaming errors --- Makefile.am | 4 +- configure.ac | 1 - locales/Makefile.am | 6 +- locales/root.txt | 150 ++++++++++++++++++------------------- src/Makefile.am | 2 +- src/icu-iter.cc | 4 +- src/lexd.cc | 10 +-- src/lexdcompiler.cc | 176 ++++++++++++++++++++++---------------------- src/lexdcompiler.h | 4 +- 9 files changed, 178 insertions(+), 179 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4db3c4f..f673c34 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,6 +17,6 @@ $(check_targets): check-%: all tests/feature + make -C tests/feature O=$* LEXD_TEST_FLAGS="$$(echo '$*' | grep -v plain | sed 's/^\|-/ --/g')" check + make -C tests/feature O=$* clean -export LTTB_I18N_DATA=$(datadir)/lttoolbox/lttoolbox.dat +export ALT_I18N_DATA=$(datadir)/lttoolbox/lttoolbox.dat export LOCALES_DIR=$(datadir)/$(PACKAGE_NAME) -export LEXD_I18N_DATA=$(LOCALES_DIR)/lexd.dat +export AXD_I18N_DATA=$(LOCALES_DIR)/axd.dat diff --git a/configure.ac b/configure.ac index 8eb01e4..ef66f18 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,6 @@ AC_ARG_ENABLE(debug, PKG_CHECK_MODULES([LTTOOLBOX], [lttoolbox >= 3.7.1]) PKG_CHECK_MODULES([ICU_UC], [icu-uc]) PKG_CHECK_MODULES([ICU_IO], [icu-io]) -PKG_CHECK_MODULES(I18N, [i18n], CPPFLAGS="$CPPFLAGS $I18N_CFLAGS"; LIBS="$LIBS $I18N_LIBS") AC_CHECK_FUNCS([getopt_long]) diff --git a/locales/Makefile.am b/locales/Makefile.am index 8434e03..aea62f3 100755 --- a/locales/Makefile.am +++ b/locales/Makefile.am @@ -1,7 +1,7 @@ -lexd.dat: root.txt en.txt +axd.dat: root.txt en.txt genrb -d . root.txt en.txt echo root.res en.res > package_list.txt - pkgdata -p lexd --mode archive -d . package_list.txt + pkgdata -p axd --mode archive -d . package_list.txt localesdir = $(LOCALES_DIR) -dist_locales_DATA = lexd.dat +dist_locales_DATA = axd.dat diff --git a/locales/root.txt b/locales/root.txt index f52146e..93a95c6 100755 --- a/locales/root.txt +++ b/locales/root.txt @@ -14,79 +14,79 @@ root{ on_line{"On line {line}: } bad_tag{"Bad tag \"-{tag}\""} - LEXD1000{"ERROR LEXD1000: Failed to create character iterator with code {code}"} - LEXD1001{"ERROR LEXD1001: Unable to access \"{file}\"."} - LEXD1002{"WARNING LEXD1002: Output is empty transducer."} - LEXD1003{"ERROR LEXD1003: Lexicon {lexicon} is empty."} - LEXD1004{"ERROR LEXD1004: Unnamed pattern or lexicon."} - LEXD1005{"ERROR LEXD1005: Lexicon/pattern names cannot contain character \"{char}\""} - LEXD1006{"ERROR LEXD1006: Cannot declare negative tag in lexicon"} - LEXD1007{"ERROR LEXD1007: Empty tag at char {char}"} - LEXD1008{"ERROR LEXD1008: Illegal tag filter."} - LEXD1009{"ERROR LEXD1009: Illegal negated operation."} - LEXD1010{"ERROR LEXD1010: Expected list of operands."} - LEXD1011{"ERROR LEXD1011: End of line in tag list, expected \"]\""} - LEXD1012{"ERROR LEXD1012: Multichar symbol didn't end; searching for {end}"} - LEXD1013{"ERROR LEXD1013: Quantifier {quantifier} may only be applied to parenthesized groups"} - LEXD1014{"ERROR LEXD1014: Regex contains mismatched ]"} - LEXD1015{"ERROR LEXD1015: Regex contains multiple colons"} - LEXD1016{"ERROR LEXD1016: Cannot process symbol range between multichar symbols"} - LEXD1017{"ERROR LEXD1017: First character in symbol range does not preceed last"} - LEXD1018{"ERROR LEXD1018: Mismatched parentheses in regex"} - LEXD1019{"ERROR LEXD1019: Unterminated regex"} - LEXD1020{"ERROR LEXD1020: Expected {num1} parts, found {num2}"} - LEXD1021{"ERROR LEXD1021: Already provided tag list for this side."} - LEXD1022{"ERROR LEXD1022: Lexicon entry contains multiple colons"} - LEXD1023{"ERROR LEXD1023: Lexicon entry contains both regex and text"} - LEXD1024{"ERROR LEXD1024: Negative tag has no default to unset."} - LEXD1025{"ERROR LEXD1025: Symbol \"{symbol}\" without lexicon name at u16 {begin}-{end}"} - LEXD1026{"ERROR LEXD1026: Syntax error - non-numeric index in parentheses: {index}"} - LEXD1027{"ERROR LEXD1027: Syntax error - unmatched parenthesis"} - LEXD1028{"ERROR LEXD1028: Syntax error - missing index in parenthesis"} - LEXD1029{"ERROR LEXD1029: Syntax error - double colon"} - LEXD1030{"ERROR LEXD1030: Colon without lexicon or pattern name"} - LEXD1031{"ERROR LEXD1031: Unexpected symbol \"{symbol}\" at column {col}"} - LEXD1032{"ERROR LEXD1032: Syntax error - initial |"} - LEXD1033{"ERROR LEXD1033: Syntax error - multiple consecutive |"} - LEXD1034{"ERROR LEXD1034: Syntax error - sieve and alternation operators without intervening token"} - LEXD1035{"ERROR LEXD1035: Syntax error - cannot sieve backwards after forwards."} - LEXD1036{"ERROR LEXD1036: Backward sieve without token?"} - LEXD1037{"ERROR LEXD1037: Syntax error - multiple consecutive sieve operators"} - LEXD1038{"ERROR LEXD1038: Syntax error - alternation and sieve operators without intervening token"} - LEXD1039{"ERROR LEXD1039: Forward sieve without token?"} - LEXD1040{"ERROR LEXD1040: Missing closing ] for anonymous lexicon"} - LEXD1041{"ERROR LEXD1041: Missing closing ) for anonymous pattern"} - LEXD1042{"ERROR LEXD1042: Syntax error - unexpected modifier at u16 {start}-{end}"} - LEXD1043{"ERROR LEXD1043: Syntax error - trailing |"} - LEXD1044{"ERROR LEXD1044: Syntax error - trailing sieve (< or >)"} - LEXD1045{"ERROR LEXD1045: Trailing backslash"} - LEXD1046{"ERROR LEXD1046: The name \"{name}\" cannot be used for both LEXICONs and PATTERNs."} - LEXD1047{"ERROR LEXD1047: Expected start of default right tags \"[\" after \":\"."} - LEXD1048{"ERROR LEXD1048: Unexpected character \"{char}\" after default tags."} - LEXD1049{"ERROR LEXD1049: Unnamed lexicon"} - LEXD1050{"ERROR LEXD1050: The name \"{name}\" cannot be used for both LEXICONs and PATTERNs."} - LEXD1051{"ERROR LEXD1051: Multiple incompatible definitions for lexicon \"{lexicon}\"."} - LEXD1052{"ERROR LEXD1052: Expected \"ALIAS lexicon alt_name\""} - LEXD1053{"ERROR LEXD1053: Attempt to alias undefined lexicon \"{lexicon}\"."} - LEXD1054{"ERROR LEXD1054: Unexpected {symbol}"} - LEXD1055{"ERROR LEXD1055: Lexicon entry has \"{symbol}\" (found at u16 {num1}), more than {num2} components"} - LEXD1056{"ERROR LEXD1056: Expected \"PATTERNS\" or \"LEXICON\""} - LEXD1057{"ERROR LEXD1057: Cannot select part of pattern {pattern}"} - LEXD1058{"ERROR LEXD1058: Cannot collate pattern {pattern1} with {pattern2}"} - LEXD1059{"ERROR LEXD1059: Cannot select side of pattern {pattern}"} - LEXD1060{"ERROR LEXD1060: Cannot collate lexicon {lexicon} with pattern {pattern}"} - LEXD1061{"ERROR LEXD1061: Cannot collate pattern {pattern} with lexicon {lexicon}"} - LEXD1062{"ERROR LEXD1062: Lexicon or pattern \"{lex_pat}\" is not defined."} - LEXD1063{"ERROR LEXD1063: Cannot collate {left} with {right} - both appear in free variation earlier in the pattern."} - LEXD1064{"ERROR LEXD1064: Lexicon {lexicon} cannot be both optional and non-optional in a single pattern."} - LEXD1065{"ERROR LEXD1065: Cannot build collated pattern {pattern}"} - LEXD1066{"ERROR LEXD1066: Cannot compile self-recursive pattern \"{pattern}\""} - LEXD1067{"ERROR LEXD1067: {lexicon}({part}) - part is out of range"} - LEXD1068{"ERROR LEXD1068: Cannot collate {left} with {right} - differing numbers of entries"} - LEXD1069{"ERROR LEXD1069: Cannot use {lexicon} one-sided - it contains a regex"} - LEXD1070{"ERROR LEXD1070: Cannot collate {left} with {right} - {something} contains a regex"} - LEXD1071{"WARNING LEXD1071: One-sided tags are deprecated and will soon be removed (line {line})"} - LEXD1072{"WARNING LEXD1072: The tags of {pattern1} conflict with {pattern2} on line {line}."} - LEXD1073{"WARNING LEXD1073: {pattern} is empty."} - LEXD1074{"WARNING LEXD1074: No non-empty patterns found."} + AXD80000{"ERROR AXD80000: Failed to create character iterator with code {code}"} + AXD80010{"ERROR AXD80010: Unable to access \"{file}\"."} + AXD60020{"WARNING AXD60020: Output is empty transducer."} + AXD80030{"ERROR AXD80030: Lexicon {lexicon} is empty."} + AXD80040{"ERROR AXD80040: Unnamed pattern or lexicon."} + AXD80050{"ERROR AXD80050: Lexicon/pattern names cannot contain character \"{char}\""} + AXD80060{"ERROR AXD80060: Cannot declare negative tag in lexicon"} + AXD80070{"ERROR AXD80070: Empty tag at char {char}"} + AXD80080{"ERROR AXD80080: Illegal tag filter."} + AXD80090{"ERROR AXD80090: Illegal negated operation."} + AXD80100{"ERROR AXD80100: Expected list of operands."} + AXD80110{"ERROR AXD80110: End of line in tag list, expected \"]\""} + AXD80120{"ERROR AXD80120: Multichar symbol didn't end; searching for {end}"} + AXD80130{"ERROR AXD80130: Quantifier {quantifier} may only be applied to parenthesized groups"} + AXD80140{"ERROR AXD80140: Regex contains mismatched ]"} + AXD80150{"ERROR AXD80150: Regex contains multiple colons"} + AXD80160{"ERROR AXD80160: Cannot process symbol range between multichar symbols"} + AXD80170{"ERROR AXD80170: First character in symbol range does not preceed last"} + AXD80180{"ERROR AXD80180: Mismatched parentheses in regex"} + AXD80190{"ERROR AXD80190: Unterminated regex"} + AXD80200{"ERROR AXD80200: Expected {num1} parts, found {num2}"} + AXD80210{"ERROR AXD80210: Already provided tag list for this side."} + AXD80220{"ERROR AXD80220: Lexicon entry contains multiple colons"} + AXD80230{"ERROR AXD80230: Lexicon entry contains both regex and text"} + AXD80240{"ERROR AXD80240: Negative tag has no default to unset."} + AXD80250{"ERROR AXD80250: Symbol \"{symbol}\" without lexicon name at u16 {begin}-{end}"} + AXD80260{"ERROR AXD80260: Syntax error - non-numeric index in parentheses: {index}"} + AXD80270{"ERROR AXD80270: Syntax error - unmatched parenthesis"} + AXD80280{"ERROR AXD80280: Syntax error - missing index in parenthesis"} + AXD80290{"ERROR AXD80290: Syntax error - double colon"} + AXD80300{"ERROR AXD80300: Colon without lexicon or pattern name"} + AXD80310{"ERROR AXD80310: Unexpected symbol \"{symbol}\" at column {col}"} + AXD80320{"ERROR AXD80320: Syntax error - initial |"} + AXD80330{"ERROR AXD80330: Syntax error - multiple consecutive |"} + AXD80340{"ERROR AXD80340: Syntax error - sieve and alternation operators without intervening token"} + AXD80350{"ERROR AXD80350: Syntax error - cannot sieve backwards after forwards."} + AXD80360{"ERROR AXD80360: Backward sieve without token?"} + AXD80370{"ERROR AXD80370: Syntax error - multiple consecutive sieve operators"} + AXD80380{"ERROR AXD80380: Syntax error - alternation and sieve operators without intervening token"} + AXD80390{"ERROR AXD80390: Forward sieve without token?"} + AXD80400{"ERROR AXD80400: Missing closing ] for anonymous lexicon"} + AXD80410{"ERROR AXD80410: Missing closing ) for anonymous pattern"} + AXD80420{"ERROR AXD80420: Syntax error - unexpected modifier at u16 {start}-{end}"} + AXD80430{"ERROR AXD80430: Syntax error - trailing |"} + AXD80440{"ERROR AXD80440: Syntax error - trailing sieve (< or >)"} + AXD80450{"ERROR AXD80450: Trailing backslash"} + AXD80460{"ERROR AXD80460: The name \"{name}\" cannot be used for both LEXICONs and PATTERNs."} + AXD80470{"ERROR AXD80470: Expected start of default right tags \"[\" after \":\"."} + AXD80480{"ERROR AXD80480: Unexpected character \"{char}\" after default tags."} + AXD80490{"ERROR AXD80490: Unnamed lexicon"} + AXD80500{"ERROR AXD80500: The name \"{name}\" cannot be used for both LEXICONs and PATTERNs."} + AXD80510{"ERROR AXD80510: Multiple incompatible definitions for lexicon \"{lexicon}\"."} + AXD80520{"ERROR AXD80520: Expected \"ALIAS lexicon alt_name\""} + AXD80530{"ERROR AXD80530: Attempt to alias undefined lexicon \"{lexicon}\"."} + AXD80540{"ERROR AXD80540: Unexpected {symbol}"} + AXD80550{"ERROR AXD80550: Lexicon entry has \"{symbol}\" (found at u16 {num1}), more than {num2} components"} + AXD80560{"ERROR AXD80560: Expected \"PATTERNS\" or \"LEXICON\""} + AXD80570{"ERROR AXD80570: Cannot select part of pattern {pattern}"} + AXD80580{"ERROR AXD80580: Cannot collate pattern {pattern1} with {pattern2}"} + AXD80590{"ERROR AXD80590: Cannot select side of pattern {pattern}"} + AXD80600{"ERROR AXD80600: Cannot collate lexicon {lexicon} with pattern {pattern}"} + AXD80610{"ERROR AXD80610: Cannot collate pattern {pattern} with lexicon {lexicon}"} + AXD80620{"ERROR AXD80620: Lexicon or pattern \"{lex_pat}\" is not defined."} + AXD80630{"ERROR AXD80630: Cannot collate {left} with {right} - both appear in free variation earlier in the pattern."} + AXD80640{"ERROR AXD80640: Lexicon {lexicon} cannot be both optional and non-optional in a single pattern."} + AXD80650{"ERROR AXD80650: Cannot build collated pattern {pattern}"} + AXD80660{"ERROR AXD80660: Cannot compile self-recursive pattern \"{pattern}\""} + AXD80670{"ERROR AXD80670: {lexicon}({part}) - part is out of range"} + AXD80680{"ERROR AXD80680: Cannot collate {left} with {right} - differing numbers of entries"} + AXD80690{"ERROR AXD80690: Cannot use {lexicon} one-sided - it contains a regex"} + AXD80700{"ERROR AXD80700: Cannot collate {left} with {right} - {something} contains a regex"} + AXD60710{"WARNING AXD60710: One-sided tags are deprecated and will soon be removed (line {line})"} + AXD60720{"WARNING AXD60720: The tags of {pattern1} conflict with {pattern2} on line {line}."} + AXD60730{"WARNING AXD60730: {pattern} is empty."} + AXD60740{"WARNING AXD60740: No non-empty patterns found."} } diff --git a/src/Makefile.am b/src/Makefile.am index 3199db1..ddc86d5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ AM_LDFLAGS=$(LIBS) -AM_CPPFLAGS = -DLEXD_I18N_DATA='"$(LEXD_I18N_DATA)"' -DLTTB_I18N_DATA='"$(LTTB_I18N_DATA)"' +AM_CPPFLAGS = -DAXD_I18N_DATA='"$(AXD_I18N_DATA)"' -DALT_I18N_DATA='"$(ALT_I18N_DATA)"' bin_PROGRAMS = lexd diff --git a/src/icu-iter.cc b/src/icu-iter.cc index a4bee66..46a33d1 100644 --- a/src/icu-iter.cc +++ b/src/icu-iter.cc @@ -2,7 +2,7 @@ #include #include #include -#include +#include using namespace std; using namespace icu; @@ -12,7 +12,7 @@ charspan_iter::charspan_iter(const UnicodeString &s) it = BreakIterator::createCharacterInstance(Locale::getDefault(), _status); if(U_FAILURE(_status)) { - I18n(LEXD_I18N_DATA, "lexd").error("LEXD1000", {"code"}, {_status}, true); + I18n(AXD_I18N_DATA, "axd").error("AXD80000", {"code"}, {_status}, true); } it->setText(s); _span.first = it->first(); diff --git a/src/lexd.cc b/src/lexd.cc index 26a4ebb..9566235 100644 --- a/src/lexd.cc +++ b/src/lexd.cc @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -10,7 +10,7 @@ using namespace std; void endProgram(char *name) { - I18n i18n {LEXD_I18N_DATA, "lexd"}; + I18n i18n {AXD_I18N_DATA, "axd"}; if(name != NULL) { cout << i18n.format("lexd_desc", {"program", "version"}, {basename(name), VERSION}); @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) input = u_fopen(infile.c_str(), "rb", NULL, NULL); if(!input) { - I18n(LEXD_I18N_DATA, "lexd").error("LEXD1001", {"file"}, {infile.c_str()}, true); + I18n(AXD_I18N_DATA, "axd").error("AXD80010", {"file"}, {infile.c_str()}, true); } } @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) output = u_fopen(outfile.c_str(), "wb", NULL, NULL); if(!output) { - I18n(LEXD_I18N_DATA, "lexd").error("LEXD1001", {"file"}, {outfile.c_str()}, true); + I18n(AXD_I18N_DATA, "axd").error("AXD80010", {"file"}, {outfile.c_str()}, true); } } @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) if(stats) comp.printStatistics(); if(!transducer) - I18n(LEXD_I18N_DATA, "lexd").error("LEXD1002", {}, {}, false); + I18n(AXD_I18N_DATA, "axd").error("AXD60020", {}, {}, false); else if(bin) { // TODO: finish this! diff --git a/src/lexdcompiler.cc b/src/lexdcompiler.cc index 13ca167..6c17c76 100644 --- a/src/lexdcompiler.cc +++ b/src/lexdcompiler.cc @@ -201,7 +201,7 @@ LexdCompiler::finishLexicon() if(inLex) { if (currentLexicon.size() == 0) { - die(i18n.format("LEXD1003", {"lexicon"}, {name(currentLexiconId)})); + die(i18n.format("AXD80030", {"lexicon"}, {name(currentLexiconId)})); } appendLexicon(currentLexiconId, currentLexicon); @@ -228,11 +228,11 @@ LexdCompiler::checkName(UnicodeString& name) const static UString forbidden = u" :?|()<>[]*+"; name.trim(); int l = name.length(); - if(l == 0) die(i18n.format("LEXD1004")); + if(l == 0) die(i18n.format("AXD80040")); for(const auto &c: forbidden) { if(name.indexOf(c) != -1) { - die(i18n.format("LEXD1005", {"char"}, {c})); + die(i18n.format("AXD80050", {"char"}, {c})); } } return internName(name); @@ -245,7 +245,7 @@ LexdCompiler::readTags(char_iter &iter, UnicodeString &line) if(filter.neg().empty() && filter.ops().empty()) return tags_t((set)filter.pos()); else - die(i18n.format("LEXD1006")); + die(i18n.format("AXD80060")); return tags_t(); } @@ -262,13 +262,13 @@ LexdCompiler::readTagFilter(char_iter& iter, UnicodeString& line) if(*iter == "]" || *iter == "," || *iter == " ") { if(!tag_nonempty) - die(i18n.format("LEXD1007", {"char"}, {iter.span().first})); + die(i18n.format("AXD80070", {"char"}, {iter.span().first})); UnicodeString s = line.tempSubStringBetween(tag_start.first, iter.span().first); if(!tag_filter.combine( negative ? tag_filter_t(neg_tag_filter_t {checkName(s)}) : tag_filter_t(pos_tag_filter_t {checkName(s)}) )) - die(i18n.format("LEXD1008")); + die(i18n.format("AXD80080")); tag_nonempty = false; negative = false; if(*iter == "]") @@ -285,7 +285,7 @@ LexdCompiler::readTagFilter(char_iter& iter, UnicodeString& line) { const UnicodeString s = *iter; if(negative) - die(i18n.format("LEXD1009")); + die(i18n.format("AXD80090")); *iter++; if (*iter == "[") { @@ -298,7 +298,7 @@ LexdCompiler::readTagFilter(char_iter& iter, UnicodeString& line) ops.push_back(op); } else - die(i18n.format("LEXD1010")); + die(i18n.format("AXD80100")); if(*iter == "]") { iter++; @@ -311,7 +311,7 @@ LexdCompiler::readTagFilter(char_iter& iter, UnicodeString& line) tag_start = iter.span(); } } - die(i18n.format("LEXD1011")); + die(i18n.format("AXD80110")); return tag_filter_t(); } @@ -346,7 +346,7 @@ LexdCompiler::readSymbol(char_iter& iter, UnicodeString& line, lex_token_t& tok) if (*iter == end) { tok.symbols.push_back(alphabet_lookup(line.tempSubStringBetween(i, iter.span().second))); } else { - die(i18n.format("LEXD1012", {"end"}, {end})); + die(i18n.format("AXD80120", {"end"}, {end})); } } else { appendSymbol(*iter, tok); @@ -361,10 +361,10 @@ LexdCompiler::processRegexTokenSeq(char_iter& iter, UnicodeString& line, Transdu for (; !iter.at_end(); ++iter) { if (*iter == "(" || *iter == ")" || *iter == "|" || *iter == "/") break; else if (*iter == "?" || *iter == "*" || *iter == "+") - die(i18n.format("LEXD1014", {"quantifier"}, {*iter})); - else if (*iter == "]") die(i18n.format("LEXD1014")); + die(i18n.format("AXD80140", {"quantifier"}, {*iter})); + else if (*iter == "]") die(i18n.format("AXD80140")); else if (*iter == ":" && inleft) inleft = false; - else if (*iter == ":") die(i18n.format("LEXD1015")); + else if (*iter == ":") die(i18n.format("AXD80150")); else if (*iter == "[") { ++iter; vector sym; @@ -386,11 +386,11 @@ LexdCompiler::processRegexTokenSeq(char_iter& iter, UnicodeString& line, Transdu // change the validity of the code -DGS 2022-05-17 if (start.symbols.size() != 1 || end.symbols.size() != 1 || (int)start.symbols[0] <= 0 || (int)end.symbols[0] <= 0) - die(i18n.format("LEXD1016")); + die(i18n.format("AXD80160")); int i_start = (int)start.symbols[0]; int i_end = (int)end.symbols[0]; if (i_start > i_end) - die(i18n.format("LEXD1017")); + die(i18n.format("AXD80170")); for (int i = 1 + i_start; i <= i_end; i++) { lex_token_t mid; mid.symbols.push_back((trans_sym_t)i); @@ -508,9 +508,9 @@ LexdCompiler::processRegexGroup(char_iter& iter, UnicodeString& line, Transducer for (auto& it : option_ends) trans->linkStates(it, state, 0); if ((depth > 0 && *iter == "/") || (depth == 0 && *iter == ")")) - die(i18n.format("LEXD1018")); + die(i18n.format("AXD80180")); if (iter.at_end()) - die(i18n.format("LEXD1019")); + die(i18n.format("AXD80190")); ++iter; if (depth > 0) { if (*iter == "?") { @@ -554,7 +554,7 @@ LexdCompiler::processLexiconSegment(char_iter& iter, UnicodeString& line, unsign seg.regex->setFinal(state); } if(iter.at_end() && seg.regex == nullptr && seg.left.symbols.size() == 0) - die(i18n.format("LEXD1020", {"num1", "num2"}, + die(i18n.format("AXD80200", {"num1", "num2"}, {to_string(currentLexiconPartCount).c_str(), to_string(part_count).c_str()})); for(; !iter.at_end(); ++iter) { @@ -564,7 +564,7 @@ LexdCompiler::processLexiconSegment(char_iter& iter, UnicodeString& line, unsign { auto &tags_applied = inleft ? left_tags_applied : right_tags_applied; if(tags_applied) - die(i18n.format("LEXD1021")); + die(i18n.format("AXD80210")); tags = readTagFilter(iter, line); --iter; tags_applied = true; @@ -574,7 +574,7 @@ LexdCompiler::processLexiconSegment(char_iter& iter, UnicodeString& line, unsign if(inleft) inleft = false; else - die(i18n.format("LEXD1022")); + die(i18n.format("AXD80220")); if ((*iter).length() > 1) readSymbol(iter, line, seg.right); } else readSymbol(iter, line, (inleft ? seg.left : seg.right)); @@ -586,7 +586,7 @@ LexdCompiler::processLexiconSegment(char_iter& iter, UnicodeString& line, unsign if (seg.regex != nullptr && !(seg.left.symbols.empty() && seg.right.symbols.empty())) - die(i18n.format("LEXD1023")); + die(i18n.format("AXD80230")); seg.tags = currentLexicon_tags; @@ -595,7 +595,7 @@ LexdCompiler::processLexiconSegment(char_iter& iter, UnicodeString& line, unsign tags_t diff = subtractset(tags.neg(), seg.tags); for(string_ref t: diff) cerr << i18n.format("bad_tag", {"tag"}, {name(t)}) << endl; - die(i18n.format("LEXD1024")); + die(i18n.format("AXD80240")); } return seg; @@ -613,7 +613,7 @@ LexdCompiler::readToken(char_iter& iter, UnicodeString& line) line.extract(begin_charspan.first, (iter.at_end() ? line.length() : iter.span().first) - begin_charspan.first, name); if(name.length() == 0) - die(i18n.format("LEXD1025", {"symbol", "begin", "end"}, + die(i18n.format("AXD80250", {"symbol", "begin", "end"}, {*iter, iter.span().first, iter.span().second-1})); bool optional = false; @@ -634,12 +634,12 @@ LexdCompiler::readToken(char_iter& iter, UnicodeString& line) for(; !iter.at_end() && (*iter).length() > 0 && *iter != ")"; iter++) { if((*iter).length() != 1 || !u_isdigit((*iter).charAt(0))) - die(i18n.format("LEXD1026", {"index"}, {*iter})); + die(i18n.format("AXD80260", {"index"}, {*iter})); } if(*iter != ")") - die(i18n.format("LEXD1027")); + die(i18n.format("AXD80270")); if(iter.span().first == begin_charspan.first) - die(i18n.format("LEXD1028")); + die(i18n.format("AXD80280")); part = (unsigned int)StringUtils::stoi(to_ustring(line.tempSubStringBetween(begin_charspan.first, iter.span().first))); ++iter; } @@ -679,15 +679,15 @@ LexdCompiler::readPatternElement(char_iter& iter, UnicodeString& line) if(boundary.indexOf(*iter) != -1) { if(*iter == ":") - die(i18n.format("LEXD1029")); + die(i18n.format("AXD80290")); else - die(i18n.format("LEXD1030")); + die(i18n.format("AXD80300")); } tok.right = readToken(iter, line); } else if(boundary.indexOf(*iter) != -1) { - die(i18n.format("LEXD1031", {"symbol", "col"}, {*iter, iter.span().first})); + die(i18n.format("AXD80310", {"symbol", "col"}, {*iter, iter.span().first})); } else { @@ -742,23 +742,23 @@ LexdCompiler::processPattern(char_iter& iter, UnicodeString& line) else if(*iter == "|") { if(alternation.empty()) - die(i18n.format("LEXD1032")); + die(i18n.format("AXD80320")); if(!final_alternative) - die(i18n.format("LEXD1033")); + die(i18n.format("AXD80330")); if(just_sieved) - die(i18n.format("LEXD1034")); + die(i18n.format("AXD80340")); final_alternative = false; } else if(*iter == "<") { if(sieve_forward) - die(i18n.format("LEXD1035")); + die(i18n.format("AXD80350")); if(alternation.empty()) - die(i18n.format("LEXD1036")); + die(i18n.format("AXD80360")); if(just_sieved) - die(i18n.format("LEXD1037")); + die(i18n.format("AXD80370")); if(!final_alternative) - die(i18n.format("LEXD1038")); + die(i18n.format("AXD80380")); expand_alternation(pats_cur, alternation); expand_alternation(pats_cur, left_sieve_tok); alternation.clear(); @@ -768,11 +768,11 @@ LexdCompiler::processPattern(char_iter& iter, UnicodeString& line) { sieve_forward = true; if(alternation.empty()) - die(i18n.format("LEXD1039")); + die(i18n.format("AXD80390")); if(just_sieved) - die(i18n.format("LEXD1037")); + die(i18n.format("AXD80370")); if(!final_alternative) - die(i18n.format("LEXD1038")); + die(i18n.format("AXD80380")); expand_alternation(pats_cur, alternation); expand_alternation(pats_cur, right_sieve_tok); alternation.clear(); @@ -788,7 +788,7 @@ LexdCompiler::processPattern(char_iter& iter, UnicodeString& line) entry.push_back(processLexiconSegment(++iter, line, 0)); if(*iter == " ") iter++; if(*iter != "]") - die(i18n.format("LEXD1040")); + die(i18n.format("AXD80400")); currentLexicon.push_back(entry); finishLexicon(); if(final_alternative && !alternation.empty()) @@ -816,7 +816,7 @@ LexdCompiler::processPattern(char_iter& iter, UnicodeString& line) if(*iter == " ") *iter++; if(iter.at_end() || *iter != ")") - die(i18n.format("LEXD1041")); + die(i18n.format("AXD80410")); ++iter; tag_filter_t filter; if(*iter == "[") @@ -840,7 +840,7 @@ LexdCompiler::processPattern(char_iter& iter, UnicodeString& line) } else if(*iter == "?" || *iter == "*" || *iter == "+") { - die(i18n.format("LEXD1042", {"start", "end"}, {iter.span().first, iter.span().second})); + die(i18n.format("AXD80420", {"start", "end"}, {iter.span().first, iter.span().second})); } else { @@ -857,9 +857,9 @@ LexdCompiler::processPattern(char_iter& iter, UnicodeString& line) } } if(!final_alternative) - die(i18n.format("LEXD1043")); + die(i18n.format("AXD80430")); if(just_sieved) - die(i18n.format("LEXD1044")); + die(i18n.format("AXD80440")); expand_alternation(pats_cur, alternation); for(const auto &pat : pats_cur) { @@ -910,7 +910,7 @@ LexdCompiler::processNextLine() lastWasSpace = space; } lineNumber++; - if(escape) die(i18n.format("LEXD1045")); + if(escape) die(i18n.format("AXD80450")); if(line.length() == 0) return; if(line == "PATTERNS" || line == "PATTERNS ") @@ -926,7 +926,7 @@ LexdCompiler::processNextLine() finishLexicon(); currentPatternId = checkName(name); if (lexicons.find(currentPatternId) != lexicons.end()) { - die(i18n.format("LEXD1046", {"name"}, {name})); + die(i18n.format("AXD80460", {"name"}, {name})); } inPat = true; } @@ -942,15 +942,15 @@ LexdCompiler::processNextLine() currentLexicon_tags = readTags(c, tags); if(c != c.end() && *c == ":") { - i18n.error("LEXD1071", {"line"}, {lineNumber}, false); + i18n.error("AXD60710", {"line"}, {lineNumber}, false); ++c; if(*c == "[") unionset_inplace(currentLexicon_tags, readTags(c, tags)); else - die(i18n.format("LEXD1047")); + die(i18n.format("AXD80470")); } if(c != c.end()) - die(i18n.format("LEXD1048", {"char"}, {(*c)[0]})); + die(i18n.format("AXD80480", {"char"}, {(*c)[0]})); name.retainBetween(0, name.indexOf('[')); } currentLexiconPartCount = 1; @@ -967,16 +967,16 @@ LexdCompiler::processNextLine() } else break; } - if(name.length() == 0) die(i18n.format("LEXD1049")); + if(name.length() == 0) die(i18n.format("AXD80490")); } currentLexiconId = checkName(name); if(lexicons.find(currentLexiconId) != lexicons.end()) { if(lexicons[currentLexiconId][0].size() != currentLexiconPartCount) { - die(i18n.format("LEXD1051", {"lexicon"}, {name})); + die(i18n.format("AXD80510", {"lexicon"}, {name})); } } if (patterns.find(currentLexiconId) != patterns.end()) { - die(i18n.format("LEXD1050", {"name"}, {name})); + die(i18n.format("AXD80500", {"name"}, {name})); } inLex = true; inPat = false; @@ -986,12 +986,12 @@ LexdCompiler::processNextLine() finishLexicon(); if(line.endsWith(' ')) line.retainBetween(0, line.length()-1); int loc = line.indexOf(" ", 6); - if(loc == -1) die(i18n.format("LEXD1052")); + if(loc == -1) die(i18n.format("AXD80520")); UnicodeString name = line.tempSubString(6, loc-6); UnicodeString alt = line.tempSubString(loc+1); string_ref altid = checkName(alt); string_ref lexid = checkName(name); - if(lexicons.find(lexid) == lexicons.end()) die(i18n.format("LEXD1053", {"lexicon"}, {name})); + if(lexicons.find(lexid) == lexicons.end()) die(i18n.format("AXD80530", {"lexicon"}, {name})); lexicons[altid] = lexicons[lexid]; inLex = false; inPat = false; @@ -1001,7 +1001,7 @@ LexdCompiler::processNextLine() char_iter iter = char_iter(line); processPattern(iter, line); if(!iter.at_end() && (*iter).length() > 0) - die(i18n.format("LEXD1054", {"symbol"}, {*iter})); + die(i18n.format("AXD80540", {"symbol"}, {*iter})); } else if(inLex) { @@ -1013,11 +1013,11 @@ LexdCompiler::processNextLine() } if(*iter == ' ') ++iter; if(!iter.at_end()) - die(i18n.format("LEXD1055", {"symbol", "num1", "num2"}, + die(i18n.format("AXD80550", {"symbol", "num1", "num2"}, {*iter, iter.span().first, to_string(currentLexiconPartCount).c_str()})); currentLexicon.push_back(entry); } - else die(i18n.format("LEXD1056")); + else die(i18n.format("AXD80560")); } bool @@ -1035,26 +1035,26 @@ LexdCompiler::isLexiconToken(const pattern_element_t& tok) { if(tok.left.part != 1 || tok.right.part != 1) { - die(i18n.format("LEXD1057", {"pattern"}, {name(tok.right.name)})); + die(i18n.format("AXD80570", {"pattern"}, {name(tok.right.name)})); } return false; } // Any other scenario is an error, so we need to die() if(lpat && rpat) { - die(i18n.format("LEXD1058", {"pattern1", "pattern2"}, {name(tok.left.name), name(tok.right.name)})); + die(i18n.format("AXD80580", {"pattern1", "pattern2"}, {name(tok.left.name), name(tok.right.name)})); } else if((lpat && tok.right.name.empty()) || (rpat && tok.left.name.empty())) { - die(i18n.format("LEXD1059", {"pattern"}, {name(tok.left.name.valid() ? tok.left.name : tok.right.name)})); + die(i18n.format("AXD80590", {"pattern"}, {name(tok.left.name.valid() ? tok.left.name : tok.right.name)})); } else if(llex && rpat) { - die(i18n.format("LEXD1060", {"lexicon", "pattern"}, {name(tok.left.name), name(tok.right.name)})); + die(i18n.format("AXD80600", {"lexicon", "pattern"}, {name(tok.left.name), name(tok.right.name)})); } else if(lpat && rlex) { - die(i18n.format("LEXD1061", {"pattern", "lexicon"}, {name(tok.left.name), name(tok.right.name)})); + die(i18n.format("AXD80610", {"pattern", "lexicon"}, {name(tok.left.name), name(tok.right.name)})); } else { @@ -1066,7 +1066,7 @@ LexdCompiler::isLexiconToken(const pattern_element_t& tok) for(auto l: lexicons) cerr << to_ustring(name(l.first)) << " "; cerr << endl; - die(i18n.format("LEXD1062", {"lex_pat"}, {name((llex || lpat) ? tok.right.name : tok.left.name)})); + die(i18n.format("AXD80620", {"lex_pat"}, {name((llex || lpat) ? tok.right.name : tok.left.name)})); } // we never reach this point, but the compiler doesn't understand die() // so we put a fake return value to keep it happy @@ -1133,7 +1133,7 @@ LexdCompiler::buildPattern(int state, Transducer* t, const pattern_t& pat, const if(tok.right.name.valid() && matchedParts.find(tok.right.name) == matchedParts.end()) matchedParts[tok.right.name] = matchedParts[tok.left.name]; if(tok.left.name.valid() && tok.right.name.valid() && matchedParts[tok.left.name] != matchedParts[tok.right.name]) - die(i18n.format("LEXD1063", {"left", "right"}, {name(tok.left.name), name(tok.right.name)})); + die(i18n.format("AXD80630", {"left", "right"}, {name(tok.left.name), name(tok.right.name)})); Transducer* lex = getLexiconTransducer(pat[pos], matchedParts[tok.left.name || tok.right.name], false); if(lex) { @@ -1166,10 +1166,10 @@ LexdCompiler::determineFreedom(pattern_t& pat) { const pattern_element_t& t1 = pat[i]; if (is_optional.find(t1.left.name) != is_optional.end() && is_optional[t1.left.name] != t1.optional()) { - die(i18n.format("LEXD1064", {"lexicon"}, {name(t1.left.name)})); + die(i18n.format("AXD80640", {"lexicon"}, {name(t1.left.name)})); } if (is_optional.find(t1.right.name) != is_optional.end() && is_optional[t1.right.name] != t1.optional()) { - die(i18n.format("LEXD1064", {"lexicon"}, {name(t1.right.name)})); + die(i18n.format("AXD80640", {"lexicon"}, {name(t1.right.name)})); } if (t1.left.name.valid()) { is_optional[t1.left.name] = t1.optional(); @@ -1198,7 +1198,7 @@ Transducer* LexdCompiler::buildPattern(const pattern_element_t &tok) { if(tok.left.part != 1 || tok.right.part != 1) - die(i18n.format("LEXD1065", {"pattern"}, {name(tok.left.name)})); + die(i18n.format("AXD80650", {"pattern"}, {name(tok.left.name)})); if(patternTransducers.find(tok) == patternTransducers.end()) { if (verbose) cerr << "Compiling " << to_ustring(printPattern(tok)) << endl; @@ -1218,7 +1218,7 @@ LexdCompiler::buildPattern(const pattern_element_t &tok) if(!pair.tag_filter.combine(tok.tag_filter.neg())) { taggable = false; if (verbose) { - i18n.error("LEXD1072", {"pattern1", "pattern2", "line"}, + i18n.error("AXD60720", {"pattern1", "pattern2", "line"}, {printPattern(tok), printPattern(pat_untagged.second[j]), pat.first}, false); } } @@ -1226,7 +1226,7 @@ LexdCompiler::buildPattern(const pattern_element_t &tok) if(!pat.second[i].tag_filter.combine(tok.tag_filter.pos())) { taggable = false; if (verbose) { - i18n.error("LEXD1072", {"pattern1", "pattern2", "line"}, + i18n.error("AXD60720", {"pattern1", "pattern2", "line"}, {printPattern(tok), printPattern(pat_untagged.second[i]), pat.first}, false); } } @@ -1246,7 +1246,7 @@ LexdCompiler::buildPattern(const pattern_element_t &tok) t->minimize(); } else if (verbose) { - i18n.error("LEXD1073", {"pattern"}, {printPattern(tok)}, false); + i18n.error("AXD60730", {"pattern"}, {printPattern(tok)}, false); } patternTransducers[tok] = t; if (verbose) { @@ -1258,7 +1258,7 @@ LexdCompiler::buildPattern(const pattern_element_t &tok) } else if(patternTransducers[tok] == NULL) { - die(i18n.format("LEXD1066", {"pattern"}, {printPattern(tok)})); + die(i18n.format("AXD80660", {"pattern"}, {printPattern(tok)})); } return patternTransducers[tok]; } @@ -1370,13 +1370,13 @@ LexdCompiler::buildPatternWithFlags(const pattern_element_t &tok, int pattern_st { if (i == idx && !cur.tag_filter.combine(tok.tag_filter.pos())) { if (verbose) { - i18n.error("LEXD1072", {"pattern1", "pattern2", "line"}, + i18n.error("AXD60720", {"pattern1", "pattern2", "line"}, {printPattern(tok), printPattern(pat.second[i]), pat.first}, false); } } if (!cur.tag_filter.combine(tok.tag_filter.neg())) { if (verbose) { - i18n.error("LEXD1072", {"pattern1", "pattern2", "line"}, + i18n.error("AXD60720", {"pattern1", "pattern2", "line"}, {printPattern(tok), printPattern(pat.second[i]), pat.first}, false); } } @@ -1548,7 +1548,7 @@ LexdCompiler::buildPatternWithFlags(const pattern_element_t &tok, int pattern_st } else if(patternTransducers[tok] == NULL) { - die(i18n.format("LEXD1066", {"pattern"}, {name(tok.left.name)})); + die(i18n.format("AXD80660", {"pattern"}, {name(tok.left.name)})); } return patternTransducers[tok]; } @@ -1749,7 +1749,7 @@ LexdCompiler::buildPatternSingleLexicon(pattern_element_t tok, int start_state) } else { - die(i18n.format("LEXD1066", {"pattern"}, {name(tok.left.name)})); + die(i18n.format("AXD80660", {"pattern"}, {name(tok.left.name)})); return 0; } } @@ -1801,7 +1801,7 @@ LexdCompiler::buildTransducerSingleLexicon() int end = buildPatternSingleLexicon(start_pat, 0); if(end == -1) { - i18n.error("LEXD1074", {}, {}, false); + i18n.error("AXD60740", {}, {}, false); } else { hyperminTrans->setFinal(end); @@ -1974,12 +1974,12 @@ LexdCompiler::getLexiconTransducer(pattern_element_t tok, unsigned int entry_ind vector& lents = lexicons[tok.left.name]; if(tok.left.name.valid() && tok.left.part > lents[0].size()) - die(i18n.format("LEXD1067", {"lexicon", "part"}, {name(tok.left.name), to_string(tok.left.part).c_str()})); + die(i18n.format("AXD80670", {"lexicon", "part"}, {name(tok.left.name), to_string(tok.left.part).c_str()})); vector& rents = lexicons[tok.right.name]; if(tok.right.name.valid() && tok.right.part > rents[0].size()) - die(i18n.format("LEXD1067", {"lexicon", "part"}, {name(tok.right.name), to_string(tok.right.part).c_str()})); + die(i18n.format("AXD80670", {"lexicon", "part"}, {name(tok.right.name), to_string(tok.right.part).c_str()})); if(tok.left.name.valid() && tok.right.name.valid() && lents.size() != rents.size()) - die(i18n.format("LEXD1068", {"left", "right"}, {name(tok.left.name), name(tok.right.name)})); + die(i18n.format("AXD80680", {"left", "right"}, {name(tok.left.name), name(tok.right.name)})); unsigned int count = (tok.left.name.valid() ? lents.size() : rents.size()); vector trans; if(free) @@ -2002,11 +2002,11 @@ LexdCompiler::getLexiconTransducer(pattern_element_t tok, unsigned int entry_ind Transducer* t = free ? trans[0] : new Transducer(); if (le.regex != nullptr || re.regex != nullptr) { if (tok.left.name.empty()) - die(i18n.format("LEXD1069", {"lexicon"}, {name(tok.right.name)})); + die(i18n.format("AXD80690", {"lexicon"}, {name(tok.right.name)})); if (tok.right.name.empty()) - die(i18n.format("LEXD1069", {"lexicon"}, {name(tok.left.name)})); + die(i18n.format("AXD80690", {"lexicon"}, {name(tok.left.name)})); if (tok.left.name != tok.right.name) - die(i18n.format("LEXD1070", {"left", "right", "something"}, + die(i18n.format("AXD80700", {"left", "right", "something"}, {name(tok.left.name), name(tok.right.name), name(tok.right.name), name((le.regex != nullptr ? tok.left.name : tok.right.name))})); } @@ -2109,12 +2109,12 @@ LexdCompiler::getLexiconTransducerWithFlags(pattern_element_t& tok, bool free) // TODO: can this be abstracted from here and getLexiconTransducer()? vector& lents = lexicons[tok.left.name]; if(tok.left.name.valid() && tok.left.part > lents[0].size()) - die(i18n.format("LEXD1067", {"lexicon", "part"}, {name(tok.left.name), to_string(tok.left.part).c_str()})); + die(i18n.format("AXD80670", {"lexicon", "part"}, {name(tok.left.name), to_string(tok.left.part).c_str()})); vector& rents = lexicons[tok.right.name]; if(tok.right.name.valid() && tok.right.part > rents[0].size()) - die(i18n.format("LEXD1067", {"lexicon", "part"}, {name(tok.right.name), to_string(tok.right.part).c_str()})); + die(i18n.format("AXD80670", {"lexicon", "part"}, {name(tok.right.name), to_string(tok.right.part).c_str()})); if(tok.left.name.valid() && tok.right.name.valid() && lents.size() != rents.size()) - die(i18n.format("LEXD1068", {"left", "right"}, {name(tok.left.name), name(tok.right.name)})); + die(i18n.format("AXD80680", {"left", "right"}, {name(tok.left.name), name(tok.right.name)})); unsigned int count = (tok.left.name.valid() ? lents.size() : rents.size()); Transducer* trans = new Transducer(); lex_seg_t empty; @@ -2132,11 +2132,11 @@ LexdCompiler::getLexiconTransducerWithFlags(pattern_element_t& tok, bool free) lex_seg_t seg; if (le.regex != nullptr || re.regex != nullptr) { if (tok.left.name.empty()) - die(i18n.format("LEXD1069", {"lexicon"}, {name(tok.right.name)})); + die(i18n.format("AXD80690", {"lexicon"}, {name(tok.right.name)})); if (tok.right.name.empty()) - die(i18n.format("LEXD1069", {"lexicon"}, {name(tok.left.name)})); + die(i18n.format("AXD80690", {"lexicon"}, {name(tok.left.name)})); if (tok.left.name != tok.right.name) - die(i18n.format("LEXD1070", {"left", "right", "something"}, + die(i18n.format("AXD80700", {"left", "right", "something"}, {name(tok.left.name), name(tok.right.name), name(tok.right.name), name((le.regex != nullptr ? tok.left.name : tok.right.name))})); seg.regex = le.regex; diff --git a/src/lexdcompiler.h b/src/lexdcompiler.h index f1e97ad..495b5a2 100644 --- a/src/lexdcompiler.h +++ b/src/lexdcompiler.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -352,7 +352,7 @@ class LexdCompiler bool doneReading = false; unsigned int anonymousCount = 0; unsigned int transitionCount = 0; - I18n i18n {LEXD_I18N_DATA, "lexd"}; + I18n i18n {AXD_I18N_DATA, "axd"}; Transducer* hyperminTrans;