< prev index next >
make/jdk/src/classes/build/tools/generatebreakiteratordata/RuleBasedBreakIteratorBuilder.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 288,298 ****
if (c == '<' && (haveEquals || havePipe)) {
error("Unknown variable name", p, description);
}
lastOpen = c;
! parenStack.push(new Character((char)c));
if (c == '<') {
sawVarName = true;
}
break;
--- 288,298 ----
if (c == '<' && (haveEquals || havePipe)) {
error("Unknown variable name", p, description);
}
lastOpen = c;
! parenStack.push(Character.valueOf((char)c));
if (c == '<') {
sawVarName = true;
}
break;
*** 900,914 ****
boolean sawEarlyBreak = false;
// if we're adding rules to the backward state table, mark the initial state
// as a looping state
if (!forward) {
! loopingStates.addElement(new Integer(1));
}
// put the current state on the decision point list before we start
! decisionPointList.addElement(new Integer(currentState)); // we want currentState to
// be 1 here...
currentState = tempStateTable.size() - 1; // but after that, we want it to be
// 1 less than the state number of the next state
while (p < rule.length()) {
int c = rule.codePointAt(p);
--- 900,914 ----
boolean sawEarlyBreak = false;
// if we're adding rules to the backward state table, mark the initial state
// as a looping state
if (!forward) {
! loopingStates.addElement(Integer.valueOf(1));
}
// put the current state on the decision point list before we start
! decisionPointList.addElement(Integer.valueOf(currentState)); // we want currentState to
// be 1 here...
currentState = tempStateTable.size() - 1; // but after that, we want it to be
// 1 less than the state number of the next state
while (p < rule.length()) {
int c = rule.codePointAt(p);
*** 976,986 ****
state = tempStateTable.elementAt(rowNum);
// if the period is followed by an asterisk, then just set the current
// state to loop back on itself
if (p + 1 < rule.length() && rule.charAt(p + 1) == '*' && state[0] != 0) {
! decisionPointList.addElement(new Integer(state[0]));
pendingChars = "";
++p;
}
// otherwise, fabricate a category list ("pendingChars") with
--- 976,986 ----
state = tempStateTable.elementAt(rowNum);
// if the period is followed by an asterisk, then just set the current
// state to loop back on itself
if (p + 1 < rule.length() && rule.charAt(p + 1) == '*' && state[0] != 0) {
! decisionPointList.addElement(Integer.valueOf(state[0]));
pendingChars = "";
++p;
}
// otherwise, fabricate a category list ("pendingChars") with
*** 1010,1020 ****
// if we have looping states to worry about, set its "don't make
// me an accepting state" flag if we've seen a slash, and add
// it to the end of the state table
int newState = tempStateTable.size();
if (loopingStates.size() != 0) {
! statesToBackfill.addElement(new Integer(newState));
}
state = new short[numCategories + 1];
if (sawEarlyBreak) {
state[numCategories] = DONT_LOOP_FLAG;
}
--- 1010,1020 ----
// if we have looping states to worry about, set its "don't make
// me an accepting state" flag if we've seen a slash, and add
// it to the end of the state table
int newState = tempStateTable.size();
if (loopingStates.size() != 0) {
! statesToBackfill.addElement(Integer.valueOf(newState));
}
state = new short[numCategories + 1];
if (sawEarlyBreak) {
state[numCategories] = DONT_LOOP_FLAG;
}
*** 1030,1040 ****
// add all states created since the last literal character we've
// seen to the decision point list
lastState = currentState;
do {
++currentState;
! decisionPointList.addElement(new Integer(currentState));
} while (currentState + 1 < tempStateTable.size());
}
}
// a { marks the beginning of an optional run of characters. Push a
--- 1030,1040 ----
// add all states created since the last literal character we've
// seen to the decision point list
lastState = currentState;
do {
++currentState;
! decisionPointList.addElement(Integer.valueOf(currentState));
} while (currentState + 1 < tempStateTable.size());
}
}
// a { marks the beginning of an optional run of characters. Push a
*** 1056,1066 ****
// when there's a *, update the current state to loop back on itself
// on the character categories that caused us to enter this state
if (c == '*') {
for (int i = lastState + 1; i < tempStateTable.size(); i++) {
Vector<Integer> temp = new Vector<>();
! temp.addElement(new Integer(i));
updateStateTable(temp, pendingChars, (short)(lastState + 1));
}
}
// pop the top element off the decision point stack and merge
--- 1056,1066 ----
// when there's a *, update the current state to loop back on itself
// on the character categories that caused us to enter this state
if (c == '*') {
for (int i = lastState + 1; i < tempStateTable.size(); i++) {
Vector<Integer> temp = new Vector<>();
! temp.addElement(Integer.valueOf(i));
updateStateTable(temp, pendingChars, (short)(lastState + 1));
}
}
// pop the top element off the decision point stack and merge
*** 1119,1129 ****
lastState = currentState;
++currentState;
// add the current state to the decision point list (add it at the
// BEGINNING so we can find it later)
! decisionPointList.insertElementAt(new Integer(currentState), 0);
// finally, push a copy of the current decision point list onto the
// stack (this keeps track of the active decision point list before
// the () expression), followed by an empty decision point list
// (this will hold the exit points)
--- 1119,1129 ----
lastState = currentState;
++currentState;
// add the current state to the decision point list (add it at the
// BEGINNING so we can find it later)
! decisionPointList.insertElementAt(Integer.valueOf(currentState), 0);
// finally, push a copy of the current decision point list onto the
// stack (this keeps track of the active decision point list before
// the () expression), followed by an empty decision point list
// (this will hold the exit points)
*** 1206,1216 ****
// finally, copy every forward reference from the entry point
// list into every state in the new decision point list
for (int i = 0; i < tempState.length; i++) {
if (tempState[i] > tempStateNum) {
updateStateTable(exitPoints,
! new Character((char)(i + 0x100)).toString(),
tempState[i]);
}
}
// update lastState and currentState, and throw away the *
--- 1206,1216 ----
// finally, copy every forward reference from the entry point
// list into every state in the new decision point list
for (int i = 0; i < tempState.length; i++) {
if (tempState[i] > tempStateNum) {
updateStateTable(exitPoints,
! Character.valueOf((char)(i + 0x100)).toString(),
tempState[i]);
}
}
// update lastState and currentState, and throw away the *
*** 1328,1338 ****
*/
private void mergeStates(int rowNum,
short[] newValues,
Vector<Integer> rowsBeingUpdated) {
short[] oldValues = tempStateTable.elementAt(rowNum);
! boolean isLoopingState = loopingStates.contains(new Integer(rowNum));
// for each of the cells in the rows we're reconciling, do...
for (int i = 0; i < oldValues.length; i++) {
// if they contain the same value, we don't have to do anything
--- 1328,1338 ----
*/
private void mergeStates(int rowNum,
short[] newValues,
Vector<Integer> rowsBeingUpdated) {
short[] oldValues = tempStateTable.elementAt(rowNum);
! boolean isLoopingState = loopingStates.contains(Integer.valueOf(rowNum));
// for each of the cells in the rows we're reconciling, do...
for (int i = 0; i < oldValues.length; i++) {
// if they contain the same value, we don't have to do anything
*** 1341,1351 ****
}
// if oldValues is a looping state and the state the current cell points to
// is too, then we can just stomp over the current value of that cell (and
// set the clear-looping-states flag if necessary)
! else if (isLoopingState && loopingStates.contains(new Integer(oldValues[i]))) {
if (newValues[i] != 0) {
if (oldValues[i] == 0) {
clearLoopingStates = true;
}
oldValues[i] = newValues[i];
--- 1341,1351 ----
}
// if oldValues is a looping state and the state the current cell points to
// is too, then we can just stomp over the current value of that cell (and
// set the clear-looping-states flag if necessary)
! else if (isLoopingState && loopingStates.contains(Integer.valueOf(oldValues[i]))) {
if (newValues[i] != 0) {
if (oldValues[i] == 0) {
clearLoopingStates = true;
}
oldValues[i] = newValues[i];
*** 1399,1431 ****
tempStateTable.addElement(newRow);
oldValues[i] = (short)combinedRowNum;
// if the decision point list contains either of the parent rows,
// update it to include the new row as well
! if ((decisionPointList.contains(new Integer(oldRowNum))
! || decisionPointList.contains(new Integer(newRowNum)))
! && !decisionPointList.contains(new Integer(combinedRowNum))
) {
! decisionPointList.addElement(new Integer(combinedRowNum));
}
// do the same thing with the list of rows being updated
! if ((rowsBeingUpdated.contains(new Integer(oldRowNum))
! || rowsBeingUpdated.contains(new Integer(newRowNum)))
! && !rowsBeingUpdated.contains(new Integer(combinedRowNum))
) {
! decisionPointList.addElement(new Integer(combinedRowNum));
}
// now (groan) do the same thing for all the entries on the
// decision point stack
for (int k = 0; k < decisionPointStack.size(); k++) {
Vector<Integer> dpl = decisionPointStack.elementAt(k);
! if ((dpl.contains(new Integer(oldRowNum))
! || dpl.contains(new Integer(newRowNum)))
! && !dpl.contains(new Integer(combinedRowNum))
) {
! dpl.addElement(new Integer(combinedRowNum));
}
}
// FINALLY (puff puff puff), call mergeStates() recursively to copy
// the row referred to by newValues into the new row and resolve any
--- 1399,1431 ----
tempStateTable.addElement(newRow);
oldValues[i] = (short)combinedRowNum;
// if the decision point list contains either of the parent rows,
// update it to include the new row as well
! if ((decisionPointList.contains(Integer.valueOf(oldRowNum))
! || decisionPointList.contains(Integer.valueOf(newRowNum)))
! && !decisionPointList.contains(Integer.valueOf(combinedRowNum))
) {
! decisionPointList.addElement(Integer.valueOf(combinedRowNum));
}
// do the same thing with the list of rows being updated
! if ((rowsBeingUpdated.contains(Integer.valueOf(oldRowNum))
! || rowsBeingUpdated.contains(Integer.valueOf(newRowNum)))
! && !rowsBeingUpdated.contains(Integer.valueOf(combinedRowNum))
) {
! decisionPointList.addElement(Integer.valueOf(combinedRowNum));
}
// now (groan) do the same thing for all the entries on the
// decision point stack
for (int k = 0; k < decisionPointStack.size(); k++) {
Vector<Integer> dpl = decisionPointStack.elementAt(k);
! if ((dpl.contains(Integer.valueOf(oldRowNum))
! || dpl.contains(Integer.valueOf(newRowNum)))
! && !dpl.contains(Integer.valueOf(combinedRowNum))
) {
! dpl.addElement(Integer.valueOf(combinedRowNum));
}
}
// FINALLY (puff puff puff), call mergeStates() recursively to copy
// the row referred to by newValues into the new row and resolve any
*** 1534,1547 ****
* @param The row number of the state to remove from the backfill list
*/
private void eliminateBackfillStates(int baseState) {
// don't do anything unless this state is actually in the backfill list...
! if (statesToBackfill.contains(new Integer(baseState))) {
// if it is, take it out
! statesToBackfill.removeElement(new Integer(baseState));
// then go through and recursively call this function for every
// state that the base state points to
short[] state = tempStateTable.elementAt(baseState);
for (int i = 0; i < numCategories; i++) {
--- 1534,1547 ----
* @param The row number of the state to remove from the backfill list
*/
private void eliminateBackfillStates(int baseState) {
// don't do anything unless this state is actually in the backfill list...
! if (statesToBackfill.contains(Integer.valueOf(baseState))) {
// if it is, take it out
! statesToBackfill.removeElement(Integer.valueOf(baseState));
// then go through and recursively call this function for every
// state that the base state points to
short[] state = tempStateTable.elementAt(baseState);
for (int i = 0; i < numCategories; i++) {
*** 1606,1616 ****
// start by backfilling the looping states
backfillLoopingStates();
int[] rowNumMap = new int[tempStateTable.size()];
Stack<Integer> rowsToFollow = new Stack<>();
! rowsToFollow.push(new Integer(1));
rowNumMap[1] = 1;
// determine which states are no longer reachable from the start state
// (the reachable states will have their row numbers in the row number
// map, and the nonreachable states will have zero in the row number map)
--- 1606,1616 ----
// start by backfilling the looping states
backfillLoopingStates();
int[] rowNumMap = new int[tempStateTable.size()];
Stack<Integer> rowsToFollow = new Stack<>();
! rowsToFollow.push(Integer.valueOf(1));
rowNumMap[1] = 1;
// determine which states are no longer reachable from the start state
// (the reachable states will have their row numbers in the row number
// map, and the nonreachable states will have zero in the row number map)
*** 1620,1630 ****
for (int i = 0; i < numCategories; i++) {
if (row[i] != 0) {
if (rowNumMap[row[i]] == 0) {
rowNumMap[row[i]] = row[i];
! rowsToFollow.push(new Integer(row[i]));
}
}
}
}
--- 1620,1630 ----
for (int i = 0; i < numCategories; i++) {
if (row[i] != 0) {
if (rowNumMap[row[i]] == 0) {
rowNumMap[row[i]] = row[i];
! rowsToFollow.push(Integer.valueOf(row[i]));
}
}
}
}
< prev index next >