nl_tokens: / * Extract a punctuator out of the next sequence of characters or return null if its not possible .
pl_tokens: function ( ) { var ch1 = this . peek ( ) ; var ch2 , ch3 , ch4 ; switch ( ch1 ) { // Most common single-character punctuators case "." : if ( ( / ^[0-9]$ / ) . test ( this . peek ( 1 ) ) ) { return null ; } if ( this . peek ( 1 ) === "." && this . peek ( 2 ) === "." ) { return { type : Token . Punctuator , value : "..." } ; } /* falls through */ case "(" : case ")" : case ";" : case "," : case "[" : case "]" : case ":" : case "~" : case "?" : return { type : Token . Punctuator , value : ch1 } ; // A block/object opener case "{" : this . pushContext ( Context . Block ) ; return { type : Token . Punctuator , value : ch1 } ; // A block/object closer case "}" : if ( this . inContext ( Context . Block ) ) { this . popContext ( ) ; } return { type : <mask> . Punctuator , value : ch1 } ; // A pound sign (for Node shebangs) case "#" : return { type : Token . Punctuator , value : ch1 } ; // We're at the end of input case "" : return null ; } // Peek more characters ch2 = this . peek ( 1 ) ; ch3 = this . peek ( 2 ) ; ch4 = this . peek ( 3 ) ; // 4-character punctuator: >>>= if ( ch1 === ">" && ch2 === ">" && ch3 === ">" && ch4 === "=" ) { return { type : Token . Punctuator , value : ">>>=" } ; } // 3-character punctuators: === !== >>> <<= >>= if ( ch1 === "=" && ch2 === "=" && ch3 === "=" ) { return { type : Token . Punctuator , value : "===" } ; } if ( ch1 === "!" && ch2 === "=" && ch3 === "=" ) { return { type : Token . Punctuator , value : "!==" } ; } if ( ch1 === ">" && ch2 === ">" && ch3 === ">" ) { return { type : Token . Punctuator , value : ">>>" } ; } if ( ch1 === "<" && ch2 === "<" && ch3 === "=" ) { return { type : Token . Punctuator , value : "<<=" } ; } if ( ch1 === ">" && ch2 === ">" && ch3 === "=" ) { return { type : Token . Punctuator , value : ">>=" } ; } // Fat arrow punctuator if ( ch1 === "=" && ch2 === ">" ) { return { type : Token . Punctuator , value : ch1 + ch2 } ; } // 2-character punctuators: <= >= == != ++ -- << >> && || // += -= *= %= &= |= ^= (but not /=, see below) if ( ch1 === ch2 && ( "+-<>&|" . indexOf ( ch1 ) >= 0 ) ) { return { type : Token . Punctuator , value : ch1 + ch2 } ; } if ( "<>=!+-*%&|^" . indexOf ( ch1 ) >= 0 ) { if ( ch2 === "=" ) { return { type : Token . Punctuator , value : ch1 + ch2 } ; } return { type : Token . Punctuator , value : ch1 } ; } // Special case: /=. if ( ch1 === "/" ) { if ( ch2 === "=" ) { return { type : Token . Punctuator , value : "/=" } ; } return { type : Token . Punctuator , value : "/" } ; } return null ; }