summary refs log tree commit diff
path: root/bin/hilex
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-12-29 17:13:26 -0500
committerJune McEnroe <june@causal.agency>2020-12-29 17:13:26 -0500
commitb53f448c0aac381ad9d58f62bd1cc5ab06562d2e (patch)
tree6abb0ee2951c9720f7e001f165b83edbe24893c4 /bin/hilex
parentMatch C type declarations as IdentifierTag (diff)
downloadsrc-b53f448c0aac381ad9d58f62bd1cc5ab06562d2e.tar.gz
src-b53f448c0aac381ad9d58f62bd1cc5ab06562d2e.zip
Match top-level C definitions as IdentifierTag
Diffstat (limited to '')
-rw-r--r--bin/hilex/c.l15
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/hilex/c.l b/bin/hilex/c.l
index c5dc31ff..c8f4ba65 100644
--- a/bin/hilex/c.l
+++ b/bin/hilex/c.l
@@ -30,6 +30,7 @@ width "*"|[0-9]+
 
 %%
 	static int pop = INITIAL;
+	static int braces = 0;
 
 [[:blank:]]+ { return Normal; }
 
@@ -102,6 +103,11 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while |
 <MacroLine>{ident} { return Macro; }
 {ident} { return Identifier; }
 
+{ident}/("["[^]]*"]")*[[:space:]]*"=" |
+{ident}/"("[^)]*")"[[:space:]]*"{" {
+	return (!braces ? IdentifierTag : Identifier);
+}
+
 "//"([^\n]|"\\\n")* |
 "/*"([^*]|"*"[^/])*"*"+"/" {
 	return Comment;
@@ -147,6 +153,15 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while |
 	[^%\\""]+|. { return String; }
 }
 
+"{" {
+	braces++;
+	REJECT;
+}
+"}" {
+	braces--;
+	REJECT;
+}
+
 <MacroLine,MacroInclude,MacroDefine>. { return Macro; }
 
 .|\n { return Normal; }