Export to GitHub

protobuf-dt - issue #102

Support for scientific notation for floating point options


Posted on Aug 25, 2011 by Grumpy Rhino

What steps will reproduce the problem? 1. Setup a project with the proto unit test files 2. Observe unittest.proto line 150

optional double default_double = 72 [default = 52e3 ];

  1. "52e3" is not recognized as a valid terminal

What is the expected output? What do you see instead?

As it appears in the unit tests for the proto library it stands to reason it should at least not provide a syntax error.

What version of the product are you using? On what operating system? 1.0.0

Please provide any additional information below.

This problem might be easy to solve...

The terminal for DECIMAL (line 159?) needs to be updated as such:

terminal DECIMAL: ('-')? (NUMBER)* ('.' (NUMBER)+)? ('e'('-')? (NUMBER)+)?;

added> ('e'('-')? (NUMBER)+)?

I'm not well versed enough in EMF to say if this will cause any problem with the

terminal FLOAT returns ecore::EFloat: DECIMAL; terminal DOUBLE returns ecore::EDouble: DECIMAL;

Rules which return ecore types. Are these parsed using Double.parseDouble(String)? (if so it should all work with just this terminal change - it seems the logical way for it to work as well)

Comment #1

Posted on Aug 25, 2011 by Grumpy Rhino

minor tweak - "E" appears to be valid in the test cases as well...

terminal DECIMAL: ('-')? (NUMBER)* ('.' (NUMBER)+)? (('e'|'E')('-')? (NUMBER)+)?;

Comment #2

Posted on Aug 29, 2011 by Grumpy Cat

(No comment was entered for this change.)

Comment #3

Posted on Aug 31, 2011 by Grumpy Cat

r333505e4fea0

Status: Fixed

Labels:
Type-Defect Priority-Medium Milestone-Release-1.0.1