unitsofmeasurement/uom-systems

Digits not parsed correctly

frothga opened this issue · 5 comments

Code:
UnitFormat UCUM = ServiceProvider.current ().getFormatService ().getUnitFormat ("UCUM");
System.out.println ("d = " + UCUM.format (UCUM.parse ("d")));
System.out.println ("1.d = " + UCUM.format (UCUM.parse ("1.d")));
System.out.println ("2.d = " + UCUM.format (UCUM.parse ("2.d")));
System.out.println ("7.d = " + UCUM.format (UCUM.parse ("7.d")));

Output:
d = d
1.d = d
2.d = 12.d
7.d = 17.d

Version: systems-ucum-2.0.jar downloaded from Maven on 4/3/20

keilw commented

Thanks for pointing that out. I am not sure if it would make a difference but did you try 2.0.1 of the UCUM system as well?

Not yet. I was just about to pull the project from git and build. Since the parser is in JavaCC, I'm wondering if this is an error in the grammar definition.

Tested with systems-ucum-2.0.1. It was also necessary to upgrade to indriya-2.0.2 to get past a missing class exception. The code still behaves the same way as reported above.

Could not find a parser definition file (.jj or .jjt) in the current codebase in git. This makes it difficult to understand or debug the parser.

keilw commented

They have been discontinued a long time ago. It would exceed a small update do forward port from JSR 275: https://github.com/unitsofmeasurement/jsr-275/tree/master/src/main/javacc/javax/measure/unit/format, for UCUM such a jj file never existed.