Skip to contentSkip to conversation

Add Pascal/Delphi (.pas file) funcname pattern.

PATCH In review Avery Pennarun 3 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add Pascal/Delphi (.pas file) funcname pattern.

Finds classes, records, functions, procedures, and sections. Most lines need to start at the first column, or else there's no way to differentiate a procedure's definition from its declaration.

---

The Ruby funcname pattern patch inspired me. Although unlike him, I didn't check with anyone else for confirmation. How many Pascal programmers can there possibly be? :)

 diff.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff.c +4 -0
index cbf2547..c73ba69 100644
@@ -1380,6 +1380,10 @@ static struct builtin_funcname_pattern {
 			"^[ 	]*\\(\\([ 	]*"
 			"[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
 			"[ 	]*([^;]*\\)$" },
+	{ "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
+			"destructor\\|interface\\|implementation\\|"
+			"type|initialization|finalization\\).*$\\)"
+			"\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },
 	{ "tex", "^\\(\\\\\\(sub\\)*section{.*\\)$" },
 };
 
Signature · 1 line
1.6.0.rc1.34.g23b24.dirty
#1 lore raw
Quoted 5 lines · Avery Pennarun
diff.c +0 -0
index cbf2547..c73ba69 100644

diff.c static struct builtin_funcname_pattern { · line 1389

Quoted 10 lines
diff.c +4 -0
@@ -1380,6 +1380,10 @@ static struct builtin_funcname_pattern {
 			"^[ 	]*\\(\\([ 	]*"
 			"[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
 			"[ 	]*([^;]*\\)$" },
+	{ "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
+			"destructor\\|interface\\|implementation\\|"
+			"type|initialization|finalization\\).*$\\)"
+			"\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },
 	{ "tex", "^\\(\\\\\\(sub\\)*section{.*\\)$" },
 };
 

Wouldn't it be better to make the second pattern start on new line instead of the outer \(\|\)?

Why "type"?

Signature · 3 lines
		Petr "Pasky, but not writing in Pascal anymore!" Baudis
As in certain cults it is possible to kill a process if you know
its true name.  -- Ken Thompson and Dennis M. Ritchie
#2 lore raw
Quoted 8 lines · Petr Baudis

diff.c static struct builtin_funcname_pattern { · line 1386

Quoted 4 lines · Avery Pennarun
diff.c +4 -0
+     { "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
+                     "destructor\\|interface\\|implementation\\|"
+                     "type|initialization|finalization\\).*$\\)"
+                     "\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },

Wouldn't it be better to make the second pattern start on new line
instead of the outer \(\|\)?

I didn't even know that was possible, but suddenly I understand the "java" pattern a lot better. Thanks!

Quoted 1 line

Why "type"?

Well, it's a subsection, but it's always followed by a class or record definition anyway, so I guess it makes more sense to omit it, now that you bring it up.

Have fun,

Avery

#3 lore raw
In reply to Avery Pennarun
Quoted 11 lines · Avery Pennarun

Finds classes, records, functions, procedures, and sections. Most lines need to start at the first column, or else there's no way to differentiate a procedure's definition from its declaration.

---

The Ruby funcname pattern patch inspired me. Although unlike him, I didn't check with anyone else for confirmation. How many Pascal programmers can there possibly be? :)

diff.c static struct builtin_funcname_pattern { · line 1386

Quoted 4 lines
diff.c +4 -0
+	{ "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
+			"destructor\\|interface\\|implementation\\|"
+			"type|initialization|finalization\\).*$\\)"
+			"\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },

Is Delphi the only surviving Pascal? Why is the name "pas", not "pascal" or even "delphi-pascal"?

The keys are not file extensions ("ruby" example did the right thing by not saying "rb").

#4 lore raw
Quoted 2 lines · Junio C Hamano

Is Delphi the only surviving Pascal? Why is the name "pas", not "pascal"
or even "delphi-pascal"?

No, but all surviving Pascals pretty much support the same syntax, so when I say Pascal/Delphi, I mean either one. And Delphi does use the .pas extension.

Quoted 2 lines

The keys are not file extensions ("ruby" example did the right thing by not saying "rb").

Will fix.

Avery