Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP] Numeral syntax improvements #2701

Merged
merged 1 commit into from Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/prism-php.js
Expand Up @@ -15,7 +15,7 @@
/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/,
/\b(?:null)\b/i,
];
var number = /\b0b[01]+\b|\b0x[\da-f]+\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+)(?:e[+-]?\d+)?/i;
var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i;
var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/;
var punctuation = /[{}\[\](),:;]/;

Expand Down
2 changes: 1 addition & 1 deletion components/prism-php.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions tests/languages/php/number_feature.test
Expand Up @@ -7,6 +7,13 @@
0x539
0x1A
0123
0o123
0O123
0b1111_0000_111
0o1111_0000_123
0O1111_0000_123
01111_0000_123
0xAAAA_FFF_0123

----------------------------------------------------

Expand All @@ -19,9 +26,16 @@
["number", "0b10100111001"],
["number", "0x539"],
["number", "0x1A"],
["number", "0123"]
["number", "0123"],
["number", "0o123"],
["number", "0O123"],
["number", "0b1111_0000_111"],
["number", "0o1111_0000_123"],
["number", "0O1111_0000_123"],
["number", "01111_0000_123"],
["number", "0xAAAA_FFF_0123"]
]

----------------------------------------------------

Checks for numbers.
Checks for numbers.