Javascript lexer missparse floating point numbers without dot

Issue #528 on hold
Anonymous created an issue

Numbers, which are floating point, but do not include a dot, will not be parsed correctly by the Javascript lexer.

Example:

1e5, 1e+5, 12E-2

Fix:

change

(r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),

to

(r'[0-9][0-9]\.[0-9]+([eE][+-]?[0-9]+)?[fd]?|[0-9][0-9]([eE][+-]?[0-9]+)[fd]?', Number.Float),

or something similar

in lexers/web.py

Reported by thoka

Comments (2)

  1. tyilo

    This is probably related: 0. should be parsed as [(Token.Literal.Number.Float, '0.')] instead of [(Token.Literal.Number.Integer, '0'), (Token.Punctuation, '.')].

    Also javascript only have floating point numbers, so I don't think JavascriptLexer should use Token.Literal.Number.Integer.

    You can see the wrong syntax highlighting here too: http://pygments.org/demo/2031743/

  2. Log in to comment