MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / parse_expr

Function parse_expr

MathBox/mathbox-core.js:33334–33368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33332
33333
33334 function parse_expr() {
33335 var expecting = state[0].expecting
33336
33337 state[0].tokens = state[0].tokens || []
33338
33339 if(state[0].parenlevel === undefined) {
33340 state[0].parenlevel = 0
33341 state[0].bracelevel = 0
33342 }
33343 if(state[0].parenlevel < 1 && expecting.indexOf(token.data) > -1) {
33344 return parseexpr(state[0].tokens)
33345 }
33346 if(token.data === '(') {
33347 ++state[0].parenlevel
33348 } else if(token.data === ')') {
33349 --state[0].parenlevel
33350 }
33351
33352 switch(token.data) {
33353 case '{': ++state[0].bracelevel; break
33354 case '}': --state[0].bracelevel; break
33355 case '(': ++state[0].parenlevel; break
33356 case ')': --state[0].parenlevel; break
33357 }
33358
33359 if(state[0].parenlevel < 0) return unexpected('unexpected `)`')
33360 if(state[0].bracelevel < 0) return unexpected('unexpected `}`')
33361
33362 state[0].tokens.push(tokens.shift())
33363 return
33364
33365 function parseexpr(tokens) {
33366 return full_parse_expr(state, tokens), state.shift()
33367 }
33368 }
33369
33370 // node types ---------------
33371

Callers 1

writeFunction · 0.70

Calls 2

parseexprFunction · 0.70
unexpectedFunction · 0.70

Tested by

no test coverage detected