summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-13 15:57:57 -0500
committerJune McEnroe <june@causal.agency>2021-01-13 15:57:57 -0500
commita21e0e852a72060c54b00404a67f4cee8c3dceb5 (patch)
tree77f0fc680dc6b1fcae90b055b3e1e9c351929798 /bin
parentMatch [] as Operator in C lexer (diff)
downloadsrc-a21e0e852a72060c54b00404a67f4cee8c3dceb5.tar.gz
src-a21e0e852a72060c54b00404a67f4cee8c3dceb5.zip
Try to return strings as single tokens
Diffstat (limited to '')
-rw-r--r--bin/c11.l12
1 files changed, 10 insertions, 2 deletions
diff --git a/bin/c11.l b/bin/c11.l
index 3c951028..ce310ffc 100644
--- a/bin/c11.l
+++ b/bin/c11.l
@@ -83,10 +83,18 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while |
 	return Comment;
 }
 
+[LUu]?"'"/[^\\] {
+	BEGIN(CharLiteral);
+	yymore();
+}
 [LUu]?"'" {
 	BEGIN(CharLiteral);
 	return String;
 }
+([LU]|u8?)?"\""/[^\\%] {
+	BEGIN(StringLiteral);
+	yymore();
+}
 ([LU]|u8?)?"\"" {
 	BEGIN(StringLiteral);
 	return String;
@@ -109,14 +117,14 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while |
 }
 
 <CharLiteral>{
-	"'" {
+	[^\\'']*"'" {
 		BEGIN(pop);
 		return String;
 	}
 	[^\\'']+|. { return String; }
 }
 <StringLiteral>{
-	"\"" {
+	[^%\\""]*"\"" {
 		BEGIN(pop);
 		return String;
 	}