mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-28 10:37:41 +00:00
refactor(common/lmlayer): extract function: appendToTopOfStack()
This commit is contained in:
parent
301870f7d7
commit
ceca35cccb
1 changed files with 9 additions and 6 deletions
|
|
@ -41,9 +41,7 @@ namespace wordBreakers {
|
|||
if (includes(delimiters, span.text)) {
|
||||
// well, now we should join them!
|
||||
if (spansAreBackToBack(lastFrom(stack), span)) {
|
||||
let top = stack.pop();
|
||||
let joinedSpan = concatenateSpans(top, span);
|
||||
stack.push(joinedSpan);
|
||||
appendToTopOfStack(span);
|
||||
} else {
|
||||
stack.push(span);
|
||||
}
|
||||
|
|
@ -62,9 +60,7 @@ namespace wordBreakers {
|
|||
break;
|
||||
}
|
||||
|
||||
let top = stack.pop();
|
||||
let joinedSpan = concatenateSpans(top, span);
|
||||
stack.push(joinedSpan);
|
||||
appendToTopOfStack(span);
|
||||
|
||||
if (includes(delimiters, span.text)) {
|
||||
state = State.JOINED;
|
||||
|
|
@ -76,8 +72,15 @@ namespace wordBreakers {
|
|||
}
|
||||
|
||||
return stack;
|
||||
|
||||
function appendToTopOfStack(span: Span) {
|
||||
let top = stack.pop();
|
||||
let joinedSpan = concatenateSpans(top, span);
|
||||
stack.push(joinedSpan);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true when the spans are contiguous.
|
||||
* Order matters when calling this function!
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue