Re: [GSOC][PATCH] userdiff: add support for Scheme
- From
Atharva Raykar <raykar.ath@gmail.com>
- Date
- Mar 28, 2021, 12:45 UTC
- Message-ID
- <166B3835-32C3-4CE6-9799-C187284E5756@gmail.com>
- In-Reply-To
- <xmqq1rc0qjn1.fsf@gitster.g>
On 28-Mar-2021, at 04:39, Junio C Hamano <gitster@pobox.com> wrote:
Show 36 quoted lines
>
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Atharva Raykar <raykar.ath@gmail.com> writes:
>> ...
>>> + (ChangeMe 'suite-name tests)))))))
>>> \ No newline at end of file
>>
>> Is there a good reason to leave the final line incomplete? ...
>> I am also trying to figure out what you wanted to achieve ...
>
> Taking all of them together, here is what I hope you may agree as
> its improved version. The only differences from what you posted are
> corrections to all the "\ No newline at end of file" and the simplification
> of the pattern (remove "a dot" from the alternative and add \t next
> to SP). Without changes, the new tests still pass so ... ;-)
>
> diff --git c/userdiff.c w/userdiff.c
> index 5fd0eb31ec..685fe712aa 100644
> --- c/userdiff.c
> +++ w/userdiff.c
> @@ -193,12 +193,8 @@ PATTERNS("rust",
> "|[-+*\\/<>%&^|=!:]=|<<=?|>>=?|&&|\\|\\||->|=>|\\.{2}=|\\.{3}|::"),
> PATTERNS("scheme",
> "^[\t ]*(\\(define-?.*)$",
> - /*
> - * Scheme allows symbol names to have any character,
> - * as long as it is not a form of a parenthesis.
> - * The spaces must be escaped.
> - */
> - "(\\.|[^][)(\\}\\{ ])+"),
> + /* whitespace separated tokens, but parentheses also can delimit words */
> + "([^][)(\\}\\{ \t])+"),
> PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$",
> "[={}\"]|[^={}\" \t]+"),
> PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",Thanks for these. I will eventually send another patch with the whitespaces corrected, and try to see if there is a better way to handle backslashes, other than the regex I suggested. I will also be writing another test case to check that case properly.
I will also incorporate the other changes suggested by Johannes and Ævar as well, My regex was not supposed to capture forms like `defined-thing`. And there are a few rough edges with some of my test cases, which I will correct as well in the next patch. It is also worth spending some more time and see if there is any other form other than definitions that a Scheme programmer other than myself may be interested in. I will consult a few Scheme communities and mailing lists and see what more experienced programmers have to say.