Show What's Parsed In Tree-Sitter Tests

Notes
  • Install graphviz

    (e.g. `brew install graphviz``)

  • Run tests with:

    tree-sitter test -D -f file-to-test.txt

    (TBD on if you need to have the full path to the file or the name of the test in the test suite)

  • The `-D`` flag produces a log.html file and attempts to open it automatically

  • The `-f`` flag points to a specific file. I do this since there's a lot of stuff that happens for each test and it makes it easier to see what's up

  • Scroll all the way down to see the final output. I find it easier to read errors with that format

    Here's an example of what it looks like:

The Test

===============
Title Section 1
===============
-- title
 
basic
---

(source_file
    (title_section
        (title_token)
        (empty_line)
        (title_headline
            (paragraph_first_word)
        )
    )
)

The Output

new_parse process version:0, version_count:1, state:1, row:0, col:0 lex_internal state:10, row:0, column:0 lexed_lookahead sym:title_token, size:8 shift state:10 stack node_head_0 node_0x6000001284b0 10 node_head_0->node_0x6000001284b0 0 node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token process version:0, version_count:1, state:10, row:0, col:8 lex_internal state:2, row:0, column:8 lexed_lookahead sym:empty_line, size:1 shift state:2 stack node_head_0 node_0x6000001285a0 2 node_head_0->node_0x6000001285a0 0 node_0x6000001284b0 10 node_0x6000001285a0->node_0x6000001284b0 empty_line node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token process version:0, version_count:1, state:2, row:1, col:0 lex_internal state:8, row:1, column:0 lexed_lookahead sym:whitespace, size:1 shift state:12 stack node_head_0 node_0x600000128690 12 node_head_0->node_0x600000128690 0 node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001284b0 10 node_0x6000001285a0->node_0x6000001284b0 empty_line node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token process version:0, version_count:1, state:12, row:1, col:1 lex_internal state:2, row:1, column:1 lexed_lookahead sym:empty_line, size:1 detect_error stack node_head_0 node_0x600000128690 12 node_head_0->node_0x600000128690 0 node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001284b0 10 node_0x6000001285a0->node_0x6000001284b0 empty_line node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token resume version:0 recover_to_previous state:10, depth:3 stack node_head_0 node_0x600000128780 ? node_head_0->node_0x600000128780 0 node_0x600000128690 12 node_0x600000128780->node_0x600000128690 node_head_1 node_0x600000128870 node_head_1->node_0x600000128870 1 node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token node_0x6000001285a0->node_0x6000001284b0 empty_line skip_token symbol:empty_line stack node_head_0 node_0x600000128960 ? node_head_0->node_0x600000128960 0 node_0x600000128780 ? node_0x600000128960->node_0x600000128780 _ERROR node_head_1 node_0x600000128870 node_head_1->node_0x600000128870 1 node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x600000128690 12 node_0x600000128780->node_0x600000128690 node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001285a0->node_0x6000001284b0 empty_line process version:0, version_count:2, state:0, row:2, col:0 lex_internal state:0, row:2, column:0 lexed_lookahead sym:word, size:5 recover_to_previous state:12, depth:2 stack node_head_0 node_0x600000128960 ? node_head_0->node_0x600000128960 0 node_0x600000128780 ? node_0x600000128960->node_0x600000128780 _ERROR node_head_1 node_0x600000128870 node_head_1->node_0x600000128870 1 node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_head_2 node_0x600000128a50 node_head_2->node_0x600000128a50 2 node_0x600000128690 12 node_0x600000128a50->node_0x600000128690 ERROR node_0x600000128780->node_0x600000128690 node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001285a0->node_0x6000001284b0 empty_line skip_token symbol:word stack node_head_0 node_0x600000128960 ? node_head_0->node_0x600000128960 0 node_0x600000128780 ? node_0x600000128960->node_0x600000128780 _ERROR node_head_1 node_0x600000128870 node_head_1->node_0x600000128870 1 node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_head_2 node_0x600000128a50 node_head_2->node_0x600000128a50 2 node_0x600000128690 12 node_0x600000128a50->node_0x600000128690 ERROR node_0x600000128780->node_0x600000128690 node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001285a0->node_0x6000001284b0 empty_line process version:1, version_count:3, state:10, row:1, col:1 lex_internal state:2, row:1, column:1 lexed_lookahead sym:empty_line, size:1 shift state:2 stack node_head_0 node_0x600000128960 ? node_head_0->node_0x600000128960 0 node_0x600000128780 ? node_0x600000128960->node_0x600000128780 _ERROR node_head_1 node_0x600000128b40 2 node_head_1->node_0x600000128b40 1 node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_head_2 node_0x600000128a50 node_head_2->node_0x600000128a50 2 node_0x600000128690 12 node_0x600000128a50->node_0x600000128690 ERROR node_0x600000128780->node_0x600000128690 node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token node_0x6000001285a0->node_0x6000001284b0 empty_line process version:1, version_count:3, state:2, row:2, col:0 lex_internal state:8, row:2, column:0 lexed_lookahead sym:paragraph_first_word, size:5 shift state:3 stack node_head_0 node_0x600000128960 ? node_head_0->node_0x600000128960 0 node_0x600000128780 ? node_0x600000128960->node_0x600000128780 _ERROR node_head_1 node_0x600000128c30 3 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 paragraph_first_word node_head_2 node_0x600000128a50 node_head_2->node_0x600000128a50 2 node_0x600000128690 12 node_0x600000128a50->node_0x600000128690 ERROR node_0x600000128780->node_0x600000128690 node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001285a0->node_0x6000001284b0 empty_line node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token process version:2, version_count:3, state:12, row:2, col:0 lex_internal state:2, row:2, column:0 lexed_lookahead sym:word, size:5 shift state:7 stack node_head_0 node_0x600000128960 ? node_head_0->node_0x600000128960 0 node_0x600000128780 ? node_0x600000128960->node_0x600000128780 _ERROR node_head_1 node_0x600000128c30 3 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 paragraph_first_word node_head_2 node_0x600000128d20 7 node_head_2->node_0x600000128d20 2 node_0x600000128a50 node_0x600000128d20->node_0x600000128a50 word node_0x600000128690 12 node_0x600000128780->node_0x600000128690 node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x600000128a50->node_0x600000128690 ERROR node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001285a0->node_0x6000001284b0 empty_line node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token condense stack node_head_0 node_0x600000128d20 7 node_head_0->node_0x600000128d20 0 node_0x600000128a50 node_0x600000128d20->node_0x600000128a50 word node_head_1 node_0x600000128c30 3 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 paragraph_first_word node_0x600000128690 12 node_0x600000128a50->node_0x600000128690 ERROR node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 whitespace node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001285a0->node_0x6000001284b0 empty_line node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token process version:0, version_count:2, state:7, row:2, col:5 lex_internal state:10, row:2, column:5 lexed_lookahead sym:end, size:0 reduce sym:paragraph_repeat1, child_count:2 stack node_head_0 node_0x600000128780 3 node_head_0->node_0x600000128780 0 node_0x6000001285a0 2 node_0x600000128780->node_0x6000001285a0 paragraph_repeat1 node_head_1 node_0x600000128c30 3 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 paragraph_first_word node_0x6000001284b0 10 node_0x6000001285a0->node_0x6000001284b0 empty_line node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token node_0x600000128870->node_0x6000001284b0 ERROR reduce sym:title_headline, child_count:1 stack node_head_0 node_0x600000128690 8 node_head_0->node_0x600000128690 0 node_0x6000001285a0 2 node_0x600000128690->node_0x6000001285a0 'title_headline' node_head_1 node_0x600000128c30 3 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 paragraph_first_word node_0x6000001284b0 10 node_0x6000001285a0->node_0x6000001284b0 empty_line node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token node_0x600000128870->node_0x6000001284b0 ERROR reduce sym:title_headline, child_count:1 stack node_head_0 node_0x600000128780 9 node_head_0->node_0x600000128780 0 node_0x6000001285a0 2 node_0x600000128780->node_0x6000001285a0 title_headline node_head_1 node_0x600000128c30 3 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 paragraph_first_word node_0x6000001284b0 10 node_0x6000001285a0->node_0x6000001284b0 empty_line node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token node_0x600000128870->node_0x6000001284b0 ERROR reduce sym:title_section, child_count:3 stack node_head_0 node_0x600000128690 5 node_head_0->node_0x600000128690 0 node_0x6000001283c0 1 node_0x600000128690->node_0x6000001283c0 title_section node_head_1 node_0x600000128c30 3 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 paragraph_first_word node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001284b0->node_0x6000001283c0 title_token reduce sym:source_file, child_count:1 stack node_head_0 node_0x6000001285a0 11 node_head_0->node_0x6000001285a0 0 node_0x6000001283c0 1 node_0x6000001285a0->node_0x6000001283c0 source_file node_head_1 node_0x600000128c30 3 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 paragraph_first_word node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001284b0->node_0x6000001283c0 title_token accept stack node_head_1 node_0x600000128c30 3 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 paragraph_first_word node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token process version:1, version_count:2, state:3, row:2, col:5 reduce sym:title_headline, child_count:1 stack node_head_1 node_0x600000128780 8 node_head_1->node_0x600000128780 1 node_0x600000128b40 2 node_0x600000128780->node_0x600000128b40 'title_headline' node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token reduce sym:title_headline, child_count:1 stack node_head_1 node_0x600000128c30 9 node_head_1->node_0x600000128c30 1 node_0x600000128b40 2 node_0x600000128c30->node_0x600000128b40 title_headline node_0x600000128870 node_0x600000128b40->node_0x600000128870 empty_line node_0x6000001284b0 10 node_0x600000128870->node_0x6000001284b0 ERROR node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 title_token reduce sym:title_section, child_count:3 stack node_head_1 node_0x600000128780 5 node_head_1->node_0x600000128780 1 node_0x6000001283c0 1 node_0x600000128780->node_0x6000001283c0 title_section reduce sym:source_file, child_count:1 stack node_head_1 node_0x6000001284b0 11 node_head_1->node_0x6000001284b0 1 node_0x6000001283c0 1 node_0x6000001284b0->node_0x6000001283c0 source_file accept select_smaller_error symbol:source_file, over_symbol:source_file stack done tree tree_0x16f92c880 source_file tree_0x600001a244e0 title_section tree_0x16f92c880->tree_0x600001a244e0 tree_0x600001a244e8 end tree_0x16f92c880->tree_0x600001a244e8 tree_0x600001528230 title_token tree_0x600001a244e0->tree_0x600001528230 tree_0x600001528238 empty_line tree_0x600001a244e0->tree_0x600001528238 tree_0x600001528240 title_headline tree_0x600001a244e0->tree_0x600001528240 tree_0x600001a24420 title_headline tree_0x600001528240->tree_0x600001a24420 tree_0x600001a243c0 paragraph_repeat1 tree_0x600001a24420->tree_0x600001a243c0 tree_0x6000015282a0 whitespace tree_0x600001a243c0->tree_0x6000015282a0 tree_0x6000015282a8 ERROR tree_0x600001a243c0->tree_0x6000015282a8 tree_0x6000015282b0 word tree_0x600001a243c0->tree_0x6000015282b0 tree_0x600001a24360 _ERROR tree_0x6000015282a8->tree_0x600001a24360 tree_0x600001a24300 empty_line tree_0x600001a24360->tree_0x600001a24300