git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add userdiff patterns for Ada
@ 2012-09-16  3:54 Adrian Johnson
  2012-09-16  6:07 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian Johnson @ 2012-09-16  3:54 UTC (permalink / raw)
  To: git

Add Ada xfuncname and wordRegex patterns to the list of builtin
patterns.

Signed-off-by: Adrian Johnson <ajohnson@redneon.com>
---
 Documentation/gitattributes.txt |  2 ++
 t/t4018-diff-funcname.sh        |  2 +-
 t/t4034-diff-words.sh           |  1 +
 t/t4034/ada/expect              | 27 +++++++++++++++++++++++++++
 t/t4034/ada/post                | 13 +++++++++++++
 t/t4034/ada/pre                 | 13 +++++++++++++
 userdiff.c                      |  9 +++++++++
 7 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 t/t4034/ada/expect
 create mode 100644 t/t4034/ada/post
 create mode 100644 t/t4034/ada/pre

diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 462b79c..99ed04d 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -511,6 +511,8 @@ configuration file (you still need to enable this with the
 attribute mechanism, via `.gitattributes`).  The following built in
 patterns are available:
 
+- `ada` suitable for source code in the Ada language.
+
 - `bibtex` suitable for files with BibTeX coded references.
 
 - `cpp` suitable for source code in the C and C++ languages.
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 4bd2a1c..082d3e8 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -105,7 +105,7 @@ test_expect_funcname () {
 	grep "^@@.*@@ $1" diff
 }
 
-for p in bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex
+for p in ada bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex
 do
 	test_expect_success "builtin $p pattern compiles" '
 		echo "*.java diff=$p" >.gitattributes &&
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 30d42cb..40ab333 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -298,6 +298,7 @@ test_expect_success 'unset default driver' '
 	test_unconfig diff.wordregex
 '
 
+test_language_driver ada
 test_language_driver bibtex
 test_language_driver cpp
 test_language_driver csharp
