summary refs log tree commit diff
path: root/bin/hilex
diff options
context:
space:
mode:
Diffstat (limited to 'bin/hilex')
-rw-r--r--bin/hilex/c.l55
1 files changed, 26 insertions, 29 deletions
diff --git a/bin/hilex/c.l b/bin/hilex/c.l
index e6bd9ad0..056867ce 100644
--- a/bin/hilex/c.l
+++ b/bin/hilex/c.l
@@ -21,21 +21,36 @@
 #include "hilex.h"
 %}
 
-%x MacroLine MacroInclude
+%s MacroLine MacroInclude
 %x CharLiteral StringLiteral
 
+ident [_[:alpha:]][_[:alnum:]]*
 width "*"|[0-9]+
 
 %%
 	static int pop = INITIAL;
 
-[[:space:]]+ { return Normal; }
+[[:blank:]]+ { return Normal; }
 
-^"%" {
+^"#"[[:blank:]]*("include"|"import") {
+	BEGIN(pop = MacroInclude);
+	return Macro;
+}
+^[#%][[:blank:]]*{ident} {
 	BEGIN(pop = MacroLine);
 	return Macro;
 }
 
+<MacroInclude>"<"[^>]+">" { return String; }
+
+<MacroLine,MacroInclude>{
+	"\n" {
+		BEGIN(pop = INITIAL);
+		return Normal;
+	}
+	"\\\n" { return Macro; }
+}
+
 ([-+*/%&|^=!<>]|"<<"|">>")"="? |
 [=~.?:]|"++"|"--"|"&&"|"||"|"->" |
 sizeof|(_A|alignof) {
@@ -55,18 +70,19 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while |
 	return Keyword;
 }
 
-[_[:alpha:]][_[:alnum:]]* { return Identifier; }
+<MacroLine,MacroInclude>{ident} { return Macro; }
+{ident} { return Identifier; }
 
-<INITIAL,MacroLine>"//"([^\n]|"\\\n")* |
-<INITIAL,MacroLine>"/*"([^*]|"*"[^/])*"*"+"/" {
+"//"([^\n]|"\\\n")* |
+"/*"([^*]|"*"[^/])*"*"+"/" {
 	return Comment;
 }
 
-<INITIAL,MacroLine>[LUu]?"'" {
+[LUu]?"'" {
 	BEGIN(CharLiteral);
 	return String;
 }
-<INITIAL,MacroLine,MacroInclude>([LU]|u8?)?"\"" {
+([LU]|u8?)?"\"" {
 	BEGIN(StringLiteral);
 	return String;
 }
@@ -102,28 +118,9 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while |
 	[^%\\""]+|. { return String; }
 }
 
-^"#" {
-	BEGIN(pop = MacroLine);
-	return Macro;
-}
-^"#"[[:blank:]]*("include"|"import") {
-	BEGIN(pop = MacroInclude);
-	return Macro;
-}
-<MacroInclude>"<"[^>]+">" {
-	BEGIN(pop = MacroLine);
-	return String;
-}
-<MacroLine,MacroInclude>{
-	"\n" {
-		BEGIN(pop = INITIAL);
-		return Macro;
-	}
-	"\\\n" { return Macro; }
-	[^\\\n/<>''""]+|. { return Macro; }
-}
+<MacroLine,MacroInclude>. { return Macro; }
 
-. { return Normal; }
+.|\n { return Normal; }
 
 %{
 	(void)yyunput;
:35:57 -0500'>2021-02-07Set urgency on bell in xtermJune McEnroe 2021-02-07Add bindings for brightness controlJune McEnroe 2021-02-07Set X key repeat rateJune McEnroe 2021-02-07Bump font size to 12June McEnroe 2021-02-07Fully configure and rebind cwmJune McEnroe 2021-02-07Add BintiJune McEnroe 2021-02-07Finish configuring xtermJune McEnroe 2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe 2021-02-06Set root window to black on purple snowJune McEnroe 2021-02-06Add xmodmap configurationJune McEnroe 2021-02-06Add initial OpenBSD X configurationJune McEnroe 2021-02-06Add xterm output to schemeJune McEnroe