($TEXT, strict_mode, embed_tokens)
| 613 | NodeWithToken.prototype.toString = function() { return this.name; }; |
| 614 | |
| 615 | function parse($TEXT, strict_mode, embed_tokens) { |
| 616 | |
| 617 | var S = { |
| 618 | input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT, |
| 619 | token : null, |
| 620 | prev : null, |
| 621 | peeked : null, |
| 622 | in_function : 0, |
| 623 | in_loop : 0, |
| 624 | labels : [] |
| 625 | }; |
| 626 | |
| 627 | S.token = next(); |
| 628 | |
| 629 | function is(type, value) { |
| 630 | return is_token(S.token, type, value); |
| 631 | }; |
| 632 | |
| 633 | function peek() { return S.peeked || (S.peeked = S.input()); }; |
| 634 | |
| 635 | function next() { |
| 636 | S.prev = S.token; |
| 637 | if (S.peeked) { |
| 638 | S.token = S.peeked; |
| 639 | S.peeked = null; |
| 640 | } else { |
| 641 | S.token = S.input(); |
| 642 | } |
| 643 | return S.token; |
| 644 | }; |
| 645 | |
| 646 | function prev() { |
| 647 | return S.prev; |
| 648 | }; |
| 649 | |
| 650 | function croak(msg, line, col, pos) { |
| 651 | var ctx = S.input.context(); |
| 652 | js_error(msg, |
| 653 | line != null ? line : ctx.tokline, |
| 654 | col != null ? col : ctx.tokcol, |
| 655 | pos != null ? pos : ctx.tokpos); |
| 656 | }; |
| 657 | |
| 658 | function token_error(token, msg) { |
| 659 | croak(msg, token.line, token.col); |
| 660 | }; |
| 661 | |
| 662 | function unexpected(token) { |
| 663 | if (token == null) |
| 664 | token = S.token; |
| 665 | token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")"); |
| 666 | }; |
| 667 | |
| 668 | function expect_token(type, val) { |
| 669 | if (is(type, val)) { |
| 670 | return next(); |
| 671 | } |
| 672 | token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type); |
nothing calls this directly
no test coverage detected
searching dependent graphs…