MCPcopy
hub / github.com/jquerytools/jquerytools / advance

Function advance

lib/jslint.js:103–118  ·  view source on GitHub ↗
(id,t)

Source from the content-addressed store, hash-verified

101j+=1;}
102return t;}
103var badbreak={')':true,']':true,'++':true,'--':true};function advance(id,t){var l;switch(token.id){case'(number)':if(nexttoken.id==='.'){warning("A dot following a number can be confused with a decimal point.",token);}
104break;case'-':if(nexttoken.id==='-'||nexttoken.id==='--'){warning("Confusing minusses.");}
105break;case'+':if(nexttoken.id==='+'||nexttoken.id==='++'){warning("Confusing plusses.");}
106break;}
107if(token.type==='(string)'||token.identifier){anonname=token.value;}
108if(id&&nexttoken.id!==id){if(t){if(nexttoken.id==='(end)'){warning("Unmatched '{a}'.",t,t.id);}else{warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",nexttoken,id,t.id,t.line+1,nexttoken.value);}}else if(nexttoken.type!=='(identifier)'||nexttoken.value!==id){warning("Expected '{a}' and instead saw '{b}'.",nexttoken,id,nexttoken.value);}}
109prevtoken=token;token=nexttoken;for(;;){nexttoken=lookahead.shift()||lex.token();if(nexttoken.type==='special'){doOption();}else{if(nexttoken.id==='<!['){if(option.adsafe){error("ADsafe violation.",nexttoken);}
110if(xtype==='html'){error("Unexpected '{a}'.",nexttoken,'<![');}
111if(xmode==='script'){nexttoken=lex.token();if(nexttoken.value!=='CDATA'){error("Missing '{a}'.",nexttoken,'CDATA');}
112nexttoken=lex.token();if(nexttoken.id!=='['){error("Missing '{a}'.",nexttoken,'[');}
113xmode='CDATA';}else if(xmode==='xml'){lex.skip(']]>');}else{error("Unexpected '{a}'.",nexttoken,'<![');}}else if(nexttoken.id===']]>'){if(xmode==='CDATA'){xmode='script';}else{error("Unexpected '{a}'.",nexttoken,']]>');}}else if(nexttoken.id!=='(endline)'){break;}
114if(xmode==='"'||xmode==="'"){error("Missing '{a}'.",token,xmode);}
115l=!xmode&&!option.laxbreak&&(token.type==='(string)'||token.type==='(number)'||token.type==='(identifier)'||badbreak[token.id]);}}
116if(l){switch(nexttoken.id){case'{':case'}':case']':case'.':break;case')':switch(token.id){case')':case'}':case']':break;default:warning("Line breaking error '{a}'.",token,')');}
117break;default:warning("Line breaking error '{a}'.",token,token.value);}}
118if(xtype==='widget'&&xmode==='script'&&nexttoken.id){l=nexttoken.id.charAt(0);if(l==='<'||l==='&'){nexttoken.nud=nexttoken.led=null;nexttoken.lbp=0;nexttoken.reach=true;}}}
119function parse(rbp,initial){var left,o;if(nexttoken.id==='(end)'){error("Unexpected early end of program.",token);}
120advance();if(option.adsafe&&predefined[token.value]===true&&(nexttoken.id!=='('&&nexttoken.id!=='.')){warning('ADsafe violation.',token);}
121if(initial){anonname='anonymous';funct['(verb)']=token.value;}

Callers 14

parseFunction · 0.85
optionalidentifierFunction · 0.85
statementFunction · 0.85
statementsFunction · 0.85
blockFunction · 0.85
xmlwordFunction · 0.85
xmlFunction · 0.85
jslint.jsFile · 0.85
varstatementFunction · 0.85
functionparamsFunction · 0.85
jsonObjectFunction · 0.85
jsonArrayFunction · 0.85

Calls 3

warningFunction · 0.85
doOptionFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected