diff mbox series

[2/3] userdiff: permit the digit-separating single-quote in numbers

Message ID 9d1c05f5f414b77a4edd741b738f47d4b9e3c56a.1633589461.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series Fun with cpp word regex | expand

Commit Message

Johannes Sixt Oct. 7, 2021, 6:50 a.m. UTC
From: Johannes Sixt <j6t@kdbg.org>

Since C++17, the single-quote can be used as digit separator:

   3.141'592'654
   1'000'000
   0xdead'beaf

Make it known to the word regex of the cpp driver, so that numbers are not
split into separate tokens at the single-quotes.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 userdiff.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/userdiff.c b/userdiff.c
index ce2a9230703..1b640c7df79 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -57,11 +57,11 @@  PATTERNS("cpp",
 	 /* identifiers and keywords */
 	 "[a-zA-Z_][a-zA-Z0-9_]*"
 	 /* decimal and octal integers as well as floatingpoint numbers */
-	 "|[0-9][0-9.]*([Ee][-+]?[0-9]+)?[fFlLuU]*"
+	 "|[0-9][0-9.']*([Ee][-+]?[0-9]+)?[fFlLuU]*"
 	 /* hexadecimal and binary integers */
-	 "|0[xXbB][0-9a-fA-F]+[lLuU]*"
+	 "|0[xXbB][0-9a-fA-F']+[lLuU]*"
 	 /* floatingpoint numbers that begin with a decimal point */
-	 "|\\.[0-9]+([Ee][-+]?[0-9]+)?[fFlL]?"
+	 "|\\.[0-9']+([Ee][-+]?[0-9]+)?[fFlL]?"
 	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"),
 PATTERNS("csharp",
 	 /* Keywords */