• R/O
  • SSH
  • HTTPS

nina: Commit


Commit MetaInfo

Revisión671 (tree)
Tiempo2018-05-12 14:07:29
Autory-moriguchi

Log Message

fixed bugs about tokens

Cambiar Resumen

Diferencia incremental

--- nina/java/src/net/morilib/nina/DFABuilder.java (revision 670)
+++ nina/java/src/net/morilib/nina/DFABuilder.java (revision 671)
@@ -234,6 +234,7 @@
234234 Collection<DBS> identical = null;
235235
236236 boolean skipSpaces;
237+ boolean tokenDeadState = false;
237238
238239 private Range allRange = null;
239240
@@ -617,6 +618,9 @@
617618
618619 };
619620
621+ //
622+ private static final int DUMMY_CH = Integer.MAX_VALUE - 1;
623+
620624 /**
621625 * The range of not a word.
622626 */
@@ -1164,17 +1168,26 @@
11641168
11651169 private void _linkBackquoteLookahead(NinaEvent event,
11661170 Trie.Node node,
1167- DBS state) {
1171+ DBS state,
1172+ boolean isRoot) {
11681173 NinaLanguageOption langopt = event.getLanguageOption();
1169- String look = langopt.getLookaheadMark() + langopt.getLookahead();
1174+ String mark = isRoot ? langopt.getLookaheadMark() : "";
1175+ String look = mark + langopt.getLookahead();
11701176 String commit = look + langopt.getLookaheadCommit();
1171- if(node != null && node.countEdges() > 0) {
1172- for(int ch : node.getEdges()) {
1173- DBS stateNew = _linkc(event, state, ch, look);
1174- _linkBackquoteLookahead(event, node.get(ch), stateNew);
1177+ DBS stateGet, stateNew;
1178+
1179+ for(int ch : node.getEdges()) {
1180+ if(state.edges != null &&
1181+ (stateGet = state.edges.map(ch)) != null) {
1182+ _linkBackquoteLookahead(event, node.get(ch), stateGet, false);
1183+ } else if(node.get(ch) != null && node.get(ch).countEdges() > 0) {
1184+ stateNew = _linkc(event, state, ch, look);
1185+ _linkBackquoteLookahead(event, node.get(ch), stateNew, false);
1186+ } else if(state.edges != null && state.edges.map(DUMMY_CH) != null) {
1187+ _linkv(event, state, vertex, DUMMY_CH, null);
11751188 }
1176- state.linkOthers(vertex, commit);
11771189 }
1190+ state.linkOthers(vertex, commit);
11781191 }
11791192
11801193 private void _linkBackquote(NinaEvent event,
@@ -1199,13 +1212,14 @@
11991212 } else {
12001213 stateNew = _linkc(event, stateNew, ch, look);
12011214 }
1202- commit = look + langopt.getLookaheadCommit();
1215+ commit = look + langopt.getLookaheadMark() +
1216+ langopt.getLookaheadCommit();
12031217 }
12041218 ch = seq.charAt(pos);
12051219 node = node == null ? null : node.get(ch);
12061220 if(node != null && node.countEdges() > 0) {
12071221 stateNew = _linkc(event, stateNew, ch, look);
1208- _linkBackquoteLookahead(event, node, stateNew);
1222+ _linkBackquoteLookahead(event, node, stateNew, true);
12091223 } else {
12101224 _linkv(event, stateNew, vertex, ch, commit);
12111225 }
Show on old repository browser