nl_tokens: adds an indentifier to the relevant current scope and creates warnings / errors as necessary name : string opts : { type : string token : token isblockscoped : bool }
pl_tokens: function addlabel ( name , opts ) { var type = opts . type ; var token = opts . token ; var isblockscoped = opts . isblockscoped ; // Define label in the current function in the current scope. if ( type === "exception" ) { if ( _ . has ( funct [ "(context)" ] , name ) ) { if ( funct [ name ] !== true && ! state . option . node ) { warning ( "W002" , state . tokens . next , name ) ; } } } if ( _ . has ( funct , name ) && ! funct [ "(global)" ] ) { if ( funct [ name ] === true ) { if ( state . option . latedef ) { if ( ( state . option . latedef === true && _ . contains ( [ funct [ name ] , type ] , "unction" ) ) || ! _ . contains ( [ funct [ name ] , type ] , "unction" ) ) { warning ( "W003" , state . tokens . next , name ) ; } } } else { if ( ( ! state . option . shadow || _ . contains ( [ "inner" , "outer" ] , state . option . shadow ) ) && type !== "exception" || funct [ "(blockscope)" ] . getlabel ( name ) ) { warning ( "W004" , state . tokens . next , name ) ; } } } if ( funct [ "(context)" ] && _ . has ( funct [ "(context)" ] , name ) && type !== "function" ) { if ( state . option . shadow === "outer" ) { warning ( "W123" , <mask> . tokens . next , name ) ; } } // if the identifier is blockscoped (a let or a const), add it only to the current blockscope if ( isblockscoped ) { funct [ "(blockscope)" ] . current . add ( name , type , state . tokens . curr ) ; if ( funct [ "(blockscope)" ] . atTop ( ) && exported [ name ] ) { state . tokens . curr . exported = true ; } } else { funct [ "(blockscope)" ] . shadow ( name ) ; funct [ name ] = type ; if ( token ) { funct [ "(tokens)" ] [ name ] = token ; } if ( funct [ "(global)" ] ) { global [ name ] = funct ; if ( _ . has ( implied , name ) ) { if ( state . option . latedef ) { if ( ( state . option . latedef === true && _ . contains ( [ funct [ name ] , type ] , "unction" ) ) || ! _ . contains ( [ funct [ name ] , type ] , "unction" ) ) { warning ( "W003" , state . tokens . next , name ) ; } } delete implied [ name ] ; } } else { scope [ name ] = funct ; } } }