joshwlewis / unitwise

Physical quantity and units of measure conversion and math for Ruby
unitwise.org
MIT License
281 stars 32 forks source link

Area are with deci prefix fails #26

Open phlegx opened 8 years ago

phlegx commented 8 years ago

Hi! I want to search deci are (d as prefix and ar as primary code):

Unitwise(1, 'dar')

but I get this error:

Unitwise::ExpressionError: Could not evaluate 'care'.

Any idea?

phlegx commented 8 years ago

The problem seams to be on the prefixes deka and deci:

- :names: deka
  :symbol: da
  :primary_code: da
  :secondary_code: DA
  :scalar: 1e1
- :names: deci
  :symbol: d
  :primary_code: d
  :secondary_code: D
  :scalar: 1e-1

Unitwise(1, 'dar') the parser finds before da as prefix instead of d.

Unitwise(1, 'deciare') works!

joshwlewis commented 7 years ago

@phlegx, thanks for the report. This certainly looks like a bug. dar should be something we can parse. We should be able to parse da as the same unit, but it fails in the same way.

I suspect that you are correct, and it has something to do with that da prefix being consumed by the parser.