blueszhangsh / protobuf-dt

Automatically exported from code.google.com/p/protobuf-dt
0 stars 0 forks source link

Support for scientific notation for floating point options #102

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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  ];

3.  "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)

Original issue reported on code.google.com by compuwar...@gmail.com on 25 Aug 2011 at 3:44

GoogleCodeExporter commented 9 years ago
minor tweak - "E" appears to be valid in the test cases as well...

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

Original comment by compuwar...@gmail.com on 25 Aug 2011 at 4:22

GoogleCodeExporter commented 9 years ago

Original comment by alr...@google.com on 29 Aug 2011 at 7:18

GoogleCodeExporter commented 9 years ago
r333505e4fea0

Original comment by alr...@google.com on 31 Aug 2011 at 1:31