diff options
author | Christian Hergert <christian@hergert.me> | 2023-01-16 19:48:45 +0000 |
---|---|---|
committer | Christian Hergert <christian@hergert.me> | 2023-01-16 19:48:45 +0000 |
commit | da3f3d75cf246f0cc4dbdebac970ee246063ab64 (patch) | |
tree | 1ba0891400b0a9ef82ac477847658960813dfab8 | |
parent | 2a6d8226830bf33323d7c823890b61a777001e95 (diff) | |
parent | 9b47ee5bdaa2bbc0f84442e5467676318c5c1296 (diff) | |
download | gtksourceview-da3f3d75cf246f0cc4dbdebac970ee246063ab64.tar.gz |
Merge branch 'master' into 'master'
c.lang: highlight binary numbers
See merge request GNOME/gtksourceview!311
-rw-r--r-- | data/language-specs/c.lang | 19 | ||||
-rw-r--r-- | tests/syntax-highlighting/file.c | 7 |
2 files changed, 26 insertions, 0 deletions
diff --git a/data/language-specs/c.lang b/data/language-specs/c.lang index 641daf53..8ebb1fc7 100644 --- a/data/language-specs/c.lang +++ b/data/language-specs/c.lang @@ -47,6 +47,7 @@ <style id="escaped-character" name="Escaped Character" map-to="def:special-char"/> <style id="floating-point" name="Floating point number" map-to="def:floating-point"/> <style id="decimal" name="Decimal number" map-to="def:decimal"/> + <style id="binary" name="Binary number" map-to="def:base-n-integer"/> <style id="octal" name="Octal number" map-to="def:base-n-integer"/> <style id="hexadecimal" name="Hexadecimal number" map-to="def:base-n-integer"/> <style id="boolean" name="Boolean value" map-to="def:boolean"/> @@ -187,6 +188,22 @@ </match> </context> + <context id="binary" style-ref="binary"> + <match extended="true"> + (?<![\w\.]) + 0[bB][01]+[uUlL]* + (?![\w\.]) + </match> + </context> + + <context id="invalid-binary" style-ref="error"> + <match extended="true"> + (?<![\w\.]) + 0[bB][01]*[2-9][a-zA-Z0-9]*[uUlL]* + (?![\w\.]) + </match> + </context> + <context id="decimal" style-ref="decimal"> <match extended="true"> (?<![\w\.]) @@ -325,6 +342,8 @@ <context ref="invalid-hexadecimal"/> <context ref="octal"/> <context ref="invalid-octal"/> + <context ref="binary"/> + <context ref="invalid-binary"/> <context ref="decimal"/> <context ref="keywords"/> <context ref="type-keywords"/> diff --git a/tests/syntax-highlighting/file.c b/tests/syntax-highlighting/file.c index 74769b74..5ec5c0fe 100644 --- a/tests/syntax-highlighting/file.c +++ b/tests/syntax-highlighting/file.c @@ -8,6 +8,13 @@ int main (void) int b = 089; int c = 89.; int d = 'a'; + + int a = 0b0101U; + int c = 0b0101L; + int d = 0B0101L; + int b = 0b201u; + int b = 0B061u; + double hexadecimal_floating_constant = 0x1.2p3; printf ("Hello %s!\n", "world"); return 0; |