import { charCodes } from "./charcodes" ; export const WHITESPACE_CHARS = [ 0x0009 , 0x000b , 0x000c , u16 ( charCodes . space ) , u16 ( charCodes . nonBreakingSpace ) , u16 ( charCodes . oghamSpaceMark ) , 0x2000 , 0x2001 , 0x2002 , 0x2003 , 0x2004 , 0x2005 , 0x2006 , 0x2007 , 0x2008 , 0x2009 , 0x200a , 0x202f , 0x205f , 0x3000 , 0xfeff , ] ; class SkipWhiteSpaceRegexLike { lastIndex : i32 = 0 ; exec ( text ) { let matchedRange = 0 ; let index = this . lastIndex ; while ( true ) { if ( index >= text . length ) { break ; } const char = text . charCodeAt ( index ) ; if ( IS_WHITESPACE [ char ] === 1 ) { matchedRange ++ ; index ++ ; } else if ( char === charCodes . slash ) { const look = text . charCodeAt ( index + 1 ) ; if ( look === charCodes . slash ) { index += 2 ; matchedRange += 2 ; while ( index < text . length ) { const c = text . charCodeAt ( index ) ; if ( c === charCodes . lineFeed || c === charCodes . carriageReturn ) { break ; } else { matchedRange ++ ; index ++ ; } } } else if ( look === charCodes . asterisk ) { let commentMatch = 2 ; index += 2 ; while ( index < text . length ) { if ( text . charCodeAt ( index ) === charCodes . asterisk ) { if ( text . charCodeAt ( index + 1 ) === charCodes . slash ) { matchedRange += commentMatch + 2 ; index += 2 ; break ; } else { commentMatch ++ ; index ++ ; } } else { commentMatch ++ ; index ++ ; } } } else { break ; } } else { break ; } } this . lastIndex += matchedRange ; return matchedRange ; } } export const skipWhiteSpace = new SkipWhiteSpaceRegexLike ( ) ; export const IS_WHITESPACE = new Uint8Array ( 65536 ) ; for ( let i = 0 ; i < WHITESPACE_CHARS . length ; i ++ ) { IS_WHITESPACE [ WHITESPACE_CHARS [ i ] ] = 1 ; }