PiotrDabkowski / pyjsparser

Fast JavaScript parser for Python.
MIT License
246 stars 37 forks source link

Integer was translated to float. #3

Closed timesong closed 8 years ago

timesong commented 8 years ago

For example,

var a = 2;

AST element is:

{
      "type": "ExpressionStatement",
      "expression": {
        "operator": "=",
        "right": {
          "raw": null,
          "type": "Literal",
          "value": 2.0
        },
        "type": "AssignmentExpression",
        "left": {
          "type": "Identifier",
          "name": "a"
        }
      }
    }

Do you have a solution for this issue?

PiotrDabkowski commented 8 years ago

In JavaScript there is no distinction between integer and float and all values are treated as float. You can easily adjust it to your needs with val = int(val) if int(val)==val else val .