summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2007-01-08 18:22:53 +0100
committergbrandl <devnull@localhost>2007-01-08 18:22:53 +0100
commit4784d9abd8e50a2e80e47037a823a75d66e0772f (patch)
treec945fba89f983e8d883592c531dab11484a01113
parent49c6f2f4940fb0063c965acda99d242560a31761 (diff)
downloadpygments-4784d9abd8e50a2e80e47037a823a75d66e0772f.tar.gz
[svn] Fixed C/C++ number lexing.
-rw-r--r--pygments/lexers/compiled.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 8d25b26b..bfa39ba2 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -49,12 +49,11 @@ class CLexer(RegexLexer):
'statements': [
(r'L?"', String, 'string'),
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
- (r'(0x[0-9a-fA-F]|0[0-7]+|(\d+\.\d*|\.\d+)|\d+)'
- r'e[+-]\d+[lL]?', Number.Float),
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
(r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
(r'0[0-7]+[Ll]?', Number.Oct),
- (r'(\d+\.\d*|\.\d+)', Number.Float),
- (r'\d+', Number.Integer),
+ (r'\d+[Ll]?', Number.Integer),
(r'[~!%^&*+=|?:<>/-]', Operator),
(r'[()\[\],.]', Punctuation),
(r'(auto|break|case|const|continue|default|do|else|enum|extern|'
@@ -140,21 +139,20 @@ class CppLexer(RegexLexer):
(r'[{}]', Keyword),
(r'L?"', String, 'string'),
(r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
- (r'(0x[0-9a-fA-F]|0[0-7]+|(\d+\.\d*|\.\d+)|\d+)'
- r'e[+-]\d+[lL]?', Number.Float),
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
(r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
(r'0[0-7]+[Ll]?', Number.Oct),
- (r'(\d+\.\d*|\.\d+)', Number.Float),
- (r'\d+', Number.Integer),
+ (r'\d+[Ll]?', Number.Integer),
(r'[~!%^&*+=|?:<>/-]', Operator),
(r'[()\[\],.;]', Punctuation),
(r'(asm|auto|break|case|catch|const|const_cast|continue|'
r'default|delete|do|dynamic_cast|else|enum|explicit|export|'
r'extern|for|friend|goto|if|mutable|namespace|new|operator|'
r'private|protected|public|register|reinterpret_cast|return|'
- r'sizeof|static|static_cast|struct|switch|template|this|throw|'
- r'throws|try|typedef|typeid|typename|union|using|volatile|'
- r'virtual|while)\b', Keyword),
+ r'restrict|sizeof|static|static_cast|struct|switch|template|'
+ r'this|throw|throws|try|typedef|typeid|typename|union|using|'
+ r'volatile|virtual|while)\b', Keyword),
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
(r'(bool|int|long|float|short|double|char|unsigned|signed|'
r'void|wchar_t)\b', Keyword.Type),