Skip to content

Commit

Permalink
Support binary integer literals and digit separators
Browse files Browse the repository at this point in the history
Example: 0b10000000'00000000'00000000'00000000

I rewrote the pattern to match integer literals so it’s stricter though will still match a partially typed number like ‘0x’ or one with a trailing digit separator (also considered partially typed), although here it marks the trailing separator as invalid.
  • Loading branch information
sorbits committed Mar 16, 2014
1 parent f39e73f commit 9afd484
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions Syntaxes/C.plist
Expand Up @@ -80,8 +80,31 @@
<string>#sizeof</string>
</dict>
<dict>
<key>captures</key>
<dict>
<key>inc</key>
<dict>
<key>name</key>
<string>invalid.illegal.digit-separator-should-not-be-last.c++</string>
</dict>
</dict>
<key>match</key>
<string>\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b</string>
<string>(?x)\b
( (?i:
0x ( \h+ ( ' \h+ )* )? # Hexadecimal
| 0b ( [0-1]+ ( ' [0-1]+ )* )? # Binary
| 0 ( [0-7]+ ( ' [0-7]+ )* ) # Octal
| ( [0-9]+ ( ' [0-9]+ )* ) # Decimal
)
( ([uUfF] | u?ll? | U?LL?)\b | (?&lt;inc&gt;') | \b )
| ( [0-9]+ ( ' [0-9]+ )* )?
(?i:
\. ( [0-9]+ ( ' [0-9]+ )* ) E(\+|-)? ( [0-9]+ ( ' [0-9]+ )* )
| \. ( [0-9]+ ( ' [0-9]+ )* )
| E(\+|-)? ( [0-9]+ ( ' [0-9]+ )* )
)
( (?&lt;inc&gt;') | \b )
)</string>
<key>name</key>
<string>constant.numeric.c</string>
</dict>
Expand Down Expand Up @@ -381,8 +404,8 @@
<string>\b([a-z0-9_]+_t)\b</string>
<key>name</key>
<string>support.type.posix-reserved.c</string>
</dict>
<dict>
</dict>
<dict>
<key>include</key>
<string>#block</string>
</dict>
Expand Down

0 comments on commit 9afd484

Please sign in to comment.