Skip to content

Commit

Permalink
Merge branch 'c-fixes' of https://github.com/rygorous/prism into gh-p…
Browse files Browse the repository at this point in the history
…ages

Conflicts:
	components/prism-c.js
	components/prism-c.min.js
	components/prism-clike.js
	components/prism-clike.min.js

+ added tests
  • Loading branch information
Golmote committed Sep 3, 2015
1 parent 4d64d07 commit 071c3dd
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/prism-c.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Prism.languages.c = Prism.languages.extend('clike', {
'keyword': /\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
'operator': /\-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|?\||[~^%?*\/]/,
'number': /\b-?(0x[\da-f]+|\d*\.?\d+(e[+-]?\d+)?)[fFuUlL]*\b/i
'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
});

Prism.languages.insertBefore('c', 'string', {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-c.min.js

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

2 changes: 1 addition & 1 deletion components/prism-clike.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Prism.languages.clike = {
'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
'boolean': /\b(true|false)\b/,
'function': /[a-z0-9_]+(?=\()/i,
'number': /\b-?(0x[\da-f]+|\d*\.?\d+(e[+-]?\d+)?)\b/i,
'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
'punctuation': /[{}[\];(),.:]/
};
2 changes: 1 addition & 1 deletion components/prism-clike.min.js

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

2 changes: 1 addition & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ Prism.languages.clike = {
'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
'boolean': /\b(true|false)\b/,
'function': /[a-z0-9_]+(?=\()/i,
'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,
'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
'punctuation': /[{}[\];(),.:]/
};
Expand Down
35 changes: 35 additions & 0 deletions tests/languages/c/number_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
42
3.14159
4e10
2.1e-10
0.4e+2
0xbabe
0xBABE
42f
42F
42u
42U
42l
42L

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

[
["number", "42"],
["number", "3.14159"],
["number", "4e10"],
["number", "2.1e-10"],
["number", "0.4e+2"],
["number", "0xbabe"],
["number", "0xBABE"],
["number", "42f"],
["number", "42F"],
["number", "42u"],
["number", "42U"],
["number", "42l"],
["number", "42L"]
]

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

Checks for decimal numbers and hexadecimal numbers.
2 changes: 2 additions & 0 deletions tests/languages/clike/number_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
3.14159
4e10
2.1e-10
0.4e+2
0xbabe
0xBABE

Expand All @@ -12,6 +13,7 @@
["number", "3.14159"],
["number", "4e10"],
["number", "2.1e-10"],
["number", "0.4e+2"],
["number", "0xbabe"],
["number", "0xBABE"]
]
Expand Down

0 comments on commit 071c3dd

Please sign in to comment.