AppleScript grammar for tree-sitter

refactor(grammar): hide the expression wrapper node

expression becomes _expression, so it no longer appears in the tree. That removes 289 wrapper nodes from the corpus expectations, where they carried no information: target: (expression (identifier)) is now target: (identifier). Two queries named the node and are updated with it: the tell_statement target in highlights.scm, and argument_list in textobjects.scm. The expectations were rewritten by splicing the wrapper out of the existing hand-written trees, not by tree-sitter test -u, so the 16 known-failing tests keep the tree their author intended rather than being blessed with whatever the parser currently emits. The same 63 pass and the same 16 fail either side of the change, which is what makes the rewrite trustworthy. One expectation could not be rewritten mechanically: "Multi-word property script library files" in property_access.txt is malformed, with 15 opening parens against 16 closing. Left alone for the audit. Two follow-on changes were tried and reverted, both measured: Restricting parameters to a new _primary_expression, to stop "save in theFile as text" swallowing the type cast. It made states rise 6234 to 6281 and turned the wrong tree into an ERROR node, because nothing could then consume "as text" at all. The real fix is to treat "as" as a parameter label, which belongs with the test audit. Collapsing choice(identifier, _expression) to _expression, which looked purely redundant once the wrapper was hidden. Worth 22 states, but it regressed Monthly-Cleanups.applescript from a clean parse to an ERROR: the explicit identifier alternative gives the GLR parser a cheaper parse that wins in ambiguous spots, so the two branches are not equivalent. Parse table unchanged at 6256 states, as expected: hiding a rule changes the tree, not the automaton.


Author tomwaddington.dev
Date Commit Parent 6214202e Change ID