-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support git format-patch
diffs
#1
Comments
This grammar focuses only on diff syntax. Patch syntax should be covered in a separate grammar which injects this diff grammar. |
Patch syntax is diff syntax with |
I can't find a formal definition for patch and/or diff (if you can find these, please do link them). My understanding is that patch syntax is a superset of diff - it's additional metadata surrounding a diff section. There is no way to not handle part of a document with tree-sitter: everything must be parsed as something, so adding support for patch would mean parsing all of the patch syntax. A separate tree-sitter-patch grammar would be a reasonable way to approach this, and it could parse the metadata. |
GNU
Ideally, this parser would handle the first three formats. (maybe in separate grammars?)
I suppose you're right as per the Kernel documentation.
I know, but you can parse the |
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
Yeah, the error node should be cleaned up. I have fixed the parsing to produce a I don't use patch format myself so I am uninterested in maintaining a grammar for it. This grammar should serve as a decent example if you would like to tackle it yourself though. |
git format-patch
uses---
to separate the commit body from the summary.This parser expects that to be part of an
old_file
node and returns an error.Here's a random kernel patch and the syntax tree it produces:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/patch/?id=da3b1c2
The text was updated successfully, but these errors were encountered: