diff options
author | June McEnroe <june@causal.agency> | 2021-01-13 15:57:57 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-01-13 15:57:57 -0500 |
commit | a96f0c74398f97804d36c1fc2c3b4ac7967ce6a0 (patch) | |
tree | f2e773adfaf98be1bd8361e6a651e1f1676e608c /bin | |
parent | Match [] as Operator in C lexer (diff) | |
download | src-a96f0c74398f97804d36c1fc2c3b4ac7967ce6a0.tar.gz src-a96f0c74398f97804d36c1fc2c3b4ac7967ce6a0.zip |
Try to return strings as single tokens
Diffstat (limited to 'bin')
-rw-r--r-- | bin/c11.l | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/bin/c11.l b/bin/c11.l index 18c0879a..98ff03c8 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; } |