Hi,

I've noticed that Rhino parsers loses some precission when working with
literals. This is a problem for me as I want to use the AST to rewrite an
exact copy (or manipulated one) of the code which fed the parser.

For example, for numbers the numeric values is stored in the double
attribute NumberLiteral.value even if the original source was an integer.
This would be right if there were a precise way to find the original source.
You can say that the class offers the method getValue() to provide just this
piece of information: the original String as read by the lexer. The problem
is that is not working right, for example, the for the hex literal "0xff",
getValue() will return "ff". So in some cases I'm not able to deduce the
original text written by the scripter. I think this is *Bug
545832<https://bugzilla.mozilla.org/show_bug.cgi?id=545832>
* which has a proposed patch (I would really appreciate if the patch could
be submitted to the repository).

Something similar happens with StringLiteral:

   - ecmascript input: "\u1234", getValue() returns "ሴ" and getSource()
   returns ""\\u1234""
   - ecmascript input "¿Soy un texto con acentos? Por supuesto que sí",
   getValue() returns "¿Soy un texto con acentos? Por supuesto que sí" and
   getSource() returns ""\\xbfSoy un texto con acentos? Por supuesto que
   s\\xed""

Am I doing something wrongly or as it seems they're just bugs?

Cheers,

Iván
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to