/**
 * Crawls text for relevant characters during parsing.
 */ export class TextParsing { /**
     * Characters not considered to be part of command names.
     */ private static nonCommandNameCharacters = new Set ( [ "}" , ":" ] ) ; /**
     * Characters not considered to be pure text parts of words.
     */ private static nonWordCharacters = new Set ( [ " " , "{" , "(" , "}" , ":" ] ) ; param text param start returns public static getNextNonSpaceIndex ( text , start ) { while ( start < text . length ) { if ( text [ start ] !== " " ) { return start ; } start += 1 ; } return text . length ; } param text param start returns public static getNextStartOfWordIndex ( text , start ) { while ( start < text . length ) { if ( ! TextParsing . nonWordCharacters . has ( text [ start ] ) ) { return start ; } start += 1 ; } return - 1 ; } param text param start returns public static getNextEndOfCommandNameIndex ( text , start ) { while ( start < text . length ) { if ( TextParsing . nonCommandNameCharacters . has ( text [ start ] ) ) { return start ; } start += 1 ; } return text . length ; } param text param i returns public static getNextEndOfWordIndex ( text , i ) { while ( i < text . length ) { if ( TextParsing . nonWordCharacters . has ( text [ i ] ) ) { return i ; } i += 1 ; } return text . length ; } param text param start returns public static getNextEndOfParenthesisWordIndex ( text , start ) { while ( start < text . length ) { if ( text [ start ] === "\\" ) { start += 3 ; continue ; } if ( text [ start ] === ")" ) { return start ; } start += 1 ; } return start ; } param word returns public static removeBackslashesFromWord ( word ) { let result = "" ; for ( let i = 0 ; i < word . length ; i += 1 ) { if ( word [ i ] === "\\" && i < word . length - 1 && word [ i + 1 ] === ")" ) { i += 1 ; } result += word [ i ] ; } return result ; } }