@@ -1,24 +1,71 @@
11+++
22
33title = "Treesitter Hoon Parser"
4−date = "2023-03-02"
4+date = "2023-05-11"
55
66[taxonomies]
7−grant_type = ["RFP"]
7+grant_type = ["Proposal"]
88grant_category = ["Core Dev"]
99
1010[extra]
1111image = ""
1212description = "Create a better hoon parser with Treesitter"
13−reward = "TBD"
14−assignee = [""]
13+reward = "2 Stars"
14+assignee = ["~hosweg-silpur"]
1515champion = [""]
16−grant_id = "P1001"
16+grant_id = "P0263"
1717completed = false
1818canceled = false
1919
2020+++
2121
22−[Tree-sitter](https://github.com/tree-sitter/tree-sitter) represents the state of the art for multi-language parsing. It is used by Atom and Github to parse any language, on every keystroke, in an editor.
22+# Summary
2323
24−Use tree-sitter to write a superior hoon parser.
24+Tree-sitter is a fast parser that supports smarter syntax highlighting that makes use of the syntax tree.
25+
26+# Background
27+
28+Current syntax-highlighters are based off complicated regex that are overly complicated and inaccurate. Tree-sitter parses the whole document and creates an abstract syntax tree (AST) which can then be used to correctly highlight syntax.
29+
30+The current syntax highlighters available for hoon are:
31+
32+- **Hoon-lsp**: Decent, but due to being a semantic highlighter it naively highlights using regex matches. As an example it does not know the difference between `!=(a)` and `!=(a 1)`. (The first is the `zaptis` rune taking `a` as a sample, the second is `!` applied to an equality check between `a` and `1`)
33+
34+- **Hoon.vim/hoon-mode.el**(emacs package): This is also a regex matcher and suffers from the same problems above.
35+
36+In conclusion, creating a tree-sitter parser will allow for superior Hoon highlighting to be used in more code-editors.
37+
38+
39+# Milestones and Compensation
40+## Milestone 1: Writing the grammar
41+
42+**Estimated Completion**: Completed
43+
44+**Payment**: 1 star
45+
46+ - Write a tree-sitter grammar that parses Hoon
47+ - Create unit tests for each syntax component (runes, irregular syntax, mold, strings...)
48+
49+
50+## Milestone 2: Code editor Integration
51+
52+**Estimated Completion**: May 2023
53+
54+**Payment**: 1 star
55+
56+Integrate the tree-sitter parser with various code-editors.
57+
58+Desktop editors:
59+ - VScode
60+ - Emacs
61+ - Neovim
62+ - Atom
63+Online editors:
64+ - Monaco
65+ - Codemirror
66+
67+# Future Work
68+
69+- GitHub Gist alternative on Urbit
70+- Online IDE with `%pyro` sandbox
71+- Collaborative Hoon code-editing with CRDTs