* Parse a block with expressions. Expressions can be separated by a newline * character '\n', or by a semicolon ';'. In case of a semicolon, no output * of the preceding line is returned. * @return {Node} node * @private
(state)
| 642 | * @private |
| 643 | */ |
| 644 | function parseBlock (state) { |
| 645 | let node |
| 646 | const blocks = [] |
| 647 | let visible |
| 648 | |
| 649 | if (state.token !== '' && state.token !== '\n' && state.token !== ';') { |
| 650 | node = parseAssignment(state) |
| 651 | if (state.comment) { |
| 652 | node.comment = state.comment |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | // TODO: simplify this loop |
| 657 | while (state.token === '\n' || state.token === ';') { // eslint-disable-line no-unmodified-loop-condition |
| 658 | if (blocks.length === 0 && node) { |
| 659 | visible = (state.token !== ';') |
| 660 | blocks.push({ node, visible }) |
| 661 | } |
| 662 | |
| 663 | getToken(state) |
| 664 | if (state.token !== '\n' && state.token !== ';' && state.token !== '') { |
| 665 | node = parseAssignment(state) |
| 666 | if (state.comment) { |
| 667 | node.comment = state.comment |
| 668 | } |
| 669 | |
| 670 | visible = (state.token !== ';') |
| 671 | blocks.push({ node, visible }) |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | if (blocks.length > 0) { |
| 676 | return new BlockNode(blocks) |
| 677 | } else { |
| 678 | if (!node) { |
| 679 | node = new ConstantNode(undefined) |
| 680 | if (state.comment) { |
| 681 | node.comment = state.comment |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | return node |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * Assignment of a function or variable, |
no test coverage detected
searching dependent graphs…