Support mode changing syntax
Changes that are only permissions take the shape `old/new mode <mode>`.
Expose the similarity score as a named node
It was previously a field, but a field is an impossible pattern for a
regex literal like we use for score. I.e.:
(similarity score: _ @_some_capture_)
Cannot match and on recent tree-sitter versions will cause an error
during query analysis.
Expose diff argument as a named 'argument' node
Remove '--git' assumption
Assume that any string is fine. If it's a different diff format then the
parser will fail anyways.
Organize changes into hunks
This introduces some hierarchy for the nodes so that each
'diff --git a b' command is a block which can have 'hunks'. Each 'hunk'
has a 'location' and a set of 'changes' under it which contain the
'addition's, 'deletion's and 'context' nodes.
Run CI on pushes and pull requests
Parse three or more '+'s as additions
Fix highlighting diff of diffs
The symbol ++ is valid when the diff is showing another diff,
e.g. when committing a diff file to a repository.
Fix deletions with multiple leading dashes
Deleted lines may start with the leading dash "-" but then the line
itself may contain an arbitrary number of dashes. This change parses
any number of leading dashes as a deletion except for the triple
leading dash which is considered to be an old file marker.
These cases should have been valid parse examples before but were
marked as errors because of the contention between the deletion
and old_file rules and error recovery.
Connects #1
Only list diff as supported file-types
Bump tree-sitter-cli to 0.20.7
Mark lines starting with '--' as deletions
Gneerate parser on latest tree-sitter
remove generated wasm bindings
push generated wasm binding to the gh-pages branch
use custom action for generating the parser commit
rebrand as tree-sitter-diff
mark tree-sitter-generated files as generated
add readme section on grammar design
add example highlights to readme
add CI and parser generation actions workflows
add playground in docs dir
add test cases for locations within diffs
clean up line repetition rules
make grammar more resilient to (lack-of) newlines
rename to tree-sitter-git-diff
separate out nodes for old and new files
use a regex instead of a choice for file declarations
test case for 'no newline at end of file'
parse locations without context
add test case for binary file deletion
add rule parse binary changes
reorganize 'seq's with 'iseq' helper
separate out percentage from similarity score
remove unecessary prec rules
parse new and deleted files
parse a simple text-file based example
setup newline and placeholder for extras
add test case files for texts and binaries
generate 'hello world' of grammars
add npm package declaration