nl_tokens: 7 . 7 Punctuators
pl_tokens: function scanPunctuator ( ) { var start = index , code = source . charCodeAt ( index ) , code2 , ch1 = source [ index ] , ch2 , ch3 , ch4 ; if ( state . inJSXTag || state . inJSXChild ) { // Don't need to check for '{' and '}' as it's already handled // correctly by default. switch ( code ) { case 60 : // < case 62 : // > ++ index ; return { type : Token . Punctuator , value : String . fromCharCode ( code ) , lineNumber : lineNumber , lineStart : lineStart , range : [ start , <mask> ] } ; } } switch ( code ) { // Check for most common single-character punctuators. case 40 : // ( open bracket case 41 : // ) close bracket case 59 : // ; semicolon case 44 : // , comma case 91 : // [ case 93 : // ] case 58 : // : case 63 : // ? case 126 : // ~ ++ index ; if ( extra . tokenize && code === 40 ) { extra . openParenToken = extra . tokens . length ; } return { type : Token . Punctuator , value : String . fromCharCode ( code ) , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; case 123 : // { open curly brace case 125 : // } close curly brace ++ index ; if ( extra . tokenize && code === 123 ) { extra . openCurlyToken = extra . tokens . length ; } // lookahead2 function can cause tokens to be scanned twice and in doing so // would wreck the curly stack by pushing the same token onto the stack twice. // curlyLastIndex ensures each token is pushed or popped exactly once if ( index > state . curlyLastIndex ) { state . curlyLastIndex = index ; if ( code === 123 ) { state . curlyStack . push ( '{' ) ; } else { state . curlyStack . pop ( ) ; } } return { type : Token . Punctuator , value : String . fromCharCode ( code ) , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; default : code2 = source . charCodeAt ( index + 1 ) ; // '=' (char #61) marks an assignment or comparison operator. if ( code2 === 61 ) { switch ( code ) { case 37 : // % case 38 : // & case 42 : // *: case 43 : // + case 45 : // - case 47 : // / case 60 : // < case 62 : // > case 94 : // ^ case 124 : // | index += 2 ; return { type : Token . Punctuator , value : String . fromCharCode ( code ) + String . fromCharCode ( code2 ) , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; case 33 : // ! case 61 : // = index += 2 ; // !== and === if ( source . charCodeAt ( index ) === 61 ) { ++ index ; } return { type : Token . Punctuator , value : source . slice ( start , index ) , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; default : break ; } } break ; } // Peek more characters. ch2 = source [ index + 1 ] ; ch3 = source [ index + 2 ] ; ch4 = source [ index + 3 ] ; // 4-character punctuator: >>>= if ( ch1 === '>' && ch2 === '>' && ch3 === '>' ) { if ( ch4 === '=' ) { index += 4 ; return { type : Token . Punctuator , value : '>>>=' , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; } } // 3-character punctuators: === !== >>> <<= >>= if ( ch1 === '>' && ch2 === '>' && ch3 === '>' && ! state . inType ) { index += 3 ; return { type : Token . Punctuator , value : '>>>' , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; } if ( ch1 === '<' && ch2 === '<' && ch3 === '=' ) { index += 3 ; return { type : Token . Punctuator , value : '<<=' , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; } if ( ch1 === '>' && ch2 === '>' && ch3 === '=' ) { index += 3 ; return { type : Token . Punctuator , value : '>>=' , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; } if ( ch1 === '.' && ch2 === '.' && ch3 === '.' ) { index += 3 ; return { type : Token . Punctuator , value : '...' , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; } // Other 2-character punctuators: ++ -- << >> && || // Don't match these tokens if we're in a type, since they never can // occur and can mess up types like Map<string, Array<string>> if ( ch1 === ch2 && ( '+-<>&|' . indexOf ( ch1 ) >= 0 ) && ! state . inType ) { index += 2 ; return { type : Token . Punctuator , value : ch1 + ch2 , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; } if ( ch1 === '=' && ch2 === '>' ) { index += 2 ; return { type : Token . Punctuator , value : '=>' , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; } if ( '<>=!+-*%&|^/' . indexOf ( ch1 ) >= 0 ) { ++ index ; return { type : Token . Punctuator , value : ch1 , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; } if ( ch1 === '.' ) { ++ index ; return { type : Token . Punctuator , value : ch1 , lineNumber : lineNumber , lineStart : lineStart , range : [ start , index ] } ; } throwError ( { } , Messages . UnexpectedToken , 'ILLEGAL' ) ; }