Skip to content

Commit

Permalink
Capturing all scenarios with regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Neko-Box-Coder committed Jun 8, 2024
1 parent d5ee3f1 commit 332e515
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions runtime/syntax/cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,36 @@ rules:
- symbol.operator: "[-+*/%=<>.:;,~&|^!?]|\\b(sizeof|alignof|typeid|(and|or|xor|not)(_eq)?|bitor|compl|bitand|(const|dynamic|reinterpret|static)_cast)\\b"
# Parenthetical Color
- symbol.brackets: "[(){}]|\\[|\\]"

# Integer Literals
- constant.number: "(\\b([0-9]|0[0-7]|0[Xx][0-9A-Fa-f]|0[Bb][01])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)"
- constant.number: "(\\b([1-9][0-9']*[0-9]|0[0-7][0-7']*[0-7])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)"
- constant.number: "(\\b(0[Xx][0-9A-Fa-f][0-9A-Fa-f']*[0-9A-Fa-f]|0[Bb][01][01']*[01])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)"
- constant.number: "(\\b([0-9]|0[0-7]|0[Xx][0-9A-Fa-f]|0[Bb][01])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Base case (Without ' separtor)
- constant.number: "(\\b([1-9][0-9']*[0-9])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Decimal
- constant.number: "(\\b(0[0-7][0-7']*[0-7])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Oct
- constant.number: "(\\b(0[Xx][0-9A-Fa-f][0-9A-Fa-f']*[0-9A-Fa-f])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Hex
- constant.number: "(\\b(0[Bb][01][01']*[01])([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)" # Binary

# Decimal Floating-point Literals
- constant.number: "(\\b(([.][0-9']*[0-9]|[0-9][0-9']*[.]|[0-9][0-9']*[.][0-9']*[0-9])([Ee][+-]?[0-9']+)?|[0-9']+[Ee][+-]?[0-9']+)[FfLl]?\\b)"
- constant.number: "(([0-9]?[.]?[0-9]+)([Ee][+-]?[0-9]+)?[FfLl]?\\b)" # Base case optional interger part with exponent base case
- constant.number: "(\\b([0-9]+[.][0-9]?)([Ee][+-]?[0-9]+)?[FfLl]?)" # Base case optional fractional part with exponent base case
- constant.number: "(([0-9]?[.]?[0-9]+)([Ee][+-]?[0-9][0-9']*[0-9])?[FfLl]?\\b)" # Base case optional interger part with exponent
- constant.number: "(\\b([0-9]+[.][0-9]?)([Ee][+-]?[0-9][0-9']*[0-9])?[FfLl]?)" # Base case optional fractional part with exponent

- constant.number: "(([0-9][0-9']*[0-9])?[.]?([0-9][0-9']*[0-9])+([Ee][+-]?[0-9]+)?[FfLl]?\\b)" # Optional interger part with exponent base case
- constant.number: "(\\b([0-9][0-9']*[0-9])+[.]([0-9][0-9']*[0-9])?([Ee][+-]?[0-9]+)?[FfLl]?)" # Optional fractional part with exponent base case
- constant.number: "(([0-9][0-9']*[0-9])?[.]?([0-9][0-9']*[0-9])+([Ee][+-]?[0-9][0-9']*[0-9])?[FfLl]?\\b)" # Optional interger part with exponent
- constant.number: "(\\b([0-9][0-9']*[0-9])+[.]([0-9][0-9']*[0-9])?([Ee][+-]?[0-9][0-9']*[0-9])?[FfLl]?)" # Optional fractional part with exponent

# Hexadecimal Floating-point Literals
- constant.number: "(\\b0[Xx]([.][0-9a-zA-Z']*[0-9a-zA-Z]|[0-9a-zA-Z][0-9a-zA-Z']*[.])[Pp][+-]?[0-9']+[FfLl]?\\b)"
- constant.number: "(\\b0[Xx]([0-9a-zA-Z][0-9a-zA-Z']*[.][0-9a-zA-Z']*[0-9a-zA-Z])[Pp][+-]?[0-9']+[FfLl]?\\b)"
- constant.number: "(\\b0[Xx]([0-9a-zA-Z]?[.]?[0-9a-zA-Z]+)([Pp][+-]?[0-9]+)?[FfLl]?\\b)" # Base case optional interger part with exponent base case
- constant.number: "(\\b0[Xx]([0-9a-zA-Z]+[.][0-9a-zA-Z]?)([Pp][+-]?[0-9]+)?[FfLl]?)" # Base case optional fractional part with exponent base case
- constant.number: "(\\b0[Xx]([0-9a-zA-Z]?[.]?[0-9a-zA-Z]+)([Pp][+-]?[0-9][0-9']*[0-9])?[FfLl]?\\b)" # Base case optional interger part with exponent
- constant.number: "(\\b0[Xx]([0-9a-zA-Z]+[.][0-9a-zA-Z]?)([Pp][+-]?[0-9][0-9']*[0-9])?[FfLl]?)" # Base case optional fractional part with exponent

- constant.number: "(\\b0[Xx]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])?[.]?([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])+([Pp][+-]?[0-9]+)?[FfLl]?\\b)" # Optional interger part with exponent base case
- constant.number: "(\\b0[Xx]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])+[.]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])?([Pp][+-]?[0-9]+)?[FfLl]?)" # Optional fractional part with exponent base case
- constant.number: "(\\b0[Xx]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])?[.]?([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])+([Pp][+-]?[0-9][0-9']*[0-9])?[FfLl]?\\b)" # Optional interger part with exponent
- constant.number: "(\\b0[Xx]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])+[.]([0-9a-zA-Z][0-9a-zA-Z']*[0-9a-zA-Z])?([Pp][+-]?[0-9][0-9']*[0-9])?[FfLl]?)" # Optional fractional part with exponent

- constant.bool: "(\\b(true|false|NULL|nullptr|TRUE|FALSE)\\b)"

- constant.string:
Expand All @@ -50,9 +71,10 @@ rules:
- constant.string:
start: "'"
end: "'"
skip: "(\\\\.)|(\\b[1-9][0-9]*'[0-9']*[0-9]|0[0-7]+'[0-7']*[0-7]|0[Xx][0-9A-Fa-f]+'[0-9A-Fa-f']*[0-9A-Fa-f]|0[Bb][01]+'[01']*[01]\\b)"
skip: "(\\\\.)|(\\b[1-9][0-9']+[0-9]|0[0-7']+[0-7]|0[Xx][0-9A-Fa-f][0-9A-Fa-f']+[0-9A-Fa-f]|0[Bb][01][01']*[01]\\b)"
rules:
- error: "[[:graph:]]{2,}'"
# - error: "..+'"
- constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})"

- comment:
Expand Down

0 comments on commit 332e515

Please sign in to comment.