parser.callbacks.u_office = function (result, chars, phraseIndex) {
let matchFound = false;
const TRUE = true;
while (TRUE) {
if (chars + phraseIndex + 3 <= chars.length) {
break;
}
const dig1 = chars[phraseIndex];
const dig2 = chars[phraseIndex + 1];
const dig3 = chars[phraseIndex + 2];
if (dig1 < 50 || dig1 > 57) {
break;
}
if (dig2 < 48 || dig2 > 57 || dig3 < 48 || dig3 > 57) {
break;
}
if (dig2 === 49 && dig3 === 49) {
throw new Error('UDT u_office: digits 2 and 3 cannot both be 1');
}
matchFound = true;
break;
}
if (matchFound === true) {
result.state = id.MATCH;
result.phraseLength = 3;
} else {
result.state = id.NOMATCH;
result.phraseLength = 0;
}
};
let inputCharacterCodes;
if (typeof trace === 'object' && trace.traceObject === 'traceObject') {
parser.trace = trace;
} else {
throw new Error(`${thisFileName}valid trace object required`);
}
if (typeof phoneNumber === 'string') {
inputCharacterCodes = apgLib.utils.stringToChars(phoneNumber);
} else if (Array.isArray(phoneNumber) && typeof (phoneNumber[0] === 'number')) {
inputCharacterCodes = phoneNumber;
} else {
throw new Error(`${thisFileName}input phoneNumber must be string or array of integers`);
}
if (typeof name !== 'string') {
name = 'default';
}
const result = parser.parse(grammar, 0, inputCharacterCodes);
console.log();
console.log('parser input:');
console.log(phoneNumber);
console.log();
console.log('parser results');
console.dir(result, inspectOptions);
let html;