• R/O
  • SSH
  • HTTPS

nina: Commit


Commit MetaInfo

Revisión674 (tree)
Tiempo2018-05-20 09:23:45
Autory-moriguchi

Log Message

fixed bugs about substrings in double quote

Cambiar Resumen

Diferencia incremental

--- nina/java/src/net/morilib/nina/DFABuilder.java (revision 673)
+++ nina/java/src/net/morilib/nina/DFABuilder.java (revision 674)
@@ -900,110 +900,24 @@
900900 return true;
901901 }
902902
903- private void _findsub(Map<String, DBS> m, String s, DBS v,
904- String k) {
905- char c, C;
906- DBS a, b;
903+ private DBS findAndLinkState(NinaEvent q, DBS x, int c, String lh) {
904+ DBS a;
907905
908- if(k.length() < s.length()) {
909- c = s.charAt(k.length());
910- C = Character.toUpperCase(c);
911- c = Character.toLowerCase(c);
912- if(c == C) {
913- a = v.edges == null ? null : v.edges.map((int)c);
914- if(a != null) {
915- _findsub(m, s, a, k + c);
916- } else {
917- m.put(k, v);
918- }
919- } else {
920- a = v.edges == null ? null : v.edges.map((int)c);
921- b = v.edges == null ? null : v.edges.map((int)C);
922- if(a != null && b != null) {
923- _findsub(m, s, a, k + c);
924- _findsub(m, s, b, k + C);
925- } else if(a != null) {
926- _findsub(m, s, a, k + c);
927- } else if(b != null) {
928- _findsub(m, s, b, k + C);
929- } else {
930- m.put(k, v);
931- }
932- }
906+ if(x.edges == null) {
907+ x = _linkc(q, x, c, lh);
908+ } else if((a = x.edges.map(c)) != null) {
909+ x = a;
933910 } else {
934- m.put(k, v);
911+ x = _linkc(q, x, c, lh);
935912 }
913+ return x;
936914 }
937915
938- private void _linksubdq(NinaEvent q, String s, DBS X, DBS v, DBS p,
939- String lh) {
940- Map<String, DBS> m;
941- DBS x, w, a, b;
942- boolean f, F;
943- int c, C;
944-
945- m = new HashMap<String, DBS>();
946- _findsub(m, s, v, "");
947- if(m.containsKey("")) {
948- c = s.charAt(0);
949- C = Character.toUpperCase(c);
950- c = Character.toLowerCase(c);
951- _linkv(q, v, X, c, lh);
952- if(c != C) {
953- _linkv(q, v, X, C, lh);
954- }
955- } else {
956- f = F = true;
957- for(Map.Entry<String, DBS> t : m.entrySet()) {
958- x = X; w = v;
959- for(int k = 0; k < t.getKey().length(); k++) {
960- c = s.charAt(k);
961- C = Character.toUpperCase(c);
962- c = Character.toLowerCase(c);
963- a = w.edges.map(c);
964- b = w.edges.map(C);
965- if(k == 0) {
966- f = f && c != C && a == null;
967- F = F && c != C && b == null;
968- } else if(a == null && b == null) {
969- _linkv(q, w, x, c, lh);
970- _linkv(q, w, x, C, lh);
971- } else if(a == null) {
972- _linkv(q, w, x, c, lh);
973- } else if(b == null) {
974- _linkv(q, w, x, C, lh);
975- }
976-
977- w = w.edges.map((int)t.getKey().charAt(k));
978- if(k < s.length() - 1) {
979- x = x.edges.map((int)s.charAt(k + 1));
980- }
981- }
982-
983- if(t.getKey().length() < s.length()) {
984- c = s.charAt(t.getKey().length());
985- C = Character.toUpperCase(c);
986- c = Character.toLowerCase(c);
987- _linkv(q, w, x, c, lh);
988- _linkv(q, w, x, C, lh);
989- } else {
990- w.linkOthers(p, q.getLanguageOption().getUnget());
991- w.linkEnd(p, null);
992- }
993- }
994- c = s.charAt(0);
995- C = Character.toUpperCase(c);
996- c = Character.toLowerCase(c);
997- if(f) _linkv(q, v, X, c, lh);
998- if(F) _linkv(q, v, X, C, lh);
999- }
1000- }
1001-
1002916 private void _linkdq(NinaEvent q, CharSequence s, DBS v, int f) {
1003917 List<DoubleQuoteTokenizer.Elems> b;
1004- String g, h, lh, lm, lc, lu, quoted;
1005- DBS x, X, a, A;
1006- int k, c, C;
918+ String g, lh, lm, lc, lu, quoted;
919+ DBS x;
920+ int k, c;
1007921 boolean z;
1008922 Range r;
1009923
@@ -1021,53 +935,10 @@
1021935 }
1022936 b = DoubleQuoteTokenizer.parse(quoted);
1023937 for(DoubleQuoteTokenizer.Elems p : b) {
1024- x = X = v;
938+ x = v;
1025939 s = p.getString();
1026940 for(k = 0; k < s.length() - 1; k++) {
1027- if(f == 'I') {
1028- c = s.charAt(k);
1029- C = Character.toUpperCase(c);
1030- c = Character.toLowerCase(c);
1031- if(x.edges == null) {
1032- x = _linkc(q, x, c, lh);
1033- } else if((a = x.edges.map(c)) != null) {
1034- x = a;
1035- } else {
1036- x = _linkc(q, x, c, lh);
1037- }
1038-
1039- if(X.edges == null) {
1040- X = _linkc(q, X, C, lh);
1041- } else if((A = X.edges.map(C)) != null) {
1042- X = A;
1043- } else {
1044- X = _linkc(q, X, C, lh);
1045- }
1046- } else if(f == 'i') {
1047- c = s.charAt(k);
1048- C = Character.toUpperCase(c);
1049- c = Character.toLowerCase(c);
1050- a = createState(q);
1051- if(k == 0) {
1052- x = X = a;
1053- } else if(c == C) {
1054- _linkv(q, x, a, c, lh);
1055- x = a;
1056- } else {
1057- _linkv(q, x, a, c, lh);
1058- _linkv(q, x, a, C, lh);
1059- x = a;
1060- }
1061- } else {
1062- c = s.charAt(k);
1063- if(x.edges == null) {
1064- x = _linkc(q, x, c, lh);
1065- } else if((a = x.edges.map(c)) != null) {
1066- x = a;
1067- } else {
1068- x = _linkc(q, x, c, lh);
1069- }
1070- }
941+ x = findAndLinkState(q, x, s.charAt(k), lh);
1071942 }
1072943
1073944 if(p.getRegex() != null) {
@@ -1091,60 +962,16 @@
1091962 r = Interval.newPoint(Integer.valueOf(s.charAt(k)));
1092963 if(p.isInvertLookahead()) r = CharSets.complement(r);
1093964 x.linkAlphabet(vertex, r, g);
1094- } else if(f == 'w') {
1095- g = lc + lu;
1096- h = lc;
1097- if(mealy != null) {
1098- g += mealy.toString();
1099- h += mealy.toString();
1100- }
1101- x = _linkc(q, x, s.charAt(k), lh);
1102- x.linkAlphabet(vertex, SPACES, g);
1103- x.linkEnd(vertex, h);
1104965 } else if(_isword(s) && f != 'p') {
1105966 g = lc + lu;
1106967 if(mealy != null) g += mealy.toString();
1107- if(f == 'I') {
1108- c = s.charAt(k);
1109- C = Character.toUpperCase(c);
1110- c = Character.toLowerCase(c);
1111- x = _linkc(q, x, c, lh);
1112- X = _linkc(q, X, C, lh);
1113- x.linkAlphabet(vertex, NOT_WORD, g);
1114- X.linkAlphabet(vertex, NOT_WORD, g);
1115- } else if(f == 'i') {
1116- c = s.charAt(k);
1117- C = Character.toUpperCase(c);
1118- c = Character.toLowerCase(c);
1119- a = _linkc(q, x, c, lh);
1120- if(c != C) {
1121- _linkv(q, x, a, C, lh);
1122- }
1123- a.linkAlphabet(vertex, NOT_WORD, g);
1124- _linksubdq(q, s.toString(), X, v, a, lh);
1125- } else {
1126- x = _linkc(q, x, s.charAt(k), lh);
1127- x.linkAlphabet(vertex, NOT_WORD, g);
1128- }
968+ x = findAndLinkState(q, x, s.charAt(k), lh);
969+ x.linkAlphabet(vertex, NOT_WORD, g);
1129970 } else {
1130- g = lc;
1131- if(mealy != null) g += mealy.toString();
1132- if(f == 'I') {
1133- c = s.charAt(k);
1134- C = Character.toUpperCase(c);
1135- c = Character.toLowerCase(c);
1136- _linkv(q, x, vertex, c, g);
1137- _linkv(q, X, vertex, C, g);
1138- } else if(f == 'i') {
1139- c = s.charAt(k);
1140- C = Character.toUpperCase(c);
1141- c = Character.toLowerCase(c);
1142- _linkv(q, x, vertex, c, g);
1143- _linkv(q, x, vertex, C, g);
1144- _linksubdq(q, s.toString(), X, v, vertex, lh);
1145- } else {
1146- _linkv(q, x, vertex, s.charAt(k), g);
1147- }
971+ g = mealy != null ? mealy.toString() : "";
972+ x = findAndLinkState(q, x, s.charAt(k), lh);
973+ x.linkOthers(vertex, lc + lu);
974+ x.linkEnd(x, lc);
1148975 }
1149976 }
1150977 }
Show on old repository browser