diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-11-10 12:27:21 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-11-10 12:27:21 +0100 |
| commit | 96299cbf09bdb75e4d6c6849c9c4c3ce000a6fc5 (patch) | |
| tree | 7d5f21e6c884a2cd87c619c5d97fddb4cceb7ea8 /lib/elixir_math_parser.ex | |
| parent | 7536cdbd312dff03ab10e46929dc1b072f881d01 (diff) | |
feat(parser): supports literal decimal numbers
Diffstat (limited to 'lib/elixir_math_parser.ex')
| -rw-r--r-- | lib/elixir_math_parser.ex | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/elixir_math_parser.ex b/lib/elixir_math_parser.ex index 4a96daf..286829e 100644 --- a/lib/elixir_math_parser.ex +++ b/lib/elixir_math_parser.ex @@ -4,11 +4,16 @@ defmodule ElixirMathParser do """ alias ElixirMathParser.Math.Rational alias ElixirMathParser.Math.Calc + alias ElixirMathParser.Math.Conversion defp reduce_to_value({:int, _line, value}, _state) do {:ok, Rational.new(value)} end + defp reduce_to_value({:float, _line, value}, _state) do + {:ok, to_string(value) |> Conversion.literal_float_to_rational()} + end + defp reduce_to_value({:var, line, var}, state) do if !Map.has_key?(state, var) do {:error, line, "value not found for " <> to_string(var)} |
