summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-12-29 15:05:39 -0500
committerJune McEnroe <june@causal.agency>2020-12-29 15:05:39 -0500
commit43fad502979651e9a11cd90f8508564c42ceab28 (patch)
tree073ec178e13036d7632e64f4911f09dec4c89c1b /bin
parentReconfigure C macro start conditions (diff)
downloadsrc-43fad502979651e9a11cd90f8508564c42ceab28.tar.gz
src-43fad502979651e9a11cd90f8508564c42ceab28.zip
Match function-like macro definitions as IdentifierTag
Diffstat (limited to '')
-rw-r--r--bin/hilex/c.l23
1 files changed, 19 insertions, 4 deletions
diff --git a/bin/hilex/c.l b/bin/hilex/c.l
index c0bd516d..29988c3f 100644
--- a/bin/hilex/c.l
+++ b/bin/hilex/c.l
@@ -21,7 +21,7 @@
 #include "hilex.h"
 %}
 
-%s MacroLine MacroInclude
+%s MacroLine MacroInclude MacroDefine
 %x CharLiteral StringLiteral
 
 ident [_[:alpha:]][_[:alnum:]]*
@@ -36,6 +36,10 @@ width "*"|[0-9]+
 	BEGIN(pop = MacroInclude);
 	return Macro;
 }
+^"#"[[:blank:]]*"define" {
+	BEGIN(pop = MacroDefine);
+	return Macro;
+}
 ^[#%][[:blank:]]*{ident} {
 	BEGIN(pop = MacroLine);
 	return Macro;
@@ -43,7 +47,18 @@ width "*"|[0-9]+
 
 <MacroInclude>"<"[^>]+">" { return String; }
 
-<MacroLine,MacroInclude>{
+<MacroDefine>{
+	{ident}/"(" {
+		BEGIN(pop = MacroLine);
+		return IdentifierTag;
+	}
+	{ident} {
+		BEGIN(pop = MacroLine);
+		return Macro;
+	}
+}
+
+<MacroLine,MacroInclude,MacroDefine>{
 	"\n" {
 		BEGIN(pop = INITIAL);
 		return Normal;
@@ -70,7 +85,7 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while |
 	return Keyword;
 }
 
-<MacroLine,MacroInclude>{ident} { return Macro; }
+<MacroLine>{ident} { return Macro; }
 {ident} { return Identifier; }
 
 "//"([^\n]|"\\\n")* |
@@ -118,7 +133,7 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while |
 	[^%\\""]+|. { return String; }
 }
 
-<MacroLine,MacroInclude>. { return Macro; }
+<MacroLine,MacroInclude,MacroDefine>. { return Macro; }
 
 .|\n { return Normal; }
 
src/commit/www/git.causal.agency/cgit/favicon.ico?id=5a8f6f3698fbd69b97483c7b84bf661f4761124f&follow=1'>Remove default faviconJune McEnroe 2021-09-21Use Z_FILTERED strategyJune McEnroe 2021-09-21Recalculate various lengths only as neededJune McEnroe 2021-09-21Rewrite pngo, add explicit optionsJune McEnroe 2021-09-16Fix /* **/ comment matchingJune McEnroe 2021-09-15Remove typer, add downgrade to READMEJune McEnroe 2021-09-15Set bot mode on downgradeJune McEnroe 2021-09-15Enter capsicum in downgradeJune McEnroe 2021-09-15Factor out common parts of downgrade messagesJune McEnroe 2021-09-14Add downgrade IRC botJune McEnroe 2021-09-14Sort by title if authors matchJune McEnroe 2021-09-13Swap-remove tags as they're foundJune McEnroe 2021-09-12Replace htagml regex with strncmpJune McEnroe 2021-09-11Also defer printing comment for lone close-parensJune McEnroe 2021-09-10Publish "git-comment"June McEnroe 2021-09-10Add git comment --pretty optionJune McEnroe 2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe 2021-09-08Up default min-repeat to 30 linesJune McEnroe 2021-09-08Handle dirty lines in git-commentJune McEnroe 2021-09-08Document and install git-commentJune McEnroe 2021-09-08Add repeat and all options to git-commentJune McEnroe 2021-09-08Add group threshold to git-commentJune McEnroe