summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-19 20:08:20 -0500
committerJune McEnroe <june@causal.agency>2021-01-19 20:15:13 -0500
commitf44f549f0caf9bcf41c68c9fdd694b36adace996 (patch)
tree861bdc19a06dbfacb7e8051257adbb7621bb56f3
parentMatch tab following escaped newline in make assignments (diff)
downloadsrc-f44f549f0caf9bcf41c68c9fdd694b36adace996.tar.gz
src-f44f549f0caf9bcf41c68c9fdd694b36adace996.zip
Support BSD make syntax and match *.am
These don't really go together, but...
Diffstat (limited to '')
-rw-r--r--bin/hilex.c2
-rw-r--r--bin/make.l30
-rw-r--r--bin/man1/hilex.18
3 files changed, 32 insertions, 8 deletions
diff --git a/bin/hilex.c b/bin/hilex.c
index 6574b1b2..93401d95 100644
--- a/bin/hilex.c
+++ b/bin/hilex.c
@@ -51,7 +51,7 @@ static const struct {
 	const char *linePatt;
 } Lexers[] = {
 	{ &LexC, "c", "[.][chlmy]$", NULL },
-	{ &LexMake, "make", "[.]mk$|^Makefile$", NULL },
+	{ &LexMake, "make", "[.](mk|am)$|^Makefile$", NULL },
 	{ &LexMdoc, "mdoc", "[.][1-9]$", "^[.]Dd" },
 	{ &LexText, "text", "[.]txt$", NULL },
 };
diff --git a/bin/make.l b/bin/make.l
index 49fda674..6d0c73f9 100644
--- a/bin/make.l
+++ b/bin/make.l
@@ -21,7 +21,7 @@
 #include "hilex.h"
 %}
 
-%s Assign
+%s Assign Preproc
 %x Variable Shell
 
 ident [._[:alnum:]]+
@@ -54,6 +54,30 @@ operator [:!]|::
 	return Keyword;
 }
 
+{target}/{operator} { return Ident; }
+
+^"."{ident} |
+^"-"?include {
+	BEGIN(pop = Preproc);
+	return Macro;
+}
+<Preproc>{
+	"\n" {
+		BEGIN(pop = INITIAL);
+		return Normal;
+	}
+	"\\\n""\t"? { return Normal; }
+
+	"\""[^""]*"\"" |
+	"<"[^>]*">" {
+		return String;
+	}
+
+	[!<>=]"="?|"||"|"&&" { return Operator; }
+	[0-9]+|"0x"[[:xdigit:]]+ { return Number; }
+	defined|make|empty|exists|target|commands|in { return Keyword; }
+}
+
 ^{ident}/[[:blank:]]*{assign} {
 	return Ident;
 }
@@ -67,12 +91,10 @@ operator [:!]|::
 		BEGIN(pop = INITIAL);
 		return Normal;
 	}
-	"\\\n""\t"? { return String; }
+	"\\\n""\t"? { return Escape; }
 	[^\\$[:space:]]+|. { return String; }
 }
 
-^"-"?include { return Macro; }
-
 {target} { return Ident; }
 
 "#"([^\\\n]|"\\"[^\n]|"\\\n")* { return Comment; }
diff --git a/bin/man1/hilex.1 b/bin/man1/hilex.1
index a151476a..e07695a3 100644
--- a/bin/man1/hilex.1
+++ b/bin/man1/hilex.1
@@ -166,12 +166,14 @@ Inferred for
 files.
 .
 .It Cm make
-The portable subset of
-.Xr make 1 .
+The BSD
+.Xr make 1
+language.
 Inferred for
+.Pa Makefile ,
 .Pa *.mk
 and
-.Pa Makefile
+.Pa *.am
 files.
 .
 .It Cm mdoc