(id)
| 79406 | } |
| 79407 | |
| 79408 | function advance(id) { |
| 79409 | var next |
| 79410 | , value |
| 79411 | , type |
| 79412 | , output |
| 79413 | |
| 79414 | if(id && token.data !== id) { |
| 79415 | return state.unexpected('expected `'+ id + '`, got `'+token.data+'`') |
| 79416 | } |
| 79417 | |
| 79418 | if(idx >= tokens.length) { |
| 79419 | token = symbol_table['(end)'] |
| 79420 | return |
| 79421 | } |
| 79422 | |
| 79423 | next = tokens[idx++] |
| 79424 | value = next.data |
| 79425 | type = next.type |
| 79426 | |
| 79427 | if(type === 'ident') { |
| 79428 | output = state.scope.find(value) || state.create_node() |
| 79429 | type = output.type |
| 79430 | } else if(type === 'builtin') { |
| 79431 | output = symbol_table['(builtin)'] |
| 79432 | } else if(type === 'keyword') { |
| 79433 | output = symbol_table['(keyword)'] |
| 79434 | } else if(type === 'operator') { |
| 79435 | output = symbol_table[value] |
| 79436 | if(!output) { |
| 79437 | return state.unexpected('unknown operator `'+value+'`') |
| 79438 | } |
| 79439 | } else if(type === 'float' || type === 'integer') { |
| 79440 | type = 'literal' |
| 79441 | output = symbol_table['(literal)'] |
| 79442 | } else { |
| 79443 | return state.unexpected('unexpected token.') |
| 79444 | } |
| 79445 | |
| 79446 | if(output) { |
| 79447 | if(!output.nud) { output.nud = itself } |
| 79448 | if(!output.children) { output.children = [] } |
| 79449 | } |
| 79450 | |
| 79451 | output = Object.create(output) |
| 79452 | output.token = next |
| 79453 | output.type = type |
| 79454 | if(!output.data) output.data = value |
| 79455 | |
| 79456 | return token = output |
| 79457 | } |
| 79458 | |
| 79459 | function fail(message) { |
| 79460 | return function() { return state.unexpected(message) } |
no test coverage detected