diff --git a/t/t4034/ada/expect b/t/t4034/ada/expect
new file mode 100644
index 0000000..be2376e
--- /dev/null
+++ b/t/t4034/ada/expect
@@ -0,0 +1,27 @@
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index d96fdd1..df21bb0 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
+<CYAN>@@ -1,13 +1,13 @@<RESET>
+Ada.Text_IO.Put_Line("Hello World<RED>!<RESET><GREEN>?<RESET>");
+1 1e<RED>-<RESET>10 16#FE12#E2 3.141_592 '<RED>x<RESET><GREEN>y<RESET>'
+<RED>a<RESET><GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET>
+<RED>a<RESET><GREEN>y<RESET>
+<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b<RESET>
+<RED>a<RESET><GREEN>y<RESET>
+<GREEN>x<RESET>**<RED>b<RESET>
+<RED>a<RESET><GREEN>y<RESET>
+<GREEN>x<RESET>(<RED>b<RESET><GREEN>y<RESET>)
+<RED>a<RESET><GREEN>x<RESET>:=<RED>b<RESET>
+<RED>a<RESET><GREEN>y<RESET>
+<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>/= <RED>b<RESET>
+<RED>a<RESET><GREEN>y<RESET>
+<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET>
+<RED>a<RESET><GREEN>y<RESET>
+<GREEN>x<RESET>,<RED>b<RESET>
+<RED>a<RESET><GREEN>y<RESET>
+<GREEN>x<RESET>=><RED>b<RESET>
+<RED>a<RESET><GREEN>y<RESET>
+<GREEN>x<RESET>..<RED>b<RESET>
+<RED>a<RESET><GREEN>y<RESET>
+<GREEN>x<RESET><><RED>b<RESET><GREEN>y<RESET>
diff --git a/t/t4034/ada/post b/t/t4034/ada/post
new file mode 100644
index 0000000..df21bb0
--- /dev/null
+++ b/t/t4034/ada/post
@@ -0,0 +1,13 @@
+Ada.Text_IO.Put_Line("Hello World?");
+1 1e10 16#FE12#E2 3.141_592 'y'
+x+y x-y
+x*y x/y
+x**y
+x(y)
+x:=y
+x=y x/= y
+x<y x<=y x>y x>=y
+x,y
+x=>y
+x..y
+x<>y
diff --git a/t/t4034/ada/pre b/t/t4034/ada/pre
new file mode 100644
index 0000000..d96fdd1
--- /dev/null
+++ b/t/t4034/ada/pre
@@ -0,0 +1,13 @@
+Ada.Text_IO.Put_Line("Hello World!");
+1 1e-10 16#FE12#E2 3.141_592 'x'
+a+b a-b
+a*b a/b
+a**b
+a(b)
+a:=b
+a=b a/= b
+a<b a<=b a>b a>=b
+a,b
+a=>b
+a..b
+a<>b
diff --git a/userdiff.c b/userdiff.c
index 1e7184f..ed958ef 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -14,6 +14,15 @@ static int drivers_alloc;
 	{ name, NULL, -1, { pattern, REG_EXTENDED | REG_ICASE }, \
 	  word_regex "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" }
 static struct userdiff_driver builtin_drivers[] = {
+IPATTERN("ada",
+	 "!^(.*[ \t])?(is new|renames|is separate)([ \t].*)?$\n"
+	 "!^[ \t]*with[ \t].*$\n"
+	 "^[ \t]*((procedure|function)[ \t]+.*)$\n"
+	 "^[ \t]*((package|protected|task)[ \t]+.*)$",
+	 /* -- */
+	 "[a-zA-Z][a-zA-Z0-9_]*"
+	 "|[0-9][-+0-9#_.eE]"
+	 "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"),
 IPATTERN("fortran",
 	 "!^([C*]|[ \t]*!)\n"
 	 "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"
-- 
1.7.12.465.g52d9ccc

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add userdiff patterns for Ada
  2012-09-16  3:54 [PATCH] Add userdiff patterns for Ada Adrian Johnson
@ 2012-09-16  6:07 ` Junio C Hamano
  2012-09-16  7:19   ` Adrian Johnson
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2012-09-16  6:07 UTC (permalink / raw)
  To: Adrian Johnson; +Cc: git

Adrian Johnson <ajohnson@redneon.com> writes:

> Add Ada xfuncname and wordRegex patterns to the list of builtin
> patterns.
>
> Signed-off-by: Adrian Johnson <ajohnson@redneon.com>
> ---

Interesting.  I do not read Ada, but in this "expect" file,...

> diff --git a/t/t4034/ada/expect b/t/t4034/ada/expect
> new file mode 100644
> index 0000000..be2376e
> --- /dev/null
> +++ b/t/t4034/ada/expect
> @@ -0,0 +1,27 @@
> +<BOLD>diff --git a/pre b/post<RESET>
> +<BOLD>index d96fdd1..df21bb0 100644<RESET>
> +<BOLD>--- a/pre<RESET>
> +<BOLD>+++ b/post<RESET>
> +<CYAN>@@ -1,13 +1,13 @@<RESET>
> +Ada.Text_IO.Put_Line("Hello World<RED>!<RESET><GREEN>?<RESET>");
> +1 1e<RED>-<RESET>10 16#FE12#E2 3.141_592 '<RED>x<RESET><GREEN>y<RESET>'
> +<RED>a<RESET><GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET>
> +<RED>a<RESET><GREEN>y<RESET>
> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b<RESET>
> +<RED>a<RESET><GREEN>y<RESET>
> +<GREEN>x<RESET>**<RED>b<RESET>
> +<RED>a<RESET><GREEN>y<RESET>
> +<GREEN>x<RESET>(<RED>b<RESET><GREEN>y<RESET>)
> +<RED>a<RESET><GREEN>x<RESET>:=<RED>b<RESET>
> +<RED>a<RESET><GREEN>y<RESET>
> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>/= <RED>b<RESET>
> +<RED>a<RESET><GREEN>y<RESET>
> +<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET>
> +<RED>a<RESET><GREEN>y<RESET>
> +<GREEN>x<RESET>,<RED>b<RESET>
> +<RED>a<RESET><GREEN>y<RESET>
> +<GREEN>x<RESET>=><RED>b<RESET>
> +<RED>a<RESET><GREEN>y<RESET>
> +<GREEN>x<RESET>..<RED>b<RESET>
> +<RED>a<RESET><GREEN>y<RESET>
> +<GREEN>x<RESET><><RED>b<RESET><GREEN>y<RESET>

I do not seem to find anything interesting after @@, which means
that xfuncname is not tested at all even though the log message
claims the patch adds some.

Puzzled...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add userdiff patterns for Ada
  2012-09-16  6:07 ` Junio C Hamano
@ 2012-09-16  7:19   ` Adrian Johnson
  2012-09-17  4:59     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian Johnson @ 2012-09-16  7:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 16/09/12 15:37, Junio C Hamano wrote:
> Adrian Johnson <ajohnson@redneon.com> writes:
> 
>> Add Ada xfuncname and wordRegex patterns to the list of builtin
>> patterns.
>>
>> Signed-off-by: Adrian Johnson <ajohnson@redneon.com>
>> ---
> 
> Interesting.  I do not read Ada, but in this "expect" file,...
> 
>> diff --git a/t/t4034/ada/expect b/t/t4034/ada/expect
>> new file mode 100644
>> index 0000000..be2376e
>> --- /dev/null
>> +++ b/t/t4034/ada/expect
>> @@ -0,0 +1,27 @@
>> +<BOLD>diff --git a/pre b/post<RESET>
>> +<BOLD>index d96fdd1..df21bb0 100644<RESET>
>> +<BOLD>--- a/pre<RESET>
>> +<BOLD>+++ b/post<RESET>
>> +<CYAN>@@ -1,13 +1,13 @@<RESET>
>> +Ada.Text_IO.Put_Line("Hello World<RED>!<RESET><GREEN>?<RESET>");
>> +1 1e<RED>-<RESET>10 16#FE12#E2 3.141_592 '<RED>x<RESET><GREEN>y<RESET>'
>> +<RED>a<RESET><GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET>
>> +<RED>a<RESET><GREEN>y<RESET>
>> +<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b<RESET>
>> +<RED>a<RESET><GREEN>y<RESET>
>> +<GREEN>x<RESET>**<RED>b<RESET>
>> +<RED>a<RESET><GREEN>y<RESET>
>> +<GREEN>x<RESET>(<RED>b<RESET><GREEN>y<RESET>)
>> +<RED>a<RESET><GREEN>x<RESET>:=<RED>b<RESET>
>> +<RED>a<RESET><GREEN>y<RESET>
>> +<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>/= <RED>b<RESET>
>> +<RED>a<RESET><GREEN>y<RESET>
>> +<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET>
>> +<RED>a<RESET><GREEN>y<RESET>
>> +<GREEN>x<RESET>,<RED>b<RESET>
>> +<RED>a<RESET><GREEN>y<RESET>
>> +<GREEN>x<RESET>=><RED>b<RESET>
>> +<RED>a<RESET><GREEN>y<RESET>
>> +<GREEN>x<RESET>..<RED>b<RESET>
>> +<RED>a<RESET><GREEN>y<RESET>
>> +<GREEN>x<RESET><><RED>b<RESET><GREEN>y<RESET>
> 
> I do not seem to find anything interesting after @@, which means
> that xfuncname is not tested at all even though the log message
> claims the patch adds some.

I probably misunderstood how the tests work. I thought t4034 tested
wordRegex while t4018 is for xfuncname. I based the Ada tests on the
Pascal tests but changed the operators to Ada operators. I'm not really
sure what else the test needs.

> 
> Puzzled...
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add userdiff patterns for Ada
  2012-09-16  7:19   ` Adrian Johnson
@ 2012-09-17  4:59     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2012-09-17  4:59 UTC (permalink / raw)
  To: Adrian Johnson; +Cc: git

Adrian Johnson <ajohnson@redneon.com> writes:

>> I do not seem to find anything interesting after @@, which means
>> that xfuncname is not tested at all even though the log message
>> claims the patch adds some.
>
> I probably misunderstood how the tests work. I thought t4034 tested
> wordRegex while t4018 is for xfuncname. I based the Ada tests on the
> Pascal tests but changed the operators to Ada operators. I'm not really
> sure what else the test needs.

The per-language for-loop you added ada to in t4018 is only to make
sure there is no regexp syntax error in the built-in xfuncname, and
does not check if the patterns make sense for the language at all.

You could add test vectors to check if the built-in xfuncname
catches beginning of functions in Ada correctly if you wanted to,
but I think observing what appears on @@ lines in t4034 test vector
would be a sufficient test.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-17  4:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-16  3:54 [PATCH] Add userdiff patterns for Ada Adrian Johnson
2012-09-16  6:07 ` Junio C Hamano
2012-09-16  7:19   ` Adrian Johnson
2012-09-17  4:59     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).